Closed abol-karimi closed 4 months ago
Hi Abel, I'll take a look at this. It's possible that the map information is incorrect, but it could also be an issue on Scenic's side. Can you provide a seed to reproduce this, ideally using the internal visualizer? Something like:
scenic road_direction.scenic --2d --seed X
scenic road_direction.scenic --2d
produces correct results (with any seeds), for example:
so it seems that the bug is in the transformation to Carla's coordinates.
Hmm interesting. I'll investigate.
There are two problems in scenicToCarlaRotation:
Here is a diagram of the correspondence of the two frames:
This code should fix it:
def scenicToCarlaRotation(orientation):
yaw, pitch, roll = orientation.r.as_euler("ZXY", degrees=False)
rot = Orientation.fromEuler(yaw=yaw+math.pi/2, pitch=pitch, roll=roll)
pitch, yaw, roll = rot.r.as_euler("YZX", degrees=True)
return carla.Rotation(pitch=-pitch, yaw=yaw, roll=-roll)
and it mostly does fix it, but I still sometimes see a car spawned in the opposite direction even though the output of the code above was correct. Maybe there is a bug in Carla?
One thing I totally missed is that Euler angles in Scenic are intrinsic, not extrinsic! So I don't know what the bug is.
This is my bugfix as we discussed over Slack:
def scenicToCarlaRotation(orientation):
origin = (0, 0, 0)
scenic_y_axis = (0, 1, 0)
obj_3d_heading = orientation.r.apply(scenic_y_axis)
scenic_yaw = headingOfSegment(origin, obj_3d_heading)
carla_yaw = -90 - math.degrees(scenic_yaw)
return carla.Rotation(pitch=0, yaw=carla_yaw, roll=0)
Example script:
which I run in python with:
produces this scene:
Platform: