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] generate service_event messages #700

Merged
merged 54 commits into from
Feb 2, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
54 commits
Select commit Hold shift + click to select a range
fe1f905
add service event message
ihasdapie Jul 21, 2022
0b85d8c
fix service introspection message compilation issues
ihasdapie Jul 25, 2022
1e2ba8a
Add service_msgs to rosidl_cmake
ihasdapie Jul 28, 2022
45c078f
event_messages for action services
ihasdapie Jul 28, 2022
0f43042
codegen a sequence extending fn
ihasdapie Jul 28, 2022
41945b8
embed message types into generated service_event msg
ihasdapie Jul 28, 2022
b7d9b99
add handles to creating/finalizing introspection messages to service_…
ihasdapie Jul 28, 2022
a076ffe
remote __extendn msg__function
ihasdapie Aug 8, 2022
d2d2da9
introspection ts for service event messages
ihasdapie Aug 8, 2022
90e498a
turn on/off enabling message payload
ihasdapie Aug 8, 2022
a8c1441
add service_msgs to action_msgs cmake macro
ihasdapie Aug 8, 2022
610bbf1
Move common Python functions into new package
jacobperron Aug 1, 2022
b7db739
Lint
jacobperron Aug 2, 2022
dccf0a1
fix find_package-ing for packages defining services and actions
ihasdapie Aug 9, 2022
957f0a9
use postfixes from rosidl_parser.definition and add some docs
ihasdapie Aug 10, 2022
9743d97
missing bracket
ihasdapie Aug 10, 2022
a4925f2
event_messages for action services
ihasdapie Jul 28, 2022
f682055
codegen a sequence extending fn
ihasdapie Jul 28, 2022
4d47424
remote __extendn msg__function
ihasdapie Aug 8, 2022
ba1ec51
introspection ts for service event messages
ihasdapie Aug 8, 2022
42dd4d2
turn on/off enabling message payload
ihasdapie Aug 8, 2022
3d5537b
add service_msgs to action_msgs cmake macro
ihasdapie Aug 8, 2022
fb9c2bf
fix find_package-ing for packages defining services and actions
ihasdapie Aug 9, 2022
1a560be
use postfixes from rosidl_parser.definition and add some docs
ihasdapie Aug 10, 2022
bbed8ad
missing bracket
ihasdapie Aug 10, 2022
373cebe
add service_msgs <test_depend> tag where needed
ihasdapie Aug 24, 2022
171caee
make service_introspection_message_create_handle take const void*
ihasdapie Aug 24, 2022
62f1f9e
add parser test
ihasdapie Aug 24, 2022
ca9ec5f
streamline rosidl_generate_interfaces cmake logic
ihasdapie Aug 24, 2022
9a89ee5
add some generator tests
ihasdapie Aug 27, 2022
5fdfded
rename from introspection_message handles to event_message handles
ihasdapie Sep 3, 2022
820712f
Remove duplicate template instances
jacobperron Sep 29, 2022
d535a6e
Refactor action/service loop
jacobperron Sep 30, 2022
ad1bd4a
Use last directory in path to identify actions and services
jacobperron Oct 3, 2022
e0d75d1
Do not rely on service_msgs_FOUND
jacobperron Oct 3, 2022
96f3223
Lint
jacobperron Oct 12, 2022
220ff59
Fix test
jacobperron Oct 12, 2022
00b5433
Modify recursive includes in rosidl_generator_c/rosidl_generator_cpp
ivanpauno Nov 11, 2022
68ff7b5
add service event create/destroy function for typesupport introspecti…
ivanpauno Nov 11, 2022
b3be446
Generate only one implementation of functions per generator
ivanpauno Nov 15, 2022
99607ee
Create only one create/destroy service event function for all cpp typ…
ivanpauno Nov 15, 2022
81e768f
Remove enable_message_payload from create service event message signa…
ivanpauno Nov 16, 2022
0649944
fixes
ivanpauno Nov 17, 2022
ec537d7
Add missing includes
ivanpauno Nov 17, 2022
11e4f8b
Include name
ivanpauno Nov 17, 2022
d5f40ef
Fix
ivanpauno Nov 18, 2022
785c3a1
please linters
ivanpauno Dec 6, 2022
84299e5
Avoid signed unsigned comparison
ivanpauno Dec 13, 2022
e842886
Complete implementation
ivanpauno Dec 14, 2022
9378583
Fix rosidl_runtime_cpp linters
ivanpauno Dec 14, 2022
b3edf00
Address peer review comments
ivanpauno Dec 23, 2022
a3712ca
Fixes after adding tests for rosidl_typesupport_c in rosidl_typesuppo…
ivanpauno Dec 23, 2022
00b3784
Remove debug message
ivanpauno Dec 23, 2022
01beada
Switch to a client_gid.
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_adapter/rosidl_adapter/parser.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@
SERVICE_REQUEST_RESPONSE_SEPARATOR = '---'
SERVICE_REQUEST_MESSAGE_SUFFIX = '_Request'
SERVICE_RESPONSE_MESSAGE_SUFFIX = '_Response'
SERVICE_EVENT_MESSAGE_SUFFIX = '_Event'

