Skip to content

Commit

Permalink
Migrate to type description interfaces
Browse files Browse the repository at this point in the history
Signed-off-by: methylDragon <methylDragon@gmail.com>
  • Loading branch information
methylDragon committed Mar 16, 2023
1 parent 5a0a864 commit 8d01f92
Show file tree
Hide file tree
Showing 6 changed files with 23 additions and 26 deletions.
10 changes: 3 additions & 7 deletions rcl/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,7 @@ find_package(rmw_implementation REQUIRED)
find_package(rosidl_runtime_c REQUIRED)
find_package(service_msgs REQUIRED)
find_package(tracetools REQUIRED)

# TODO(methylDragon): TEMPORARY! REMOVE EVENTUALLY WHEN WE HAVE A TYPE DESCRIPTION MESSAGE IN RMW
find_package(rosidl_dynamic_typesupport REQUIRED)
find_package(type_description_interfaces REQUIRED)

include(cmake/rcl_set_symbol_visibility_hidden.cmake)
include(cmake/get_default_rcl_logging_implementation.cmake)
Expand Down Expand Up @@ -79,10 +77,8 @@ target_include_directories(${PROJECT_NAME} PUBLIC
"$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/include>"
"$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/src>"
"$<INSTALL_INTERFACE:include/${PROJECT_NAME}>")

