Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Service introspection #127

Merged
merged 36 commits into from
Feb 2, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
36 commits
Select commit Hold shift + click to select a range
b45bf00
preliminary c ts impl for service introspection msg gen
ihasdapie Jul 28, 2022
0e9197e
preliminary cpp ts impl for service introspection msg gen
ihasdapie Jul 28, 2022
5a47f94
use event_msg->info directly
ihasdapie Aug 8, 2022
659fa71
enable/disable event msg payload
ihasdapie Aug 8, 2022
acd7ae5
remove debug code
ihasdapie Aug 10, 2022
200fa79
use suffix from rosidl_parser.definition
ihasdapie Aug 10, 2022
c481c6d
const void* service introspection message create handle
ihasdapie Aug 24, 2022
3137d0f
update tests to reflect rosidl_service_type_support_t
ihasdapie Aug 24, 2022
a4d426a
fix tests with new service typesupport definition
ihasdapie Aug 27, 2022
3e5f053
create rosidl_typesupport_tests package
ihasdapie Aug 27, 2022
4a8c54c
rename service_introspection_create/destroy handles to event_message …
ihasdapie Sep 3, 2022
fee9c5d
remove zero_allocate calls
ihasdapie Sep 3, 2022
709b831
remove ifdef cpp
ihasdapie Sep 3, 2022
dc3410b
remove unnecessary rcutils_reset_error
ihasdapie Sep 3, 2022
b67d241
fix tests
ihasdapie Sep 3, 2022
ac0a4f3
Fix test + more comprehensive error checking
jacobperron Sep 30, 2022
6f79f4f
Lint
jacobperron Sep 30, 2022
7180857
Cleanup package.xml and CMakeLists.txt
jacobperron Sep 30, 2022
7cdf466
Update TODO
jacobperron Sep 30, 2022
e301055
Lint and fix warning
jacobperron Oct 12, 2022
5a6e355
Remove completed TODO
ivanpauno Nov 11, 2022
54e65f3
Use create/destroy event function generated in rosidl_generator_c
ivanpauno Nov 15, 2022
b6863bb
Remove unneeded changes
ivanpauno Nov 15, 2022
c85bbba
Use common service event create/destroy function in cpp
ivanpauno Nov 15, 2022
109f9b3
fix
ivanpauno Nov 17, 2022
1e90346
fixup test
ivanpauno Dec 6, 2022
d9e1678
please linters
ivanpauno Dec 6, 2022
863030c
Add missing initializers
ivanpauno Dec 13, 2022
2a44577
Don't use designated initializers in c++
ivanpauno Dec 13, 2022
7fe5d18
fix
ivanpauno Dec 14, 2022
7389d83
please uncrustify
ivanpauno Dec 14, 2022
27bbb09
service typesupport struct field renaming
ivanpauno Dec 23, 2022
5190714
Complete testing
ivanpauno Dec 23, 2022
c71797f
Fix windows CI
ivanpauno Jan 2, 2023
55745b0
Switch to using the client_gid.
clalancette Jan 25, 2023
c3c80ad
Small fixes to fix tests.
clalancette Jan 25, 2023
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions rosidl_typesupport_c/resource/msg__type_support.cpp.em
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ header_files = [
'rosidl_runtime_c/message_type_support_struct.h',
include_base + '__struct.h',
include_base + '__type_support.h',
include_base + '__functions.h',
]
if len(type_supports) != 1:
header_files += [
Expand Down
20 changes: 19 additions & 1 deletion rosidl_typesupport_c/resource/srv__type_support.cpp.em
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,14 @@ TEMPLATE(
type_supports=type_supports)
}@

@{
TEMPLATE(
'msg__type_support.cpp.em',
package_name=package_name, interface_path=interface_path,
message=service.event_message, include_directives=include_directives,
type_supports=type_supports)
}@

@{
from rosidl_pycommon import convert_camel_case_to_lower_case_underscore
include_parts = [package_name] + list(interface_path.parents[0].parts) + [
Expand All @@ -33,6 +41,8 @@ if len(type_supports) != 1:
'rosidl_typesupport_c/type_support_map.h',
]
header_files.append('rosidl_typesupport_interface/macros.h')
header_files.append('service_msgs/msg/service_event_info.h')
header_files.append('builtin_interfaces/msg/time.h')
}@
@[for header_file in header_files]@
@[ if header_file in include_directives]@
Expand All @@ -53,7 +63,6 @@ namespace @(ns)

