-
Notifications
You must be signed in to change notification settings - Fork 130
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
change generators to IDL-based pipeline, change char type, separate action types #334
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
First, this required installation of pydot
on my machine.
Currently getting a build failure:
--- stderr: rosidl_generator_c
Unknown named type: boolean /home/mjcarroll/workspaces/ros2_ws/src/build/rosidl_generator_c/rosidl_adapter/rosidl_generator_c/msg/Bool.idl
Error processing idl file: /home/mjcarroll/workspaces/ros2_ws/src/build/rosidl_generator_c/rosidl_adapter/rosidl_generator_c/msg/Bool.idl
Traceback (most recent call last):
File "/home/mjcarroll/workspaces/ros2_ws/src/ros2/rosidl/rosidl_generator_c/bin/rosidl_generator_c", line 40, in <module>
sys.exit(main())
File "/home/mjcarroll/workspaces/ros2_ws/src/ros2/rosidl/rosidl_generator_c/bin/rosidl_generator_c", line 35, in main
args.generator_arguments_file,
File "/home/mjcarroll/workspaces/ros2_ws/src/ros2/rosidl/rosidl_generator_c/rosidl_generator_c/__init__.py", line 35, in generate_c
generate_files(generator_arguments_file, mapping)
File "/home/mjcarroll/workspaces/ros2_ws/src/install/rosidl_cmake/lib/python3.6/site-packages/rosidl_cmake/__init__.py", line 122, in generate_files
raise(e)
File "/home/mjcarroll/workspaces/ros2_ws/src/install/rosidl_cmake/lib/python3.6/site-packages/rosidl_cmake/__init__.py", line 101, in generate_files
idl_rel_path.stem) + '.png')
File "/home/mjcarroll/workspaces/ros2_ws/src/install/rosidl_parser/lib/python3.6/site-packages/rosidl_parser/parser.py", line 60, in parse_idl_file
content = parse_idl_string(string, png_file=png_file)
File "/home/mjcarroll/workspaces/ros2_ws/src/install/rosidl_parser/lib/python3.6/site-packages/rosidl_parser/parser.py", line 80, in parse_idl_string
return extract_content_from_ast(tree)
File "/home/mjcarroll/workspaces/ros2_ws/src/install/rosidl_parser/lib/python3.6/site-packages/rosidl_parser/parser.py", line 129, in extract_content_from_ast
resolve_typedefed_names(msg.structure, typedefs)
File "/home/mjcarroll/workspaces/ros2_ws/src/install/rosidl_parser/lib/python3.6/site-packages/rosidl_parser/parser.py", line 232, in resolve_typedefed_names
assert type_.name in typedefs, 'Unknown named type: ' + type_.name
AssertionError: Unknown named type: boolean
I can disable the generation of the AST graph before the merge - or better make it conditional.
That shouldn't be the case. Are you sure you have the Anyway the build is currently expected to fail way later (around |
@[for field in spec.fields]@ | ||
@(msg_type_to_c(field.type, field.name)); | ||
@[for member in message.structure.members]@ | ||
@(idl_declaration_to_c(member.type, member.name)); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It looks like this is returning a declaration with uint8
for a field char[<=3] char_values
in test_msgs/msg/BoundedArrayPrimitives.msg
. It cases a warning while building
/home/developer/workspaces/ros2-dev0/build/test_msgs/rosidl_generator_py/test_msgs/msg/_bounded_array_primitives_s.c: In function ‘test_msgs__msg__bounded_array_primitives__convert_from_py’:
/home/developer/workspaces/ros2-dev0/build/test_msgs/rosidl_generator_py/test_msgs/msg/_bounded_array_primitives_s.c:144:51: warning: passing argument 1 of ‘rosidl_generator_c__char__Sequence__init’ from incompatible pointer type [-Wincompatible-po
inter-types]
if (!rosidl_generator_c__char__Sequence__init(&(ros_message->char_values), size)) {
^
In file included from /home/developer/workspaces/ros2-dev0/build/test_msgs/rosidl_generator_py/test_msgs/msg/_bounded_array_primitives_s.c:13:0:
/home/developer/workspaces/ros2-dev0/install/rosidl_generator_c/include/rosidl_generator_c/primitives_sequence_functions.h:31:8: note: expected ‘rosidl_generator_c__char__Sequence * {aka struct rosidl_generator_c__char__Sequence *}’ but argument is
of type ‘rosidl_generator_c__uint8__Sequence * {aka struct rosidl_generator_c__uint8__Sequence *}’
bool rosidl_generator_c__ ## STRUCT_NAME ## __Sequence__init( \
^
^~~~~~~~~~~
There are other warnings that all look related to char/uint8 confusion
/home/developer/workspaces/ros2-dev0/build/test_msgs/rosidl_generator_py/test_msgs/msg/_dynamic_array_primitives_s.c: In function ‘test_msgs__msg__dynamic_array_primitives__convert_from_py’:
/home/developer/workspaces/ros2-dev0/build/test_msgs/rosidl_generator_py/test_msgs/msg/_dynamic_array_primitives_s.c:144:51: warning: passing argument 1 of ‘rosidl_generator_c__char__Sequence__init’ from incompatible pointer type [-Wincompatible-po
inter-types]
if (!rosidl_generator_c__char__Sequence__init(&(ros_message->char_values), size)) {
^
In file included from /home/developer/workspaces/ros2-dev0/build/test_msgs/rosidl_generator_py/test_msgs/msg/_dynamic_array_primitives_s.c:13:0:
/home/developer/workspaces/ros2-dev0/install/rosidl_generator_c/include/rosidl_generator_c/primitives_sequence_functions.h:31:8: note: expected ‘rosidl_generator_c__char__Sequence * {aka struct rosidl_generator_c__char__Sequence *}’ but argument is
of type ‘rosidl_generator_c__uint8__Sequence * {aka struct rosidl_generator_c__uint8__Sequence *}’
bool rosidl_generator_c__ ## STRUCT_NAME ## __Sequence__init( \
^
/home/developer/workspaces/ros2-dev0/install/rosidl_generator_c/include/rosidl_generator_c/primitives_sequence_functions.h:42:1: note: in expansion of macro ‘ROSIDL_GENERATOR_C__DECLARE_PRIMITIVE_SEQUENCE_FUNCTIONS’
ROSIDL_GENERATOR_C__DECLARE_PRIMITIVE_SEQUENCE_FUNCTIONS(char, signed char)
^
/home/developer/workspaces/ros2-dev0/build/test_msgs/rosidl_generator_py/test_msgs/msg/_dynamic_array_primitives_s.c:150:26: warning: pointer targets in initialization differ in signedness [-Wpointer-sign]
signed char * dest = ros_message->char_values.data;
^~~~~~~~~~~
/home/developer/workspaces/ros2-dev0/build/test_msgs/rosidl_generator_py/test_msgs/msg/_dynamic_array_primitives_s.c: In function ‘test_msgs__msg__dynamic_array_primitives__convert_to_py’:
/home/developer/workspaces/ros2-dev0/build/test_msgs/rosidl_generator_py/test_msgs/msg/_dynamic_array_primitives_s.c:652:25: warning: pointer targets in initialization differ in signedness [-Wpointer-sign]
signed char * src = ros_message->char_values.data;
^~~~~~~~~~~
/home/developer/workspaces/ros2-dev0/build/test_msgs/rosidl_generator_py/test_msgs/msg/_bounded_array_primitives_s.c: In function ‘test_msgs__msg__bounded_array_primitives__convert_from_py’:
/home/developer/workspaces/ros2-dev0/build/test_msgs/rosidl_generator_py/test_msgs/msg/_bounded_array_primitives_s.c:144:51: warning: passing argument 1 of ‘rosidl_generator_c__char__Sequence__init’ from incompatible pointer type [-Wincompatible-po
inter-types]
if (!rosidl_generator_c__char__Sequence__init(&(ros_message->char_values), size)) {
^
In file included from /home/developer/workspaces/ros2-dev0/build/test_msgs/rosidl_generator_py/test_msgs/msg/_bounded_array_primitives_s.c:13:0:
/home/developer/workspaces/ros2-dev0/install/rosidl_generator_c/include/rosidl_generator_c/primitives_sequence_functions.h:31:8: note: expected ‘rosidl_generator_c__char__Sequence * {aka struct rosidl_generator_c__char__Sequence *}’ but argument is
of type ‘rosidl_generator_c__uint8__Sequence * {aka struct rosidl_generator_c__uint8__Sequence *}’
bool rosidl_generator_c__ ## STRUCT_NAME ## __Sequence__init( \
^
/home/developer/workspaces/ros2-dev0/install/rosidl_generator_c/include/rosidl_generator_c/primitives_sequence_functions.h:42:1: note: in expansion of macro ‘ROSIDL_GENERATOR_C__DECLARE_PRIMITIVE_SEQUENCE_FUNCTIONS’
ROSIDL_GENERATOR_C__DECLARE_PRIMITIVE_SEQUENCE_FUNCTIONS(char, signed char)
^
/home/developer/workspaces/ros2-dev0/build/test_msgs/rosidl_generator_py/test_msgs/msg/_bounded_array_primitives_s.c:150:26: warning: pointer targets in initialization differ in signedness [-Wpointer-sign]
signed char * dest = ros_message->char_values.data;
^~~~~~~~~~~
/home/developer/workspaces/ros2-dev0/build/test_msgs/rosidl_generator_py/test_msgs/msg/_bounded_array_primitives_s.c: In function ‘test_msgs__msg__bounded_array_primitives__convert_to_py’:
/home/developer/workspaces/ros2-dev0/build/test_msgs/rosidl_generator_py/test_msgs/msg/_bounded_array_primitives_s.c:652:25: warning: pointer targets in initialization differ in signedness [-Wpointer-sign]
signed char * src = ros_message->char_values.data;
^~~~~~~~~~~
/home/developer/workspaces/ros2-dev0/build/test_msgs/rosidl_generator_py/test_msgs/msg/_static_array_primitives_s.c: In function ‘test_msgs__msg__static_array_primitives__convert_from_py’:
/home/developer/workspaces/ros2-dev0/build/test_msgs/rosidl_generator_py/test_msgs/msg/_static_array_primitives_s.c:117:26: warning: pointer targets in initialization differ in signedness [-Wpointer-sign]
signed char * dest = ros_message->char_values;
^~~~~~~~~~~
/home/developer/workspaces/ros2-dev0/build/test_msgs/rosidl_generator_py/test_msgs/msg/_static_array_primitives_s.c: In function ‘test_msgs__msg__static_array_primitives__convert_to_py’:
/home/developer/workspaces/ros2-dev0/build/test_msgs/rosidl_generator_py/test_msgs/msg/_static_array_primitives_s.c:489:25: warning: pointer targets in initialization differ in signedness [-Wpointer-sign]
signed char * src = ros_message->char_values;
^~~~~~~~~~~
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It looks like this is returning a declaration with
uint8
for a fieldchar[<=3] char_values
intest_msgs/msg/BoundedArrayPrimitives.msg
.
That is the expected mapping. The ROS 1 type char
is mapped to the IDL type uint8
- see https://github.com/ros2/design/blob/gh-pages/articles/143_legacy_interface_definition.md#mapping-to-idl-types This matches the definition of char
from ROS 1: http://wiki.ros.org/msg#Field_Types
Regarding the warnings are you using ros2/rosidl_python#24 in your workspace?
c43d7fa
to
be891f1
Compare
08f947b
to
8f8beed
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
A few comments on things I noticed. I do think that I'm lacking a bit of context, so I cannot fully assess any shortcuts taken.
#define EXPECT_EQ(arg1, arg2) if ((arg1) != (arg2)) { \ | ||
fputs(STRINGIFY(arg1) " != " STRINGIFY(arg2) "\n", stderr); \ | ||
return 1; \ | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@dirk-thomas super minor: consider doing the same for EXPECT_NE
.
rosidl_typesupport_introspection_cpp/resource/srv__type_support.cpp.em
Outdated
Show resolved
Hide resolved
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Few minor comments, I'll have another pass tomorrow on those templates though.
...pesupport_introspection_c/cmake/rosidl_typesupport_introspection_c_generate_interfaces.cmake
Outdated
Show resolved
Hide resolved
...pport_introspection_cpp/cmake/rosidl_typesupport_introspection_cpp_generate_interfaces.cmake
Outdated
Show resolved
Hide resolved
c849052
to
ae09654
Compare
rosidl_generator_c/cmake/rosidl_generator_c_generate_interfaces.cmake
Outdated
Show resolved
Hide resolved
elements = [repr(v) for v in value] | ||
while len(elements) < 2: | ||
elements.append('') | ||
return '"(%s)"' % ', '.join(e.replace('"', r'\"') for e in elements) | ||
|
||
if 'boolean' == idl_type: | ||
return 'TRUE' if value else 'FALSE' | ||
if 'string' == idl_type: | ||
if idl_type.startswith('string'): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It looks like this might trigger for fixed sized array's of nested messages if the package name starts with string
because of
rosidl/rosidl_adapter/rosidl_adapter/msg/__init__.py
Lines 96 to 97 in ab1b43a
identifier = '{type_.pkg_name}::msg::{type_.type}' \ | |
.format_map(locals()) |
rosidl/rosidl_adapter/rosidl_adapter/msg/__init__.py
Lines 102 to 103 in ab1b43a
if type_.is_fixed_size_array(): | |
return '{identifier}[{type_.array_size}]'.format_map(locals()) |
const @(get_idl_type(constant.type)) @(constant.name) = @(to_idl_literal(get_idl_type(constant.type), constant.value)); |
I assume startswith
is used for bounded strings?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The function is only used for constant values and default values. So nested messages aren't supported in these cases atm. While certainly not future proof I think it is good enough for now.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Just a few minor comments.
const @(MSG_TYPE_TO_CPP[c.type]) | ||
@(spec.base_type.type)_<ContainerAllocator>::@(c.name) = "@(escape_string(c.value))"; | ||
const @(MSG_TYPE_TO_CPP['string']) | ||
@(message.structure.type.name)_<ContainerAllocator>::@(c.name) = "@(escape_string(c.value))"; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@dirk-thomas FYI, and probably out of scope, but since a string constant is actually a const char *
, you could make this constexpr
too just like it is done immediately below.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I will leave this as an enhancement in the future.
Addressed all the feedback. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
list_append_unique(_ARG_RGAI_DEPENDENCY_PACKAGE_NAMES "unique_identifier_msgs") | ||
ament_export_dependencies(action_msgs) | ||
ament_export_dependencies(builtin_interfaces) | ||
ament_export_dependencies(unique_identifier_msgs) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@dirk-thomas It looks like bringing along these dependencies for actions were lost during the pipeline change. See ros2/rcl_interfaces#75.
Bug introduced by #334. Signed-off-by: Jacob Perron <[email protected]>
Bug introduced by #334. Signed-off-by: Jacob Perron <[email protected]>
This is the seventh PR integrating #298 step-by-step.
Builds on top of #331.
rosidl_generator_c
androsidl_generator_cpp
packages to use the new IDL-based extension points. One change effecting other packages is that the generators now generate the same set of files for each input.idl
file (no different sets depending on the content of the interface file) - see next bullet.rosidl_actions
package as well as any other custom processing logic for actions..action
files to the legacy generators.Similar to the third bullet this patch requires the following changes: