lgsvl / simulator

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

How does the random traffic mode realize? #1518

Open ssbse2021 opened 3 years ago

ssbse2021 commented 3 years ago

Hello team,

Recently i want to realize a similar function just like random traffic. More specifically, I want to add NPC or pedestrian to the environment with a specific position and let them move at a predefined behavior. But when i follow the example of 12-create-npc-on-lane.pyor 14-create-pedestrians.py, sometimes the NPC or pedestrian will be added out of road or two NPCs appear in a same position and collide with each other which are not conform to reality, after checking the example of 29-add-random-agents.py, i found the following api can add NPCs and pedestrians in real,

sim.add_random_agents(lgsvl.AgentType.NPC)
sim.add_random_agents(lgsvl.AgentType.PEDESTRIAN)

After checking the source code of these two apis, i found it send a socket command to contorl the generation of random agents but i still can not know the underlying principle, can anyone give me a more specific explain of that?

EricBoiseLGSVL commented 3 years ago

@ssbse2021 sorry that our documentation is not clear on this. We added random agent support in API mode with these calls. These agents don't support control, only the ones you specifically place in a simulation. You should be able to place pedestrians and npcs exactly where you specify in your .py file. Is this not happening? Are you placing the agent on the nav mesh and setting the waypoints?