ros2 / ros1_bridge

ROS 2 package that provides bidirectional communication between ROS 1 and ROS 2
Apache License 2.0
425 stars 275 forks source link

Fields mapping #353

Closed amifsud closed 2 years ago

amifsud commented 2 years ago

Bug report

Required Info:

Steps to reproduce issue

Trying to map the following message in ros1:

Example.msg :

float64 a
float64 b
float64 c
float64 d

to this one in ros2:

Example1.msg :

float64 w
float64 x
float64 y
float64 z

With the mapping rules :

-
    ros1_package_name: 'ros1_msgs'
    ros1_message_name: 'Example'
    ros2_package_name: 'ros2_msgs'
    ros2_message_name: 'Example1'
        fields_1_to_2:
            a: 'w'
            b: 'x'
            c: 'y'
            d: 'z'

Or the following ones :

-
    ros1_package_name: 'ros1_msgs'
    ros1_message_name: 'Example'
    ros2_package_name: 'ros2_msgs'
    ros2_message_name: 'Example1'
        fields_2_to_1:
            w: 'a'
            x: 'b'
            y: 'c'
            z: 'd'

In ros1 workspace (~/ros1_ws):

source /opt/ros/noetic/setup.bash
catkin_make install

source ~/ros1_ws/install/setup.bash
rosmsg show ros1_msgs/Example

In ros2 workspace (~/ros2_ws):

source /opt/ros/foxy/setup.bash
colcon build --build-base foxy_build --install-base foxy_install

source ~/ros2_ws/foxy_install/setup.bash
ros2 interface show ros2_msgs/msg/Example1

In ros1_bridge workspace (~/bridge_ws):

source ~/ros1_ws/install/setup.bash
source ~/ros2_ws/foxy_install/setup.bash
colcon build --build-base foxy_build --install-base foxy_install --cmake-force-configure

source ~/bridge_ws/foxy_install/setup.bash
ros2 run ros1_bridge dynamic_bridge --print-pairs | grep Example

Expected behavior

In ros1 workspace (~/ros1_ws):

source /opt/ros/noetic/setup.bash
catkin_make install

source ~/ros1_ws/install/setup.bash
rosmsg show ros1_msgs/Example

Result :

float64 a
float64 b
float64 c
float64 d

In ros2 workspace (~/ros2_ws):

source /opt/ros/foxy/setup.bash
colcon build --build-base foxy_build --install-base foxy_install

source ~/ros2_ws/foxy_install/setup.bash
ros2 interface show ros2_msgs/msg/Example1

Result :

float64 w
float64 x
float64 y
float64 z

In ros1_bridge workspace (~/bridge_ws):

source ~/ros1_ws/install/setup.bash
source ~/ros2_ws/foxy_install/setup.bash
colcon build --build-base foxy_build --install-base foxy_install --cmake-force-configure

Result : No error or warning for both mapping rules

source ~/bridge_ws/foxy_install/setup.bash
ros2 run ros1_bridge dynamic_bridge --print-pairs | grep Example

Result : for both mapping rules :

 - 'icars2_msgs/msg/Example1' (ROS 2) <=> 'icars_msgs/Example' (ROS 1)

Actual behavior

Expected behavior until in ros1_bridge workspace.

In ros1_bridge workspace (~/bridge_ws):

source ~/ros1_ws/install/setup.bash
source ~/ros2_ws/foxy_install/setup.bash
colcon build --build-base foxy_build --install-base foxy_install --cmake-force-configure

Result: For the second mapping rule (using field_2_to_1)

--- stderr: ros1_bridge                                          
Mapping for package icars2_msgs contains unknown field(s)
---

Expected behavior for the first.

source ~/bridge_ws/foxy_install/setup.bash
ros2 run ros1_bridge dynamic_bridge --print-pairs | grep Example

Result: Empty answer for the second mapping rule, expected behavior for the first.

gbiggs commented 2 years ago

Can you please provide a copy of your source to reproduce the issue?

amifsud commented 2 years ago

Here is a repo with the different workspaces (ros1_bridge as a submodule)

Thanks again for your reply Alexis

quarkytale commented 2 years ago

Thanks for sharing the source code. I could reproduce both #353 and #354. Looking into it.

gbiggs commented 2 years ago

@amifsud Please see this comment on #354. I believe this issue has the same cause. Try running the commands in three separate terminals.

amifsud commented 2 years ago

Hello,

As I said in #354, I actually used different terminals.

Thanks, Alexis

quarkytale commented 2 years ago

@amifsud I think this might solve your issue, please try again using quarkytale/mapping_rule branch of ros1_bridge. It should print out using both mapping rules. Let me know how it goes!

amifsud commented 2 years ago

@quarkytale Yes it is working for both mapping rules. Thanks !

quarkytale commented 2 years ago

Thanks for trying it out! I'll open a PR for it to be merged into master.