namespace rosidl_typesupport_c
{

typedef struct _@(service.namespaced_type.name)_type_support_ids_t
{
const char * typesupport_identifier[@(len(type_supports))];
Expand Down Expand Up @@ -109,6 +118,15 @@ static const rosidl_service_type_support_t @(service.namespaced_type.name)_servi
rosidl_typesupport_c__typesupport_identifier,
reinterpret_cast<const type_support_map_t *>(&_@(service.namespaced_type.name)_service_typesupport_map),
rosidl_typesupport_c__get_service_typesupport_handle_function,
ROSIDL_TYPESUPPORT_INTERFACE__SERVICE_CREATE_EVENT_MESSAGE_SYMBOL_NAME(
rosidl_typesupport_c,
@(',\n '.join(service.namespaced_type.namespaced_name()))
),
ROSIDL_TYPESUPPORT_INTERFACE__SERVICE_DESTROY_EVENT_MESSAGE_SYMBOL_NAME(
rosidl_typesupport_c,
@(',\n '.join(service.namespaced_type.namespaced_name()))
),
&@(service.namespaced_type.name)_Event_message_type_support_handle
};

} // namespace rosidl_typesupport_c
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ rosidl_message_type_support_t get_rosidl_message_type_support(const char * ident

rosidl_service_type_support_t get_rosidl_service_type_support(const char * identifier)
{
return {identifier, nullptr, nullptr};
return {identifier, nullptr, nullptr, nullptr, nullptr, nullptr};
}

type_support_map_t get_typesupport_map(void ** library_array)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ constexpr const char * symbols[map_size] = {

rosidl_service_type_support_t get_rosidl_service_type_support(const char * identifier)
{
return {identifier, nullptr, nullptr};
return {identifier, nullptr, nullptr, nullptr, nullptr, nullptr};
}

type_support_map_t get_typesupport_map(void ** library_array)
Expand Down
2 changes: 1 addition & 1 deletion rosidl_typesupport_c/test/test_type_support.c
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ static const rosidl_message_type_support_t message_type_support = {
};

static const rosidl_service_type_support_t service_type_support = {
0, 0, 0
0, 0, 0, 0, 0, 0
};

const rosidl_message_type_support_t * test_message_type_support() {return &message_type_support;}
Expand Down
14 changes: 12 additions & 2 deletions rosidl_typesupport_cpp/resource/srv__type_support.cpp.em
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,14 @@ TEMPLATE(
type_supports=type_supports)
}@

@{
TEMPLATE(
'msg__type_support.cpp.em',
package_name=package_name, interface_path=interface_path,
message=service.event_message, include_directives=include_directives,
type_supports=type_supports)
}@

@{
from rosidl_pycommon import convert_camel_case_to_lower_case_underscore
include_parts = [package_name] + list(interface_path.parents[0].parts) + [
Expand All @@ -24,11 +32,11 @@ include_base = '/'.join(include_parts)
header_files = [
'cstddef',
'rosidl_runtime_c/service_type_support_struct.h',
'rosidl_typesupport_cpp/service_type_support.hpp',
include_base + '__struct.hpp',
]
if len(type_supports) != 1:
header_files.append('rosidl_typesupport_cpp/identifier.hpp')
header_files.append('rosidl_typesupport_cpp/service_type_support.hpp')
if len(type_supports) != 1:
header_files += [
'rosidl_typesupport_c/type_support_map.h',
Expand Down Expand Up @@ -76,7 +84,6 @@ typedef struct _@(service.namespaced_type.name)_type_support_symbol_names_t
{
const char * symbol_name[@(len(type_supports))];
} _@(service.namespaced_type.name)_type_support_symbol_names_t;

#define STRINGIFY_(s) #s
#define STRINGIFY(s) STRINGIFY_(s)

Expand Down Expand Up @@ -113,6 +120,9 @@ static const rosidl_service_type_support_t @(service.namespaced_type.name)_servi
::rosidl_typesupport_cpp::typesupport_identifier,
reinterpret_cast<const type_support_map_t *>(&_@(service.namespaced_type.name)_service_typesupport_map),
::rosidl_typesupport_cpp::get_service_typesupport_handle_function,
&::rosidl_typesupport_cpp::service_create_event_message<@('::'.join([package_name, *interface_path.parents[0].parts, service.namespaced_type.name]))>,
&::rosidl_typesupport_cpp::service_destroy_event_message<@('::'.join([package_name, *interface_path.parents[0].parts, service.namespaced_type.name]))>,
::rosidl_typesupport_cpp::get_message_type_support_handle<@('::'.join([package_name, *interface_path.parents[0].parts, service.namespaced_type.name]))_Event>(),
};

} // namespace rosidl_typesupport_cpp
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ rosidl_message_type_support_t get_rosidl_message_type_support(const char * ident

rosidl_service_type_support_t get_rosidl_service_type_support(const char * identifier)
{
return {identifier, nullptr, nullptr};
return {identifier, nullptr, nullptr, nullptr, nullptr, nullptr};
}

type_support_map_t get_typesupport_map(void ** library_array)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ constexpr const char * symbols[map_size] = {

rosidl_service_type_support_t get_rosidl_service_type_support(const char * identifier)
{
return {identifier, nullptr, nullptr};
return {identifier, nullptr, nullptr, nullptr, nullptr, nullptr};
}

type_support_map_t get_typesupport_map(void ** library_array)
Expand Down
4 changes: 2 additions & 2 deletions rosidl_typesupport_cpp/test/test_type_support.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -35,11 +35,11 @@ const rosidl_service_type_support_t * test_service_type_support();
#endif

static const rosidl_message_type_support_t message_type_support = {
0, 0, 0
nullptr, nullptr, nullptr
};

static const rosidl_service_type_support_t service_type_support = {
0, 0, 0
nullptr, nullptr, nullptr, nullptr, nullptr, nullptr
};

const rosidl_message_type_support_t * test_message_type_support() {return &message_type_support;}
Expand Down
43 changes: 43 additions & 0 deletions rosidl_typesupport_tests/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
cmake_minimum_required(VERSION 3.8)
project(rosidl_typesupport_tests)

if(CMAKE_COMPILER_IS_GNUCXX OR CMAKE_CXX_COMPILER_ID MATCHES "Clang")
add_compile_options(-Wall -Wextra -Wpedantic)
endif()

find_package(ament_cmake REQUIRED)

if(BUILD_TESTING)
find_package(ament_lint_auto REQUIRED)
ament_lint_auto_find_test_dependencies()
find_package(rosidl_cmake REQUIRED)
find_package(ament_cmake_gtest REQUIRED)
find_package(test_interface_files REQUIRED)
find_package(rcutils REQUIRED)

rosidl_generate_interfaces(${PROJECT_NAME}
${test_interface_files_MSG_FILES}
${test_interface_files_SRV_FILES}
${test_interface_files_ACTION_FILES}
SKIP_INSTALL
)

rosidl_get_typesupport_target(cpp_typesupport_target ${PROJECT_NAME} "rosidl_typesupport_cpp")
rosidl_get_typesupport_target(c_typesupport_target ${PROJECT_NAME} "rosidl_typesupport_c")

ament_add_gtest(test_service_typesupport_cpp
test/rosidl_typesupport_cpp/test_service_typesupport.cpp
)
target_link_libraries(test_service_typesupport_cpp
"${cpp_typesupport_target}"
)

ament_add_gtest(test_service_typesupport_c
test/rosidl_typesupport_c/test_service_typesupport.cpp
)
target_link_libraries(test_service_typesupport_c
"${c_typesupport_target}"
)
endif()

ament_package()
27 changes: 27 additions & 0 deletions rosidl_typesupport_tests/package.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
<?xml version="1.0"?>
<?xml-model href="http://download.ros.org/schema/package_format3.xsd" schematypens="http://www.w3.org/2001/XMLSchema"?>
<package format="3">
<name>rosidl_typesupport_tests</name>
<version>2.2.0</version>
<description>Test rosidl_typesupport_c and rosidl_typesupport_cpp packages</description>
<maintainer email="[email protected]">Jacob Perron</maintainer>
<license>Apache License 2.0</license>
<author email="[email protected]">Brian Chen</author>

<buildtool_depend>ament_cmake</buildtool_depend>

<test_depend>ament_lint_auto</test_depend>
<test_depend>ament_lint_common</test_depend>
<test_depend>ament_cmake_gtest</test_depend>
<test_depend>rcutils</test_depend>
<test_depend>rosidl_cmake</test_depend>
<test_depend>rosidl_typesupport_c</test_depend>
<test_depend>rosidl_typesupport_cpp</test_depend>
<test_depend>test_interface_files</test_depend>
<test_depend>service_msgs</test_depend>
<test_depend>action_msgs</test_depend>

<export>
<build_type>ament_cmake</build_type>
</export>
</package>
Loading