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

change generators to IDL-based pipeline, change char type, separate action types #334

Merged
merged 78 commits into from
Mar 12, 2019

Conversation

dirk-thomas
Copy link
Member

This is the seventh PR integrating #298 step-by-step.

Builds on top of #331.

  • It adds a Python function usable by message generators to reduce duplicate logic.
  • It updates the rosidl_generator_c and rosidl_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.
  • It updates the includes of the generated code to match the reduced number of generated files.
  • It removes the rosidl_actions package as well as any other custom processing logic for actions.
  • Skip passing .action files to the legacy generators.

Similar to the third bullet this patch requires the following changes:

  • ...

@dirk-thomas dirk-thomas added the in progress Actively being worked on (Kanban column) label Nov 21, 2018
@dirk-thomas dirk-thomas self-assigned this Nov 21, 2018
@dirk-thomas dirk-thomas added the enhancement New feature or request label Nov 21, 2018
Copy link
Member

@mjcarroll mjcarroll left a 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

rosidl_generator_c/msg/PrimitiveValues.msg Show resolved Hide resolved
@dirk-thomas
Copy link
Member Author

this required installation of pydot on my machine.

I can disable the generation of the AST graph before the merge - or better make it conditional.

Currently getting a build failure:

That shouldn't be the case. Are you sure you have the python3-lark-parser dependency installed?

Anyway the build is currently expected to fail way later (around test_msgs) and needs branches from various repos for the changed header names.

@[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));
Copy link
Contributor

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;
                         ^~~~~~~~~~~

Copy link
Member Author

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.

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?

@dirk-thomas dirk-thomas force-pushed the idl-stage-7 branch 3 times, most recently from 08f947b to 8f8beed Compare November 25, 2018 05:33
@dirk-thomas dirk-thomas added in review Waiting for review (Kanban column) and removed in progress Actively being worked on (Kanban column) labels Nov 26, 2018
@dirk-thomas
Copy link
Member Author

dirk-thomas commented Nov 26, 2018

  • Linux Build Status
  • Linux-aarch64 Build Status
  • macOS Build Status
  • Windows Build Status

Copy link
Contributor

@hidmic hidmic left a 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.

rosidl_generator_c/resource/idl.h.em Outdated Show resolved Hide resolved
rosidl_generator_c/resource/idl__functions.c.em Outdated Show resolved Hide resolved
rosidl_generator_c/src/u16string_functions.c Show resolved Hide resolved
#define EXPECT_EQ(arg1, arg2) if ((arg1) != (arg2)) { \
fputs(STRINGIFY(arg1) " != " STRINGIFY(arg2) "\n", stderr); \
return 1; \
}
Copy link
Contributor

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_generator_cpp/resource/msg__struct.hpp.em Outdated Show resolved Hide resolved
rosidl_generator_cpp/test/test_interfaces.cpp Outdated Show resolved Hide resolved
@dirk-thomas
Copy link
Member Author

dirk-thomas commented Nov 28, 2018

Builds including the updated introspection typesupport packages:

  • Linux Build Status
  • Linux-aarch64 Build Status (using FastRTPS static and dynamic)
  • macOS Build Status
  • Windows Build Status

Copy link
Contributor

@hidmic hidmic left a 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.

@dirk-thomas
Copy link
Member Author

Builds including the updated FastRTPS typesupport packages:

  • Linux Build Status
  • Linux-aarch64 Build Status (using FastRTPS static and dynamic)
  • macOS Build Status
  • Windows Build Status

@dirk-thomas
Copy link
Member Author

dirk-thomas commented Dec 5, 2018

Builds including the updated rosidl_generator_py package and the Connext TS changes:

  • Linux Build Status
  • Linux-aarch64 Build Status
  • macOS Build Status
  • Windows Build Status

@dirk-thomas
Copy link
Member Author

dirk-thomas commented Dec 5, 2018

Latest builds with all RMW (without repeating failed test, so some might be flaky):

  • Linux Build Status
  • Linux-aarch64 Build Status
  • macOS Build Status
  • Windows Build Status

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'):
Copy link
Contributor

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

identifier = '{type_.pkg_name}::msg::{type_.type}' \
.format_map(locals())
and this return
if type_.is_fixed_size_array():
return '{identifier}[{type_.array_size}]'.format_map(locals())
when called here
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?

Copy link
Member Author

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.

Copy link
Contributor

@hidmic hidmic left a 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))";
Copy link
Contributor

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.

Copy link
Member Author

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.

rosidl_generator_cpp/test/test_interfaces.cpp Outdated Show resolved Hide resolved
rosidl_generator_cpp/test/test_interfaces.cpp Outdated Show resolved Hide resolved
rosidl_generator_c/rosidl_generator_c/__init__.py Outdated Show resolved Hide resolved
rosidl_generator_c/rosidl_generator_c/__init__.py Outdated Show resolved Hide resolved
rosidl_generator_c/src/u16string_functions.c Outdated Show resolved Hide resolved
rosidl_generator_c/src/u16string_functions.c Show resolved Hide resolved
rosidl_generator_c/src/u16string_functions.c Outdated Show resolved Hide resolved
@dirk-thomas
Copy link
Member Author

Addressed all the feedback.

Copy link
Member

@jacobperron jacobperron left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@dirk-thomas dirk-thomas merged commit 416ebd8 into master Mar 12, 2019
@dirk-thomas dirk-thomas deleted the idl-stage-7 branch March 12, 2019 04:11
@dirk-thomas dirk-thomas removed the in review Waiting for review (Kanban column) label Mar 12, 2019
@dirk-thomas dirk-thomas mentioned this pull request Apr 15, 2019
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)
Copy link
Member

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.

jacobperron added a commit that referenced this pull request May 14, 2019
Bug introduced by #334.

Signed-off-by: Jacob Perron <[email protected]>
jacobperron added a commit that referenced this pull request May 14, 2019
Bug introduced by #334.

Signed-off-by: Jacob Perron <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants