lgsvl / simulator

A ROS/ROS2 Multi-robot Simulator for Autonomous Vehicles
Other
2.29k stars 781 forks source link

How to get the position and rotation vector of selected point in the map? #1305

Open ideasplus opened 3 years ago

ideasplus commented 3 years ago

Hi, I want to know how to get the coordinate vector and the desired direction vector of selected point in the map when spawning car at this position, like lgsvl.Vector(-7.67, 0.2, 6.299) and lgsvl.Vector(0, 180, 0)?

EricBoiseLGSVL commented 3 years ago

@ideasplus You can run the simulator in Editor and set debug logs when the agent is added or create a sensor plugin that will output this data to the visualizer.

ideasplus commented 3 years ago

@ideasplus You can run the simulator in Editor and set debug logs when the agent is added or create a sensor plugin that will output this data to the visualizer.

Thank you for your reply! I am not familiar with Unity Editor, Can you give me some more detailed steps and explanation? I have installed Unity 2019.3.3f1 and build the Simulator according to the tutorial.

EricBoiseLGSVL commented 3 years ago

No problem, glad to help.

What simulator version are you using? 06 release MUST be Unity 2019.3.15f1 2021.1 release MUST be Unity 2019.4.18f1 Latest documentation is for 2021.1

As for Unity help: First way: As for the code you will need to add Debug.Log(Data you want); So in AddAgent, add the code to calculate what data you want and then Debug.Log to Unity Console Panel. You will need to make a new binary of simulator.

Second way: Create a new sensor (Copy a simple one like KeyboardControlSensor), DO NOT use the same name for the class, Add new functionality to get all NPCs in scene and on a keypress display data you want in the visualizer method or again with debug. You can create any functionality you want with this sensor. Just be sure to add the sensor to the vehicle sensor config. Again, see the keyboard sensor as an example.

If you need custom data/behavior with simulator, be sure to watch some tutorial videos on Unity. This will help immensely when first altering simulator.