carla-simulator / ros-bridge

ROS bridge for CARLA Simulator
MIT License
510 stars 408 forks source link

Wrong conversion from CARLA coordinate system to ROS coordinate system? #637

Open gunnxx opened 1 year ago

gunnxx commented 1 year ago

Hi, I noticed that in carla_rotation_to_RPY function, yaw and pitch are inverted. If CARLA uses left-hand coordinate system (with z-axis up) and ROS uses right-hand coordinate system (with z-axis up), then yaw and roll should be the ones inverted. See figure below. Screenshot from 2022-09-05 15-55-56

I do not know if there is another rule that I missed, because CARLA documentation itself is kind of inconsistent. In the carla.Rotation documentation, the picture shows that the yaw is left-handed but roll and pitch are right-handed.

geyang commented 1 year ago

Only if folks who build ROS and CARLA knew graphics, we wouldn't have to do these conversions.

UditSinghParihar commented 1 year ago

Correct transforms should be like this in transforms.py as mentioned by @gunnxx

RHS (ROS) = LHS (CARLA)

Position:

x_ros = x_carla
y_ros = -y_carla
z_ros = z_carla

Rotation:

roll_ros = -roll_carla
pitch_ros = pitch_carla
yaw_ros = -yaw_carla
gunnxx commented 1 year ago

@UditSinghParihar you also have to change the default config to spawn ego if you use that one (here). You have to negate the pitch. This is very very inconvenient.

UditSinghParihar commented 1 year ago

@gunnxx , thanks for the pointer but moving forward I have just changed the tranforms.py and the changes in the objects.json would only be in the right-hand coordinate transform.