ACTION_REQUEST_RESPONSE_SEPARATOR = '---'
ACTION_GOAL_SUFFIX = '_Goal'
Expand Down
32 changes: 30 additions & 2 deletions rosidl_cmake/cmake/rosidl_generate_interfaces.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -139,21 +139,49 @@ macro(rosidl_generate_interfaces target)
# afterwards all remaining interface files are .idl files
list(APPEND _idl_tuples ${_idl_adapter_tuples})

# to generate action interfaces, we need to depend on "action_msgs"
# Check for any action or service interfaces
# Which have implicit dependencies that need to be found
foreach(_tuple ${_interface_tuples})
# We use the parent directory name to identify if the interface is an action or service
string(REGEX REPLACE ".*:([^:]*)$" "\\1" _tuple_file "${_tuple}")
get_filename_component(_parent_dir "${_tuple_file}" DIRECTORY)
ivanpauno marked this conversation as resolved.
Show resolved Hide resolved
get_filename_component(_parent_dir ${_parent_dir} NAME)

if("${_parent_dir}" STREQUAL "action")
# Actions depend on the packages service_msgs and action_msgs
find_package(service_msgs QUIET)
if(NOT ${service_msgs_FOUND})
message(FATAL_ERROR
"Unable to generate action interface for '${_tuple_file}'. "
"In order to generate action interfaces you must add a depend tag "
"for 'service_msgs' in your package.xml.")
endif()
ament_export_dependencies(service_msgs)
list_append_unique(_ARG_DEPENDENCIES "service_msgs")
ivanpauno marked this conversation as resolved.
Show resolved Hide resolved
find_package(action_msgs QUIET)
if(NOT ${action_msgs_FOUND})
message(FATAL_ERROR
"Unable to generate action interface for '${_tuple_file}'. "
"In order to generate action interfaces you must add a depend tag "
"for 'action_msgs' in your package.xml.")
endif()
list_append_unique(_ARG_DEPENDENCIES "action_msgs")
ament_export_dependencies(action_msgs)
list_append_unique(_ARG_DEPENDENCIES "action_msgs")

# It is safe to break out of the loop since services only depend on service_msgs
# Which has already been found above
break()
elseif("${_parent_dir}" STREQUAL "srv")
# Services depend on service_msgs
find_package(service_msgs QUIET)
if(NOT ${service_msgs_FOUND})
message(FATAL_ERROR
"Unable to generate service interface for '${_tuple_file}'. "
"In order to generate service interfaces you must add a depend tag "
"for 'service_msgs' in your package.xml.")
endif()
ament_export_dependencies(service_msgs)
list_append_unique(_ARG_DEPENDENCIES "service_msgs")
endif()
endforeach()

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ foreach(_abs_idl_file ${rosidl_generate_interfaces_ABS_IDL_FILES})
)
list(APPEND _generated_sources
"${_output_path}/${_parent_folder}/detail/${_header_name}__functions.c"
"${_output_path}/${_parent_folder}/detail/${_header_name}__type_support.c"
)
endforeach()