# TODO(methylDragon): THIS TARGET_LINK_LIBRARIES IS TEMPORARY! REMOVE EVENTUALLY
target_link_libraries(${PROJECT_NAME}
rosidl_dynamic_typesupport::rosidl_dynamic_typesupport # TODO(methylDragon): TEMPORARY! REMOVE EVENTUALLY
${type_description_interfaces__TARGETS}
)
# specific order: dependents before dependencies
ament_target_dependencies(${PROJECT_NAME}
Expand Down Expand Up @@ -127,7 +123,6 @@ ament_export_targets(${PROJECT_NAME})

# specific order: dependents before dependencies
ament_export_dependencies(ament_cmake)
ament_export_dependencies(rosidl_dynamic_typesupport) # TODO(methylDragon): TEMPORARY! REMOVE EVENTUALLY
ament_export_dependencies(rcl_interfaces)
ament_export_dependencies(rcl_logging_interface)
ament_export_dependencies(rcl_yaml_param_parser)
Expand All @@ -138,6 +133,7 @@ ament_export_dependencies(${RCL_LOGGING_IMPL})
ament_export_dependencies(rosidl_runtime_c)
ament_export_dependencies(service_msgs)
ament_export_dependencies(tracetools)
ament_export_dependencies(type_description_interfaces)


if(BUILD_TESTING)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,22 +15,21 @@
#ifndef RCL_DYNAMIC_TYPESUPPORT_C__MESSAGE_INTROSPECTION_H_
#define RCL_DYNAMIC_TYPESUPPORT_C__MESSAGE_INTROSPECTION_H_

#include "rosidl_dynamic_typesupport/description.h"

#include "rosidl_runtime_c/message_type_support_struct.h"
#include "rcl/macros.h"
#include "rcl/types.h"
#include "rcl/visibility_control.h"

#include <rosidl_runtime_c/type_description/type_description__struct.h> // TEMPORARY
// #include <type_description_interfaces/msg/type_description.h> // Use this when conversion is ok

#ifdef __cplusplus
extern "C" {
#endif


// TODO(methylDragon): !!! Document that the user is in charge of the lifetime of the struct...
// TODO(methylDragon): ...
// NOTE(methylDragon): My use of the rosidl_dynamic_typesupport::type_description_t struct is for
// convenience only. We should be passing the TypeDescription message

/// If the user passes a NULL desc, it is deferred instead, the middleware is responsibile for
/// populating the fields on type discovery!!!
Expand All @@ -39,7 +38,8 @@ RCL_WARN_UNUSED
rosidl_message_type_support_t *
rcl_get_dynamic_message_typesupport_handle(
const char * serialization_lib_name,
type_description_t * desc);
// TODO(methylDragon): This should be type_description_interfaces__msg__TypeDescription
rosidl_runtime_c__type_description__TypeDescription * desc);

/// Finalize a rosidl_message_type_support_t obtained with
/// rcl_get_dynamic_message_typesupport_handle
Expand Down
8 changes: 4 additions & 4 deletions rcl/include/rcl/subscription.h
Original file line number Diff line number Diff line change
Expand Up @@ -601,12 +601,12 @@ rcl_take_serialized_message(
rmw_message_info_t * message_info,
rmw_subscription_allocation_t * allocation);

/// Take a runtime type message from a topic using a rcl subscription.
/// Take a dynamic type message from a topic using a rcl subscription.
/**
* In contrast to rcl_take(), this function takes a runtime type message with dynamic data taken
* In contrast to rcl_take(), this function takes a dynamic type message with dynamic data taken
* directly from the middleware.
* It is the job of the caller to ensure that the type associated with the subscription
* matches, and that the subscription uses the runtime type rosidl_message_type_support_t.
* matches, and that the subscription uses the dynamic type rosidl_message_type_support_t.
*
* Apart from the differences above, this function behaves like rcl_take().
*
Expand All @@ -619,7 +619,7 @@ rcl_take_serialized_message(
* Lock-Free | Yes
*
* \param[in] subscription the handle to the subscription from which to take
* \param[inout] dynamic_message pointer to a (pre-allocated) runtime type message.
* \param[inout] dynamic_message pointer to a (pre-allocated) dynamic type message.
* \param[out] message_info rmw struct which contains meta-data for the message
* \param[in] allocation structure pointer used for memory preallocation (may be NULL)
* \return #RCL_RET_OK if the message was taken, or
Expand Down
2 changes: 1 addition & 1 deletion rcl/package.xml
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@

<build_export_depend>rmw</build_export_depend>

<depend>rosidl_dynamic_typesupport</depend> <!-- TODO(methylDragon): TEMPORARY. Remove eventually -->
<depend>rcl_interfaces</depend>
<depend>rcl_logging_interface</depend>
<depend>rcl_logging_spdlog</depend> <!-- the default logging impl -->
Expand All @@ -29,6 +28,7 @@
<depend>rosidl_runtime_c</depend>
<depend>service_msgs</depend>
<depend>tracetools</depend>
<depend>type_description_interfaces</depend>

<test_depend>ament_cmake_gtest</test_depend>
<test_depend>ament_lint_auto</test_depend>
Expand Down
15 changes: 8 additions & 7 deletions rcl/src/rcl/rcl_dynamic_typesupport_c/message_introspection.c
Original file line number Diff line number Diff line change
Expand Up @@ -17,33 +17,34 @@ extern "C"
{
#endif

#include "rosidl_dynamic_typesupport/description.h"
#include "rmw/dynamic_typesupport.h"

#include "rcl/types.h"
#include "rcl/error_handling.h"
#include "rcl/rcl_dynamic_typesupport_c/identifier.h"
#include "rcl/rcl_dynamic_typesupport_c/message_introspection.h"

#include "rcutils/logging_macros.h"
#include "rosidl_runtime_c/message_type_support_struct.h"
#include <rcutils/logging_macros.h>
#include <rosidl_runtime_c/message_type_support_struct.h>
#include <rosidl_runtime_c/type_description/type_description__struct.h> // TEMPORARY
// #include <type_description_interfaces/msg/type_description.h> // Use this when conversion is ok


// NOTE(methylDragon): My use of the rosidl_dynamic_typesupport::type_description_t struct is for
// convenience only. We should be passing the TypeDescription message

/// Create a rosidl_message_type_support_t from a TypeDescription message
RCL_PUBLIC
RCL_WARN_UNUSED
rosidl_message_type_support_t *
rcl_get_dynamic_message_typesupport_handle(
const char * serialization_lib_name,
type_description_t * desc)
// TODO(methylDragon): This should be type_description_interfaces__msg__TypeDescription
rosidl_runtime_c__type_description__TypeDescription * desc)
{
return rmw_get_dynamic_message_typesupport_handle(
rmw_get_serialization_support(serialization_lib_name),
rmw_feature_supported(RMW_MIDDLEWARE_SUPPORTS_TYPE_DISCOVERY),
rmw_feature_supported(RMW_MIDDLEWARE_CAN_TAKE_DYNAMIC_DATA),
// TODO(methylDragon): We need to type_description_interfaces__msg__TypeDescription to
// rosidl_runtime_c__type_description__TypeDescription here
desc
);
}
Expand Down
4 changes: 2 additions & 2 deletions rcl/src/rcl/subscription.c
Original file line number Diff line number Diff line change
Expand Up @@ -630,7 +630,7 @@ rcl_take_dynamic_message(
rmw_subscription_allocation_t * allocation
)
{
RCUTILS_LOG_DEBUG_NAMED(ROS_PACKAGE_NAME, "Subscription taking runtime type message");
RCUTILS_LOG_DEBUG_NAMED(ROS_PACKAGE_NAME, "Subscription taking dynamic message");
if (!rcl_subscription_is_valid(subscription)) {
return RCL_RET_SUBSCRIPTION_INVALID; // error already set
}
Expand All @@ -648,7 +648,7 @@ rcl_take_dynamic_message(
return rcl_convert_rmw_ret_to_rcl_ret(ret);
}
RCUTILS_LOG_DEBUG_NAMED(
ROS_PACKAGE_NAME, "Subscription runtime type take succeeded: %s", taken ? "true" : "false");
ROS_PACKAGE_NAME, "Subscription dynamic take succeeded: %s", taken ? "true" : "false");
if (!taken) {
return RCL_RET_SUBSCRIPTION_TAKE_FAILED;
}
Expand Down

0 comments on commit 8d01f92

Please sign in to comment.