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

demo ros2 call ros1 service failure #356

Closed xlla closed 2 years ago

xlla commented 2 years ago

Bug report

Required Info:

Steps to reproduce issue

exactly as Example 4: bridge only selected topics and services

Expected behavior

as Example 4 described

Actual behavior

bridge create failure, can't call ros1 service from ros2

roscore was running on machine A

launch bridge on machine B

$ ros2 run ros1_bridge parameter_bridge
Trying to create bidirectional bridge for topic '/chatter' with ROS 2 type 'std_msgs/msg/String'
[INFO] [1650822995.675139598] [ros_bridge]: create bidirectional bridge for topic /chatter
Trying to create bridge for ROS 2 service '/add_two_ints' with type 'example_interfaces/srv/AddTwoInts'
failed to create bridge ROS 1 service '/add_two_ints' no conversion for type 'example_interfaces/srv/AddTwoInts'
The parameter 'services_2_to_1' either doesn't exist or isn't an array
[INFO] [1650822996.207521866] [ros_bridge]: Passing message from ROS 1 std_msgs/String to ROS 2 std_msgs/msg/String (showing msg only once per type)

launch ros1 service on machine C

$ rosrun roscpp_tutorials add_two_ints_server

launch ros2 service caller on machine B

$ ros2 service call /add_two_ints example_interfaces/srv/AddTwoInts "{a: 1, b: 2}"
waiting for service to become available...

ros1 service was launch

$ rosservice list
/add_two_ints
/add_two_ints_server/get_loggers
/add_two_ints_server/set_logger_level
/ros_bridge/get_loggers
/ros_bridge/set_logger_level
/rosout/get_loggers
/rosout/set_logger_level
/talker_97489_1650826988152/get_loggers
/talker_97489_1650826988152/set_logger_level
/talker_97842_1650827739573/get_loggers
/talker_97842_1650827739573/set_logger_level

ros1 service can be call from ros1 client

$ rosrun roscpp_tutorials add_two_ints_client 55 33
[ INFO] [1650827853.334119000]: Sum: 88

Additional information

Feature request

Feature description

Implementation considerations

xlla commented 2 years ago

I have created another ubuntu 20.04 server , build ros2 galactic from source, it still failure to run Example 4.

$ ros2 run ros1_bridge parameter_bridge
Trying to create bidirectional bridge for topic '/chatter' with ROS 2 type 'std_msgs/msg/String'
[INFO] [1650894884.831267657] [ros_bridge]: create bidirectional bridge for topic /chatter
Trying to create bridge for ROS 2 service '/add_two_ints' with type 'example_interfaces/srv/AddTwoInts'
Created 1 to 2 bridge for service /add_two_ints
The parameter 'services_2_to_1' either doesn't exist or isn't an array
[INFO] [1650894885.151093541] [ros_bridge]: Passing message from ROS 1 std_msgs/String to ROS 2 std_msgs/msg/String (showing msg only once per type)
xlla commented 2 years ago

I unconsciously run ros1 client with ros2 server on this parameter_bridge, it is work!

So I think the bridge yaml for example 4 was inverted, the corrected should:

topics:
  -
    topic: /chatter  # ROS1 topic name
    type: std_msgs/msg/String  # ROS2 type name
    queue_size: 1  # For the publisher back to ROS1
services_2_to_1:
  -
    service: /add_two_ints  # ROS2 service name
    type: roscpp_tutorials/TwoInts  # The ROS1 type name

see the PR #357

methylDragon commented 2 years ago

Thanks for catching this! I'll follow up on the PR (:

methylDragon commented 2 years ago

Merged, https://github.com/ros2/ros1_bridge/pull/357 thanks!!