Carla: How can I get the real time location and categories of objects in the Uworld?

Created on 24 May 2018  ·  4Comments  ·  Source: carla-simulator/carla


I want to get the real time location and categories of objects in the Uworld to train my algorithm,but I don't know how to get the information.Is there a function to acquire it?

question

Most helpful comment

Hi @zhangfree2018 ,
are you looking for something like this?

measurements.player_measurements.transform.orientation.x
measurements.player_measurements.transform.orientation.y
measurements.player_measurements.transform.orientation.z

It's marked as deprecated, while instead of orientation (Vector3D) the rotation (Rotation3D, pitch/roll/yaw) should be used. You can simply print it to the screen/console (like in client_example.py) or dump it to a .txt file:

message = 'Orientation: ({rot_x:.1f}, {rot_y:.1f}, {rot_z:.1f})'
message = message.format(
    rot_x=measurements.player_measurements.transform.orientation.x,
    rot_y=measurements.player_measurements.transform.orientation.y,
    rot_z=measurements.player_measurements.transform.orientation.z)
with open("_out/orientation.txt", "a") as text_file:
    text_file.write(message)
    text_file.close()

I do this inside the print_measurements() function of the client_example.py. I hope this is helping you.

All 4 comments

Hi @Super-Tree,

Please read the documentation and take a look at the well commented examples that we provide in our repo, like client_example.py.

https://github.com/carla-simulator/carla/blob/998e2421c9dde806e9bef7c5d140238606d267cf/PythonClient/client_example.py#L159

non_player_agents contains a list with all this information. On the Measurements section of our documentation you will find more information.

Hi @marcgpuig ,
How can I get player_agents's movement orientation that the simulator displayed on lower left?
As follows:
Orientation: (x,y,z)

Hi @zhangfree2018 ,
are you looking for something like this?

measurements.player_measurements.transform.orientation.x
measurements.player_measurements.transform.orientation.y
measurements.player_measurements.transform.orientation.z

It's marked as deprecated, while instead of orientation (Vector3D) the rotation (Rotation3D, pitch/roll/yaw) should be used. You can simply print it to the screen/console (like in client_example.py) or dump it to a .txt file:

message = 'Orientation: ({rot_x:.1f}, {rot_y:.1f}, {rot_z:.1f})'
message = message.format(
    rot_x=measurements.player_measurements.transform.orientation.x,
    rot_y=measurements.player_measurements.transform.orientation.y,
    rot_z=measurements.player_measurements.transform.orientation.z)
with open("_out/orientation.txt", "a") as text_file:
    text_file.write(message)
    text_file.close()

I do this inside the print_measurements() function of the client_example.py. I hope this is helping you.

Hi @p-schulz ,
Thanks for your help! I have got orientation by your explanation.

Was this page helpful?
0 / 5 - 0 ratings