Failed to create a bridge for topic when done using ROS2 python launch file but works using command line
Hi,
I am using ROS2 Humble Hawksbill on Ubuntu 22.04 Jammy along with Ignition Fortress which comes pre-packed with the desktop-full variant of ROS for amd64 architecture.
I have an sdf file which contains both robot (with lidar sensor) and the environment. IGN gazebo publishes two topics: one for laser_scan(ignition.msgs.LaserScan in IGN or sensor_msgs/msg/LaserScan in ROS2) and second for point cloud2 (ignition.msgs.PointCloudPacked in IGN or sensor_msgs/msg/PointCloud2 in ROS).
After loading the model in ign gazebo and running the simulation, I was able to create a ros_ign_bridge for the above two topics and remapped them the using command line which works perfectly. I can echo the messages and see visualization on rviz2 as well.
ros2 run ros_ign_bridge parameter_bridge /lidar2@sensor_msgs/msg/LaserScan[ign... --ros-args -r /lidar2:=/laser_scan
ros2 run ros_ign_bridge parameter_bridge /lidar2/points@sensor_msgs/msg/PointC... --ros-args -r /lidar2/points:=/point_cloud2
But the problem occurs when I try to do so using a python launch file. It can load load the model and start the simulation in ign, but can not create a bridge properly. "ros2 topic list" shows below which indicates that the bridge is working (at least partially).
/clicked_point /goal_pose /initialpose /laser_scan /model/vehicle_blue/cmd_vel /parameter_events /point_cloud2 /rosout /tf /tf_static
Then, I did "ros2 topic echo /laser_scan" or "ros2 topic echo /point_cloud2" topics which gives below error.
2022-06-17 17:42:00.940 [RTPS_TRANSPORT_SHM Error] Failed init_port fastrtps_port7427: open_and_lock_file failed -> Function open_port_internal
However, "ign topic -e -t /lidar2" and "ign topic -e -t /lidar2/points" shows data indicating that the sensors are spitting out values but the bridge is not working correctly.
Below is my launch file: C:\fakepath\spawn_husky_launch.py
and here is the error output on terminal:
[ign gazebo-1] [Err] [SystemPaths.cc:467] Could not resolve file [playground_diffuse.jpg] [ign gazebo-1] libEGL warning: DRI2: failed to create dri screen [ign gazebo-1] libEGL warning: DRI2: failed to create dri screen [ign gazebo-1] [Err] [SystemPaths.cc:467] Could not resolve file [playground_diffuse.jpg] [ign gazebo-1] libEGL warning: DRI2: failed to create dri screen [ign gazebo-1] libEGL warning: DRI2: failed to create dri screen [ign gazebo-1] [GUI] [Err] [SystemPaths.cc:467] Could not resolve file [playground_diffuse.jpg] [INFO] [parameter_bridge-3]: process started with pid [3550288] [parameter_bridge-3] 2022-06-17 17:35:17.253 [RTPS_TRANSPORT_SHM Error] Failed init_port fastrtps_port7427: open_and_lock_file failed -> Function open_port_internal [parameter_bridge-3] Failed to create a bridge for topic [/lidar2] with ROS2 type [sensor_msgs/msg/LaserScan] and Ignition Transport type [ignition.msgs.LaserScan --ros-args -r /lidar2:=/laser_scan] [parameter_bridge-3] Failed to create a bridge for topic [/lidar2/points] with ROS2 type [sensor_msgs/msg/PointCloud2] and Ignition Transport type [ignition.msgs.PointCloudPacked --ros-args -r /lidar2/points:=/point_cloud2]
Initially, in the launch file, inside of "return LaunchDescription", "bridge" was present instead of "TimerAction(period=10.0,actions=[bridge])" which gave the same error. Then, I thought that the computer might be loading the model and then creating the bridge very fast (even before the sensor start to send data), so, having a delay would be better ...