Expand All @@ -52,15 +53,18 @@ set(target_dependencies
"${rosidl_generator_c_BIN}"
${rosidl_generator_c_GENERATOR_FILES}
"${rosidl_generator_c_TEMPLATE_DIR}/action__type_support.h.em"
"${rosidl_generator_c_TEMPLATE_DIR}/action__type_support.c.em"
"${rosidl_generator_c_TEMPLATE_DIR}/idl.h.em"
"${rosidl_generator_c_TEMPLATE_DIR}/idl__functions.c.em"
"${rosidl_generator_c_TEMPLATE_DIR}/idl__functions.h.em"
"${rosidl_generator_c_TEMPLATE_DIR}/idl__struct.h.em"
"${rosidl_generator_c_TEMPLATE_DIR}/idl__type_support.c.em"
"${rosidl_generator_c_TEMPLATE_DIR}/idl__type_support.h.em"
"${rosidl_generator_c_TEMPLATE_DIR}/msg__functions.c.em"
"${rosidl_generator_c_TEMPLATE_DIR}/msg__functions.h.em"
"${rosidl_generator_c_TEMPLATE_DIR}/msg__struct.h.em"
"${rosidl_generator_c_TEMPLATE_DIR}/msg__type_support.h.em"
"${rosidl_generator_c_TEMPLATE_DIR}/srv__type_support.c.em"
"${rosidl_generator_c_TEMPLATE_DIR}/srv__type_support.h.em"
${rosidl_generate_interfaces_ABS_IDL_FILES}
${_dependency_files})
Expand Down
14 changes: 14 additions & 0 deletions rosidl_generator_c/resource/action__type_support.c.em
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
@# Included from rosidl_generator_c/resource/idl__type_support.c.em
@{
TEMPLATE(
'srv__type_support.c.em',
package_name=package_name, service=action.send_goal_service,
interface_path=interface_path, include_directives=include_directives)
}@

@{
TEMPLATE(
'srv__type_support.c.em',
package_name=package_name, service=action.get_result_service,
interface_path=interface_path, include_directives=include_directives)
}@
21 changes: 21 additions & 0 deletions rosidl_generator_c/resource/idl__functions.c.em
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,13 @@ TEMPLATE(
package_name=package_name, interface_path=interface_path,
message=service.response_message, include_directives=include_directives)
}@

@{
TEMPLATE(
'msg__functions.c.em',
package_name=package_name, interface_path=interface_path,
message=service.event_message, include_directives=include_directives)
}@
@[end for]@
@
@#######################################################################
Expand Down Expand Up @@ -109,6 +116,13 @@ TEMPLATE(
message=action.send_goal_service.response_message, include_directives=include_directives)
}@

@{
TEMPLATE(
'msg__functions.c.em',
package_name=package_name, interface_path=interface_path,
message=action.send_goal_service.event_message, include_directives=include_directives)
}@

@{
TEMPLATE(
'msg__functions.c.em',
Expand All @@ -123,6 +137,13 @@ TEMPLATE(
message=action.get_result_service.response_message, include_directives=include_directives)
}@

@{
TEMPLATE(
'msg__functions.c.em',
package_name=package_name, interface_path=interface_path,
message=action.get_result_service.event_message, include_directives=include_directives)
}@

@{
TEMPLATE(
'msg__functions.c.em',
Expand Down
20 changes: 20 additions & 0 deletions rosidl_generator_c/resource/idl__functions.h.em
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,12 @@ TEMPLATE(
message=service.response_message)
}@

@{
TEMPLATE(
'msg__functions.h.em',
package_name=package_name, interface_path=interface_path,
message=service.event_message)
}@
@[end for]@
@
@#######################################################################
Expand Down Expand Up @@ -116,6 +122,13 @@ TEMPLATE(
message=action.send_goal_service.response_message)
}@

@{
TEMPLATE(
'msg__functions.h.em',
package_name=package_name, interface_path=interface_path,
message=action.send_goal_service.event_message)
}@

@{
TEMPLATE(
'msg__functions.h.em',
Expand All @@ -130,6 +143,13 @@ TEMPLATE(
message=action.get_result_service.response_message)
}@

@{
TEMPLATE(
'msg__functions.h.em',
package_name=package_name, interface_path=interface_path,
message=action.get_result_service.event_message)
}@

@{
TEMPLATE(
'msg__functions.h.em',
Expand Down
21 changes: 21 additions & 0 deletions rosidl_generator_c/resource/idl__struct.h.em
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,13 @@ TEMPLATE(
message=service.response_message, include_directives=include_directives)
}@

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

@[end for]@
@
@#######################################################################
Expand Down Expand Up @@ -113,6 +120,13 @@ TEMPLATE(
message=action.send_goal_service.response_message, include_directives=include_directives)
}@

@{
TEMPLATE(
'msg__struct.h.em',
package_name=package_name, interface_path=interface_path,
message=action.send_goal_service.event_message, include_directives=include_directives)
}@

@{
TEMPLATE(
'msg__struct.h.em',
Expand All @@ -127,6 +141,13 @@ TEMPLATE(
message=action.get_result_service.response_message, include_directives=include_directives)
}@

@{
TEMPLATE(
'msg__struct.h.em',
package_name=package_name, interface_path=interface_path,
message=action.get_result_service.event_message, include_directives=include_directives)
}@

@{
TEMPLATE(
'msg__struct.h.em',
Expand Down
70 changes: 70 additions & 0 deletions rosidl_generator_c/resource/idl__type_support.c.em
Original file line number Diff line number Diff line change
@@ -0,0 +1,70 @@
// generated from rosidl_generator_c/resource/idl__type_support.c.em
// with input from @(package_name):@(interface_path)
// generated code does not contain a copyright notice
@
@#######################################################################
@# EmPy template for generating <idl>__type_support.c files
@#
@# Context:
@# - package_name (string)
@# - interface_path (Path relative to the directory named after the package)
@# - content (IdlContent, list of elements, e.g. Messages or Services)
@#######################################################################
@{
from rosidl_pycommon import convert_camel_case_to_lower_case_underscore
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)

include_directives = {
'rosidl_typesupport_interface/macros.h',
include_base + '__type_support.h',
include_base + '__struct.h',
include_base + '__functions.h'}
}@

#include <string.h>

@[for header_file in include_directives]@
#include "@(header_file)"
@[end for]@

#ifdef __cplusplus
extern "C"
{
#endif

@#######################################################################
@# Handle service
@#######################################################################
@{
from rosidl_parser.definition import Service
}@
@[for service in content.get_elements_of_type(Service)]@
@{
TEMPLATE(
'srv__type_support.c.em',
package_name=package_name, service=service,
interface_path=interface_path, include_directives=include_directives)
}@

@[end for]@
@
@#######################################################################
@# Handle action
@#######################################################################
@{
from rosidl_parser.definition import Action
}@
@[for action in content.get_elements_of_type(Action)]@
@{
TEMPLATE(
'action__type_support.c.em',
package_name=package_name, action=action,
interface_path=interface_path, include_directives=include_directives)
}@

@[end for]@
#ifdef __cplusplus
}
#endif
10 changes: 10 additions & 0 deletions rosidl_generator_c/resource/msg__struct.h.em
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@ from rosidl_parser.definition import FLOATING_POINT_TYPES
from rosidl_parser.definition import INTEGER_TYPES
from rosidl_parser.definition import NamespacedType
from rosidl_parser.definition import OCTET_TYPE
from rosidl_parser.definition import SERVICE_REQUEST_MESSAGE_SUFFIX
from rosidl_parser.definition import SERVICE_RESPONSE_MESSAGE_SUFFIX
from rosidl_generator_c import basetype_to_c
from rosidl_generator_c import idl_declaration_to_c
from rosidl_generator_c import idl_structure_type_sequence_to_c_typename
Expand Down Expand Up @@ -43,6 +45,14 @@ for member in message.structure.members:
'rosidl_runtime_c/u16string.h', [])
member_names.append(member.name)
elif isinstance(type_, NamespacedType):
if (
message.structure.namespaced_type.namespaces[-1] in ['action', 'srv'] and (
type_.name.endswith(SERVICE_REQUEST_MESSAGE_SUFFIX) or
type_.name.endswith(SERVICE_RESPONSE_MESSAGE_SUFFIX))
):
typename = type_.name.rsplit('_', 1)[0]
if typename == message.structure.namespaced_type.name.rsplit('_', 1)[0]:
continue
include_prefix = idl_structure_type_to_c_include_prefix(
type_, 'detail')
member_names = includes.setdefault(
Expand Down
Loading