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

Add typesupport for actions in c and c++ #36

Merged
merged 24 commits into from
Nov 13, 2018

Conversation

apojomovsky
Copy link
Contributor

@apojomovsky apojomovsky commented Nov 7, 2018

This PR addresses the second part of ros2/rosidl#303 and ros2/rosidl#302 , which was coupled to the first one.

  • Extends the logic of the rosidl_typesupport_c and rosidl_typesupport_cpp to support the generation of typesupport headers for action files.
  • Adds the required templates to generate both c and cpp action typesupport files.

connects to ros2/rcl_interfaces#48

@tfoote tfoote added the in progress Actively being worked on (Kanban column) label Nov 7, 2018
@@ -0,0 +1,36 @@
// Copyright 2016 Open Source Robotics Foundation, Inc.
Copy link
Contributor

Choose a reason for hiding this comment

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

2018

Copy link
Contributor

Choose a reason for hiding this comment

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

Actually I don't think this file is necessary like it is for messages and services. The action type support doesn't change with rmw implementation, so there's no need to have a dispatch.

Copy link
Contributor

@hidmic hidmic Nov 9, 2018

Choose a reason for hiding this comment

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

That's true, but don't we need it to get proper typesupport for the underlying services and messages? Nvm, wrong assumption.

Copy link
Contributor

Choose a reason for hiding this comment

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

That's true, but don't we need it to get proper typesupport for the underlying services and messages?

Yes, but that can use the dispatch on the generated messages and services. The generated action type support just needs to call get_service_type_support<>() or get_message_type_support<>(), and in C ROSIDL_GET_SRV_TYPE_SUPPORT() or ROSIDL_GET_MSG_TYPE_SUPPORT()

Copy link
Contributor

Choose a reason for hiding this comment

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

Right, I realized shortly after I commented.

@@ -0,0 +1,124 @@
// generated from rosidl_typesupport_c/resource/action__type_support.cpp.em
Copy link
Contributor

Choose a reason for hiding this comment

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

Same as above comment I don't think this file is needed because no dispatch is needed for actions.

Copy link
Contributor

Choose a reason for hiding this comment

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

True.

@@ -0,0 +1,34 @@
// Copyright 2016 Open Source Robotics Foundation, Inc.
Copy link
Contributor

Choose a reason for hiding this comment

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

Same as above comments, I don't think this file is needed.

Copy link
Contributor

Choose a reason for hiding this comment

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

True.

{

template<>
ROSIDL_GENERATOR_C_PUBLIC_@(spec.pkg_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 will need a different visibility macro ROSIDL_GENERATOR_C_PUBLIC_<package name>_ACTION. This is needed to get the dllexport and dllimport correct when generating these files.

See changes in this diff.

https://github.com/ros2/rcl_interfaces/pull/47/files/a70935a2109267bb4ea7cf9ee17fdd50f3995d5b..6d6da5801ed3ee1438246bc5b31898d12d522ff0

Copy link
Contributor

Choose a reason for hiding this comment

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

Good point. Added.

@hidmic hidmic force-pushed the apojomovsky/cpp_typesupport_for_actions branch from 6d4db14 to c4b9758 Compare November 10, 2018 01:33
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.

LGTM but for a few minor nits and pending CI.

@# Parsed specification of the .action file
@# - subfolder (string)
@# The subfolder / subnamespace of the message, usually 'action'
@# - type_supports (list of strings)
Copy link
Contributor

Choose a reason for hiding this comment

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

@apojomovsky unused type_supports list?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

true that, just removed references to it where unused. thanks!

args['output_dir'], subfolder, generated_filename %
convert_camel_case_to_lower_case_underscore(spec.action_name))

data = {'spec': spec, 'subfolder': subfolder, 'type_supports': type_supports}
Copy link
Contributor

Choose a reason for hiding this comment

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

@apojomovsky same as above, are we using this type_supports list?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

it's not being used, just removed it. thanks!

@# Parsed specification of the .action file
@# - subfolder (string)
@# The subfolder / subnamespace of the message, usually 'action'
@# - type_supports (list of strings)
Copy link
Contributor

Choose a reason for hiding this comment

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

@apojomovsky unused type_supports list?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

yup! removed, thanks!

@apojomovsky
Copy link
Contributor Author

CI with ros2/rosidl_typesupport#36, ros2/rosidl#312 and ros2/rcl_interfaces#48

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

@hidmic
Copy link
Contributor

hidmic commented Nov 13, 2018

@sloretz @apojomovsky I can't seem to be able to compile ros2/rcl#319 locally with #36, ros2/rosidl#312 and ros2/rcl_interfaces#48.

--- stderr: rcl_action
CMakeFiles/test_action_client.dir/test/rcl_action/test_action_client.cpp.o: In function `TestActionClientBaseFixture_test_action_client_init_fini_Test::TestBody()':
test_action_client.cpp:(.text+0x50): undefined reference to `rosidl_typesupport_c__get_action_type_support_handle__test_msgs__action__Fibonacci'
CMakeFiles/test_action_client.dir/test/rcl_action/test_action_client.cpp.o: In function `TestActionClientFixture::SetUp()':
test_action_client.cpp:(.text._ZN23TestActionClientFixture5SetUpEv[_ZN23TestActionClientFixture5SetUpEv]+0x45): undefined reference to `rosidl_typesupport_c__get_action_type_support_handle__test_msgs__action__Fibonacci'
collect2: error: ld returned 1 exit status
make[2]: *** [test_action_client] Error 1
make[1]: *** [CMakeFiles/test_action_client.dir/all] Error 2
make: *** [all] Error 2
---
Failed   <<< rcl_action	[ Exited with code 2 ]

However, the action interfaces library is generated and installed, and it does contain the missing symbol above, so it looks like there's a missing dependency relationship in the CMake infrastructure. I tried a fix but it isn't obvious to me where the chain broke.

VERBATIM
)

set(_target_suffix "__generate_action_interfaces__rosidl_typesupport_cpp")
Copy link
Contributor

Choose a reason for hiding this comment

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

Copy link
Contributor

Choose a reason for hiding this comment

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

No reason

Copy link
Contributor

Choose a reason for hiding this comment

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

Made consistent in 31efaca

@sloretz
Copy link
Contributor

sloretz commented Nov 13, 2018

@hidmic The linking issue should be solved by ros2/rosidl@2467acf which changes rosidl_generate_action_interfaces() from a function to a macro (thanks @dirk-thomas). The linking issue happened because _AMENT_EXPORT_LIBRARIES was being set in a different scope than ament_package() was being called in.

@apojomovsky
Copy link
Contributor Author

Thanks a lot for the fixes @sloretz ! Just verified that the rcl_action tests from @hidmic 's branch are now able to build/run successfully with the latest changes 👍

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.

LGTM!

@sloretz sloretz merged commit 0461362 into master Nov 13, 2018
@sloretz sloretz deleted the apojomovsky/cpp_typesupport_for_actions branch November 13, 2018 18:51
@sloretz sloretz removed the in progress Actively being worked on (Kanban column) label Nov 13, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants