Skip to content

Commit

Permalink
micro-ROS get_type_description fix
Browse files Browse the repository at this point in the history
Signed-off-by: acuadros95 <acuadros1995@gmail.com>

Revert minor change

Signed-off-by: acuadros95 <acuadros1995@gmail.com>

Remove vscode file

Signed-off-by: acuadros95 <acuadros1995@gmail.com>
  • Loading branch information
pablogs9 committed Jul 19, 2023
1 parent 8aa3c11 commit 0d583e2
Show file tree
Hide file tree
Showing 8 changed files with 43 additions and 14 deletions.
4 changes: 2 additions & 2 deletions rcl/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ set(${PROJECT_NAME}_sources
src/rcl/network_flow_endpoints.c
src/rcl/node.c
src/rcl/node_options.c
src/rcl/node_type_cache.c
$<$<NOT:$<BOOL:${RCL_MICROROS}>>:src/rcl/node_type_cache.c>
src/rcl/publisher.c
src/rcl/remap.c
src/rcl/node_resolve_name.c
Expand All @@ -79,7 +79,7 @@ set(${PROJECT_NAME}_sources
src/rcl/time.c
src/rcl/timer.c
src/rcl/type_hash.c
src/rcl/type_description_conversions.c
$<$<NOT:$<BOOL:${RCL_MICROROS}>>:src/rcl/type_description_conversions.c>
src/rcl/validate_enclave_name.c
src/rcl/validate_topic_name.c
src/rcl/wait.c
Expand Down
9 changes: 6 additions & 3 deletions rcl/src/rcl/client.c
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,9 @@ extern "C"

#include "rcl/error_handling.h"
#include "rcl/node.h"
#ifdef RCL_MICROROS_COMPLETE_IMPL
#include "rcl/node_type_cache.h"
#endif // RCL_MICROROS_COMPLETE_IMPL
#include "rcl/publisher.h"
#include "rcl/time.h"
#include "rcutils/logging_macros.h"
Expand Down Expand Up @@ -177,7 +179,7 @@ rcl_client_init(
// options
client->impl->options = *options;
atomic_init(&client->impl->sequence_number, 0);

#ifdef RCL_MICROROS_COMPLETE_IMPL
if (RCL_RET_OK != rcl_node_type_cache_register_type(
node, type_support->get_type_hash_func(type_support),
type_support->get_type_description_func(type_support),
Expand All @@ -188,6 +190,7 @@ rcl_client_init(
ret = RCL_RET_ERROR;
goto destroy_client;
}
#endif // RCL_MICROROS_COMPLETE_IMPL
client->impl->type_hash = *type_support->get_type_hash_func(type_support);

RCUTILS_LOG_DEBUG_NAMED(ROS_PACKAGE_NAME, "Client initialized");
Expand Down Expand Up @@ -250,15 +253,15 @@ rcl_client_fini(rcl_client_t * client, rcl_node_t * node)
RCL_SET_ERROR_MSG(rmw_get_error_string().str);
result = RCL_RET_ERROR;
}

#ifdef RCL_MICROROS_COMPLETE_IMPL
if (
ROSIDL_TYPE_HASH_VERSION_UNSET != client->impl->type_hash.version &&
RCL_RET_OK != rcl_node_type_cache_unregister_type(node, &client->impl->type_hash))
{
RCUTILS_SAFE_FWRITE_TO_STDERR(rcl_get_error_string().str);
result = RCL_RET_ERROR;
}

#endif // RCL_MICROROS_COMPLETE_IMPL
allocator.deallocate(client->impl->remapped_service_name, allocator.state);
client->impl->remapped_service_name = NULL;

Expand Down
2 changes: 2 additions & 0 deletions rcl/src/rcl/node.c
Original file line number Diff line number Diff line change
Expand Up @@ -561,6 +561,7 @@ void rcl_node_type_description_service_handle_request(
const type_description_interfaces__srv__GetTypeDescription_Request * request,
type_description_interfaces__srv__GetTypeDescription_Response * response)
{
#ifdef RCL_MICROROS_COMPLETE_IMPL
rcl_type_info_t type_info;
RCL_CHECK_FOR_NULL_WITH_MSG(node, "invalid node handle", return;);
RCL_CHECK_FOR_NULL_WITH_MSG(node->impl, "invalid node", return;);
Expand Down Expand Up @@ -619,6 +620,7 @@ void rcl_node_type_description_service_handle_request(
}

response->successful = true;
#endif //RCL_MICROROS
}

rcl_ret_t rcl_node_type_description_service_init(rcl_node_t * node)
Expand Down
7 changes: 6 additions & 1 deletion rcl/src/rcl/publisher.c
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,9 @@ extern "C"
#include "rcl/allocator.h"
#include "rcl/error_handling.h"
#include "rcl/node.h"
#ifdef RCL_MICROROS_COMPLETE_IMPL
#include "rcl/node_type_cache.h"
#endif // RCL_MICROROS_COMPLETE_IMPL
#include "rcutils/logging_macros.h"
#include "rcutils/macros.h"
#include "rcl/time.h"
Expand Down Expand Up @@ -128,7 +130,7 @@ rcl_publisher_init(
options->qos.avoid_ros_namespace_conventions;
// options
publisher->impl->options = *options;

#ifdef RCL_MICROROS_COMPLETE_IMPL
if (RCL_RET_OK != rcl_node_type_cache_register_type(
node, type_support->get_type_hash_func(type_support),
type_support->get_type_description_func(type_support),
Expand All @@ -138,6 +140,7 @@ rcl_publisher_init(
RCL_SET_ERROR_MSG("Failed to register type for subscription");
goto fail;
}
#endif // RCL_MICROROS_COMPLETE_IMPL
publisher->impl->type_hash = *type_support->get_type_hash_func(type_support);

RCUTILS_LOG_DEBUG_NAMED(ROS_PACKAGE_NAME, "Publisher initialized");
Expand Down Expand Up @@ -201,13 +204,15 @@ rcl_publisher_fini(rcl_publisher_t * publisher, rcl_node_t * node)
RCL_SET_ERROR_MSG(rmw_get_error_string().str);
result = RCL_RET_ERROR;
}
#ifdef RCL_MICROROS_COMPLETE_IMPL
if (
ROSIDL_TYPE_HASH_VERSION_UNSET != publisher->impl->type_hash.version &&
RCL_RET_OK != rcl_node_type_cache_unregister_type(node, &publisher->impl->type_hash))
{
RCUTILS_SAFE_FWRITE_TO_STDERR(rcl_get_error_string().str);
result = RCL_RET_ERROR;
}
#endif // RCL_MICROROS_COMPLETE_IMPL
allocator.deallocate(publisher->impl, allocator.state);
publisher->impl = NULL;
}
Expand Down
9 changes: 6 additions & 3 deletions rcl/src/rcl/service.c
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,9 @@ extern "C"

#include "rcl/error_handling.h"
#include "rcl/node.h"
#ifdef RCL_MICROROS_COMPLETE_IMPL
#include "rcl/node_type_cache.h"
#endif // RCL_MICROROS_COMPLETE_IMPL
#include "rcl/publisher.h"
#include "rcl/time.h"
#include "rcl/types.h"
Expand Down Expand Up @@ -188,7 +190,7 @@ rcl_service_init(

// options
service->impl->options = *options;

#ifdef RCL_MICROROS_COMPLETE_IMPL
if (RCL_RET_OK != rcl_node_type_cache_register_type(
node, type_support->get_type_hash_func(type_support),
type_support->get_type_description_func(type_support),
Expand All @@ -199,6 +201,7 @@ rcl_service_init(
ret = RCL_RET_ERROR;
goto destroy_service;
}
#endif // RCL_MICROROS_COMPLETE_IMPL
service->impl->type_hash = *type_support->get_type_hash_func(type_support);

RCUTILS_LOG_DEBUG_NAMED(ROS_PACKAGE_NAME, "Service initialized");
Expand Down Expand Up @@ -262,15 +265,15 @@ rcl_service_fini(rcl_service_t * service, rcl_node_t * node)
RCL_SET_ERROR_MSG(rmw_get_error_string().str);
result = RCL_RET_ERROR;
}

#ifdef RCL_MICROROS_COMPLETE_IMPL
if (
ROSIDL_TYPE_HASH_VERSION_UNSET != service->impl->type_hash.version &&
RCL_RET_OK != rcl_node_type_cache_unregister_type(node, &service->impl->type_hash))
{
RCUTILS_SAFE_FWRITE_TO_STDERR(rcl_get_error_string().str);
result = RCL_RET_ERROR;
}

#endif // RCL_MICROROS_COMPLETE_IMPL
allocator.deallocate(service->impl->remapped_service_name, allocator.state);
service->impl->remapped_service_name = NULL;

Expand Down
9 changes: 6 additions & 3 deletions rcl/src/rcl/subscription.c
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,9 @@ extern "C"

#include "rcl/error_handling.h"
#include "rcl/node.h"
#ifdef RCL_MICROROS_COMPLETE_IMPL
#include "rcl/node_type_cache.h"
#endif // RCL_MICROROS_COMPLETE_IMPL
#include "rcutils/logging_macros.h"
#include "rcutils/strdup.h"
#include "rcutils/types/string_array.h"
Expand Down Expand Up @@ -123,7 +125,7 @@ rcl_subscription_init(
options->qos.avoid_ros_namespace_conventions;
// options
subscription->impl->options = *options;

#ifdef RCL_MICROROS_COMPLETE_IMPL
if (RCL_RET_OK != rcl_node_type_cache_register_type(
node, type_support->get_type_hash_func(type_support),
type_support->get_type_description_func(type_support),
Expand All @@ -133,6 +135,7 @@ rcl_subscription_init(
RCL_SET_ERROR_MSG("Failed to register type for subscription");
goto fail;
}
#endif // RCL_MICROROS_COMPLETE_IMPL
subscription->impl->type_hash = *type_support->get_type_hash_func(type_support);

RCUTILS_LOG_DEBUG_NAMED(ROS_PACKAGE_NAME, "Subscription initialized");
Expand Down Expand Up @@ -205,7 +208,7 @@ rcl_subscription_fini(rcl_subscription_t * subscription, rcl_node_t * node)
RCUTILS_SAFE_FWRITE_TO_STDERR("\n");
result = RCL_RET_ERROR;
}

#ifdef RCL_MICROROS_COMPLETE_IMPL
if (
ROSIDL_TYPE_HASH_VERSION_UNSET != subscription->impl->type_hash.version &&
RCL_RET_OK != rcl_node_type_cache_unregister_type(node, &subscription->impl->type_hash))
Expand All @@ -214,7 +217,7 @@ rcl_subscription_fini(rcl_subscription_t * subscription, rcl_node_t * node)
RCUTILS_SAFE_FWRITE_TO_STDERR("\n");
result = RCL_RET_ERROR;
}

#endif // RCL_MICROROS_COMPLETE_IMPL
allocator.deallocate(subscription->impl, allocator.state);
subscription->impl = NULL;
}
Expand Down
8 changes: 7 additions & 1 deletion rcl_action/src/rcl_action/action_client.c
Original file line number Diff line number Diff line change
Expand Up @@ -25,10 +25,12 @@ extern "C"
#include "rcl_action/types.h"
#include "rcl_action/wait.h"

#ifdef RCL_MICROROS_COMPLETE_IMPL
#include "rcl/node_type_cache.h"
#endif // RCL_MICROROS_COMPLETE_IMPL
#include "rcl/client.h"
#include "rcl/error_handling.h"
#include "rcl/graph.h"
#include "rcl/node_type_cache.h"
#include "rcl/subscription.h"
#include "rcl/types.h"
#include "rcl/wait.h"
Expand Down Expand Up @@ -93,12 +95,14 @@ _rcl_action_client_fini_impl(
if (RCL_RET_OK != rcl_subscription_fini(&action_client->impl->status_subscription, node)) {
ret = RCL_RET_ERROR;
}
#ifdef RCL_MICROROS_COMPLETE_IMPL
if (
ROSIDL_TYPE_HASH_VERSION_UNSET != action_client->impl->type_hash.version &&
RCL_RET_OK != rcl_node_type_cache_unregister_type(node, &action_client->impl->type_hash))
{
ret = RCL_RET_ERROR;
}
#endif // RCL_MICROROS_COMPLETE_IMPL
allocator.deallocate(action_client->impl->action_name, allocator.state);
allocator.deallocate(action_client->impl, allocator.state);
action_client->impl = NULL;
Expand Down Expand Up @@ -230,6 +234,7 @@ rcl_action_client_init(
SUBSCRIPTION_INIT(feedback);
SUBSCRIPTION_INIT(status);

#ifdef RCL_MICROROS_COMPLETE_IMPL
if (RCL_RET_OK != rcl_node_type_cache_register_type(
node, type_support->get_type_hash_func(type_support),
type_support->get_type_description_func(type_support),
Expand All @@ -239,6 +244,7 @@ rcl_action_client_init(
RCL_SET_ERROR_MSG("Failed to register type for action");
goto fail;
}
#endif // RCL_MICROROS_COMPLETE_IMPL
action_client->impl->type_hash = *type_support->get_type_hash_func(type_support);

RCUTILS_LOG_DEBUG_NAMED(ROS_PACKAGE_NAME, "Action client initialized");
Expand Down
9 changes: 8 additions & 1 deletion rcl_action/src/rcl_action/action_server.c
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,10 @@ extern "C"
#include "rcl_action/types.h"
#include "rcl_action/wait.h"

#include "rcl/error_handling.h"
#ifdef RCL_MICROROS_COMPLETE_IMPL
#include "rcl/node_type_cache.h"
#endif // RCL_MICROROS_COMPLETE_IMPL
#include "rcl/error_handling.h"
#include "rcl/rcl.h"
#include "rcl/time.h"

Expand Down Expand Up @@ -195,6 +197,7 @@ rcl_action_server_init(
goto fail;
}

#ifdef RCL_MICROROS_COMPLETE_IMPL
// Store type hash
if (RCL_RET_OK != rcl_node_type_cache_register_type(
node, type_support->get_type_hash_func(type_support),
Expand All @@ -205,6 +208,7 @@ rcl_action_server_init(
RCL_SET_ERROR_MSG("Failed to register type for action");
goto fail;
}
#endif // RCL_MICROROS_COMPLETE_IMPL
action_server->impl->type_hash = *type_support->get_type_hash_func(type_support);

return ret;
Expand Down Expand Up @@ -264,12 +268,15 @@ rcl_action_server_fini(rcl_action_server_t * action_server, rcl_node_t * node)
}
allocator.deallocate(action_server->impl->goal_handles, allocator.state);
action_server->impl->goal_handles = NULL;

#ifdef RCL_MICROROS_COMPLETE_IMPL
if (
ROSIDL_TYPE_HASH_VERSION_UNSET != action_server->impl->type_hash.version &&
RCL_RET_OK != rcl_node_type_cache_unregister_type(node, &action_server->impl->type_hash))
{
ret = RCL_RET_ERROR;
}
#endif // RCL_MICROROS_COMPLETE_IMPL
// Deallocate struct
allocator.deallocate(action_server->impl, allocator.state);
action_server->impl = NULL;
Expand Down

0 comments on commit 0d583e2

Please sign in to comment.