carla-simulator / carla

Open-source simulator for autonomous driving research.
http://carla.org
MIT License
11.11k stars 3.58k forks source link

RCL Error while running CARLA basic agent along with carla ros bridge #6767

Open AJK97 opened 1 year ago

AJK97 commented 1 year ago

Hi, i keep getting this RCL error: Failed to create publisher: create_publisher() called for existing topic name rt/carla/hero/front with incompatible type carlamsgs::msg::dds::CarlaLaneInvasionEvent_, at ./src/publisher.cpp:149, at ./src/rcl/publisher.c:116. This happens every time I try to run carla ros bridge alongside the example basic agent .

anyone here has a clue why this happens ? CARLA 9.14 ROS2 Humble

image

lrstttl commented 11 months ago

Hi @AJK97, I also encountered the same issue today.

The problem started to occur when using the ROS Bridge with ROS2 humble and only when using the ROS Scenario Runner. Here, both the LaneInvasionSensor and CollisionSensor are spawned. For some reason, both of them have the same name, so the call to self.get_topic_prefix() yields /carla/hero/front (for role name "hero" as you stated above).

This leads to publishing the sensor events of both sensors to topic /carla/ego_vehicle/front, which eventually leads to the error of incompatible types, as the lane invasion sensor uses the message CarlaLaneInvasionEvent and the collision sensor uses CarlaCollisionEvent from ros-carla-msgs.

lrstttl commented 11 months ago

Quick workaround would be to define a different topic name for one of the sensors. You could change line 53 of collision_sensor.py from

                                                      self.get_topic_prefix(),

to

                                                      self.get_topic_prefix() + "_collision",

to make the ROS Bridge + humble work again.

lrstttl commented 11 months ago

Of course this needs further investigation. But the issue rather belongs to the repository https://github.com/carla-simulator/ros-bridge.

stale[bot] commented 8 months ago

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.