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 #92

Merged
merged 9 commits into from
Feb 2, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
10 changes: 10 additions & 0 deletions rosidl_typesupport_fastrtps_c/resource/msg__type_support_c.cpp.em
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,9 @@ from rosidl_parser.definition import AbstractWString
from rosidl_parser.definition import ACTION_FEEDBACK_SUFFIX
from rosidl_parser.definition import ACTION_GOAL_SUFFIX
from rosidl_parser.definition import ACTION_RESULT_SUFFIX
from rosidl_parser.definition import SERVICE_REQUEST_MESSAGE_SUFFIX
from rosidl_parser.definition import SERVICE_RESPONSE_MESSAGE_SUFFIX
from rosidl_parser.definition import SERVICE_EVENT_MESSAGE_SUFFIX
from rosidl_parser.definition import Array
from rosidl_parser.definition import BasicType
from rosidl_parser.definition import BoundedSequence
Expand All @@ -18,6 +21,7 @@ include_parts = [package_name] + list(interface_path.parents[0].parts) + [
'detail', convert_camel_case_to_lower_case_underscore(interface_path.stem)]
include_base = '/'.join(include_parts)


header_files = [
'cassert',
'limits',
Expand Down Expand Up @@ -84,6 +88,12 @@ for member in message.structure.members:
keys.add('rosidl_runtime_c/u16string.h')
keys.add('rosidl_runtime_c/u16string_functions.h')
elif isinstance(type_, NamespacedType):
import sys
if (
type_.name.endswith(SERVICE_REQUEST_MESSAGE_SUFFIX) or
type_.name.endswith(SERVICE_RESPONSE_MESSAGE_SUFFIX)
):
continue
if (
type_.name.endswith(ACTION_GOAL_SUFFIX) or
type_.name.endswith(ACTION_RESULT_SUFFIX) or
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,13 @@ TEMPLATE(
include_directives=include_directives)
}@

@{
TEMPLATE(
'msg__rosidl_typesupport_fastrtps_c.h.em',
package_name=package_name, interface_path=interface_path, message=service.event_message,
include_directives=include_directives)
}@

@{
header_files = [
'rosidl_runtime_c/service_type_support_struct.h',
Expand Down
16 changes: 16 additions & 0 deletions rosidl_typesupport_fastrtps_c/resource/srv__type_support_c.cpp.em
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,13 @@ TEMPLATE(
include_directives=include_directives)
}@

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

@{
from rosidl_pycommon import convert_camel_case_to_lower_case_underscore

Expand Down Expand Up @@ -55,6 +62,15 @@ static rosidl_service_type_support_t @(service.namespaced_type.name)__handle = {
rosidl_typesupport_fastrtps_c__identifier,
&@(service.namespaced_type.name)__callbacks,
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__type_support
};

const rosidl_service_type_support_t *
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,13 @@ TEMPLATE(
include_directives=include_directives)
}@

@{
TEMPLATE(
'msg__rosidl_typesupport_fastrtps_cpp.hpp.em',
package_name=package_name, interface_path=interface_path, message=service.event_message,
include_directives=include_directives)
}@

@{
header_files = [
'rmw/types.h',
Expand Down
28 changes: 25 additions & 3 deletions rosidl_typesupport_fastrtps_cpp/resource/srv__type_support.cpp.em
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
@# Included from rosidl_typesupport_fastrtps_cpp/resource/idl__type_support.cpp.em
@{
from rosidl_pycommon import convert_camel_case_to_lower_case_underscore
from rosidl_parser.definition import SERVICE_REQUEST_MESSAGE_SUFFIX
from rosidl_parser.definition import SERVICE_RESPONSE_MESSAGE_SUFFIX

include_parts = [package_name] + list(interface_path.parents[0].parts) + [
'detail', convert_camel_case_to_lower_case_underscore(interface_path.stem)]
Expand All @@ -20,9 +22,17 @@ TEMPLATE(
include_directives=include_directives)
}@

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

@{
header_files = [
'rmw/error_handling.h',
'rosidl_typesupport_cpp/service_type_support.hpp',
'rosidl_typesupport_fastrtps_cpp/identifier.hpp',
'rosidl_typesupport_fastrtps_cpp/service_type_support.h',
'rosidl_typesupport_fastrtps_cpp/service_type_support_decl.hpp',
Expand All @@ -49,16 +59,28 @@ namespace typesupport_fastrtps_cpp
static service_type_support_callbacks_t _@(service.namespaced_type.name)__callbacks = {
"@('::'.join([package_name] + list(interface_path.parents[0].parts)))",
"@(service.namespaced_type.name)",
ROSIDL_TYPESUPPORT_INTERFACE__MESSAGE_SYMBOL_NAME(rosidl_typesupport_fastrtps_cpp, @(', '.join([package_name] + list(interface_path.parents[0].parts))), @(service.namespaced_type.name)_Request)(),
ROSIDL_TYPESUPPORT_INTERFACE__MESSAGE_SYMBOL_NAME(rosidl_typesupport_fastrtps_cpp, @(', '.join([package_name] + list(interface_path.parents[0].parts))), @(service.namespaced_type.name)_Response)(),
ROSIDL_TYPESUPPORT_INTERFACE__MESSAGE_SYMBOL_NAME(rosidl_typesupport_fastrtps_cpp, @(', '.join([package_name] + list(interface_path.parents[0].parts))), @(service.namespaced_type.name + SERVICE_REQUEST_MESSAGE_SUFFIX))(),
ROSIDL_TYPESUPPORT_INTERFACE__MESSAGE_SYMBOL_NAME(rosidl_typesupport_fastrtps_cpp, @(', '.join([package_name] + list(interface_path.parents[0].parts))), @(service.namespaced_type.name + SERVICE_RESPONSE_MESSAGE_SUFFIX))(),
};

static rosidl_service_type_support_t _@(service.namespaced_type.name)__handle = {
#ifdef __cplusplus
extern "C"
{
#endif

static const rosidl_service_type_support_t _@(service.namespaced_type.name)__handle{
rosidl_typesupport_fastrtps_cpp::typesupport_identifier,
&_@(service.namespaced_type.name)__callbacks,
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_fastrtps_cpp::get_message_type_support_handle<@('::'.join([package_name, *interface_path.parents[0].parts, service.namespaced_type.name]))_Event>(),
};

#ifdef __cplusplus
}
#endif

} // namespace typesupport_fastrtps_cpp
@[ for ns in reversed(service.namespaced_type.namespaces)]@

Expand Down