Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Carla bridge functions doesn't work as expectation #72

Open
spyeic opened this issue Aug 26, 2023 · 0 comments · May be fixed by #73
Open

Carla bridge functions doesn't work as expectation #72

spyeic opened this issue Aug 26, 2023 · 0 comments · May be fixed by #73
Assignees
Labels
bug Something isn't working

Comments

@spyeic
Copy link

spyeic commented Aug 26, 2023

Describe the bug
In carla_bridge.py:
convert_xx_from_agent_to_source functions have issue:

def convert_location_from_agent_to_source(self, source: Location) -> carla.Location:
"""Convert Agent's Location to a Carla.Location."""
return carla.Location(x=source.x, y=-source.z, z=source.y)
def convert_rotation_from_agent_to_source(self, source: Rotation) -> carla.Rotation:
"""Convert Agent's Rotation to a Carla.Rotation."""
return carla.Rotation(pitch=source.yaw, yaw=source.pitch, roll=source.roll)
def convert_transform_from_agent_to_source(
self, source: Transform
) -> carla.Transform:
"""Convert Agent's Transform to a Carla.Transform."""
return carla.Transform(
location=self.convert_location_from_agent_to_source(source=source.location),
rotation=self.convert_rotation_from_agent_to_source(source=source.rotation),
)

are not inverse functions of

def convert_location_from_source_to_agent(self, source: carla.Location) -> Location:
"""w
Convert Location data from Carla.location to Agent's location data type
invert the Z axis to make it into right hand coordinate system
Args:
source: carla.location
Returns:
"""
return Location(x=source.x, y=source.z, z=source.y)
# return Location(x=source.x, y=source.y, z=source.z)
def convert_rotation_from_source_to_agent(self, source: carla.Rotation) -> Rotation:
"""Convert a CARLA raw rotation to Rotation(pitch=float,yaw=float,roll=float)."""
roll, pitch, yaw = source.roll, source.pitch, source.yaw
if yaw <= 90:
yaw = yaw + 90
else:
yaw = yaw - 270
return Rotation(roll=roll, pitch=pitch, yaw=-yaw)
def convert_transform_from_source_to_agent(
self, source: carla.Transform
) -> Transform:
"""Convert CARLA raw location and rotation to Transform(location,rotation)."""
return Transform(
location=self.convert_location_from_source_to_agent(source=source.location),
rotation=self.convert_rotation_from_source_to_agent(source=source.rotation),
)

To Reproduce

  1. Create a agent transform
  2. Convert it to carla transform using convert_transform_from_agent_to_source
  3. Convert it back to agent transform using convert_transform_from_source_to_agent
  4. The new agent transform is different from the original one

Expected behavior
The original agent transform should be the same thing as the new agent transform (the one converted to carla and converted back)

Desktop (please complete the following information):

  • OS: Windows 11, Carla
@spyeic spyeic added the bug Something isn't working label Aug 26, 2023
@spyeic spyeic linked a pull request Aug 26, 2023 that will close this issue
13 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants