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

Map duration and time messages #106

Merged
merged 3 commits into from
Mar 30, 2018
Merged

Conversation

dirk-thomas
Copy link
Member

Only slightly related to #104.

While the bridge can already handle fields with a Duration or Time type it currently can't map the messages std_msgs/Duration|Time with builtin_interfaces/Duration|Time.

With this patch the following appears when invoking the dynamic bridge with --print-pairs:

  - 'builtin_interfaces/Duration' (ROS 2) <=> 'std_msgs/Duration' (ROS 1)
  - 'builtin_interfaces/Time' (ROS 2) <=> 'std_msgs/Time' (ROS 1)

And the following example works:

  • ROS 1 side:
    rostopic pub /time std_msgs/Time "data:
      secs: 1 
      nsecs: 2"
    
  • ROS 2 side:
    ros2 topic echo /time builtin_interfaces/Time

@dirk-thomas dirk-thomas added the in review Waiting for review (Kanban column) label Mar 26, 2018
@dirk-thomas dirk-thomas self-assigned this Mar 26, 2018
@dirk-thomas dirk-thomas added the enhancement New feature or request label Mar 26, 2018
@dirk-thomas
Copy link
Member Author

Waiting for review.

Copy link
Member

@mikaelarguedas mikaelarguedas left a comment

Choose a reason for hiding this comment

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

lgtm, tested it locally and I can successfully bridge these messages now

@@ -31,27 +31,26 @@ namespace ros1_bridge
template<>
void
convert_1_to_2(
const ros::Duration & ros1_msg,
const ros::Duration & ros1_type,
Copy link
Member

Choose a reason for hiding this comment

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

This change doesn't make sense to me. Can you clarify why you changed only one of the names of this prototype? and that the names don't match what's used in the implementation at https://github.com/ros2/ros1_bridge/pull/106/files#diff-e7604d29ef87753b67dcf843c9e940caR72?

Copy link
Member

Choose a reason for hiding this comment

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

these are not messages but ROS 1 types hence the change in name. The prototype you're pointing to is taking messages and not types so using the _msg there is appropriate

Copy link
Member Author

Choose a reason for hiding this comment

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

This patch changes the ros1_msg argument to ros1_type argument for all convert_1_to_2 / convert_2_to_1 functions in the header as well as the source file. The rational is that neither of the two arguments ros::Duration nor ros::Time is a message but just a plain type.

The function you are referencing is unrelated to this signature. That one is for actual message in the builtin_interfaces packages and therefore those arguments still use _msg as the argument suffix.

Copy link
Member

Choose a reason for hiding this comment

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

ok, I'll keep looking at this to get my head around it myself, in the meantime the approval from @mikaelarguedas suggests it's just my misunderstanding so not a blocker 😄

Copy link
Member

Choose a reason for hiding this comment

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

following up, @mikaelarguedas pointed out what I was missing, which is that these particular msgs, fundamentally, are represented differently in ROS 1 and ROS 2: time/duration isn't a message in ROS 1, it is a data type, whereas in ROS 2 time/duration has message definitions associated with them. The contents of ros1_msg.data at this line is not another message.

#include "ros1_bridge/builtin_interfaces_factories.hpp"
#include "ros1_bridge/factory.hpp"
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 would rather revert this change. Before it was including first the factory interface and then all specialized factories. That made sense to me. Also the include order isn't being checked at the moment since some includes are hard coded and some other are being generated. So the overall order won't pass the inter anyway (without custom logic ordering the superset).

Copy link
Member

@mikaelarguedas mikaelarguedas Mar 30, 2018

Choose a reason for hiding this comment

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

Feel free to revert it, I wanted to save an iteration but apparently I should have just commented to get feedback rather than commiting the change.

In my mind as the specialized factories include the generic ones the order didn't matter and the day we remove the include of any specialized one the factory interface will still be imported

Copy link
Member Author

Choose a reason for hiding this comment

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

Np, better being proactive - I appreciate it!

@dirk-thomas dirk-thomas force-pushed the builtin_interfaces_messages branch from a55748f to f2caf7a Compare March 30, 2018 16:58
@dirk-thomas dirk-thomas merged commit ca30494 into master Mar 30, 2018
@dirk-thomas dirk-thomas deleted the builtin_interfaces_messages branch March 30, 2018 16:59
@dirk-thomas dirk-thomas removed the in review Waiting for review (Kanban column) label Mar 30, 2018
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.

3 participants