PythonAPI icon indicating copy to clipboard operation
PythonAPI copied to clipboard

When I use waypoints in pythonAPI, the physical collision attribute of NPC is lost

Open Gump0116 opened this issue 4 years ago • 1 comments

image

Here is my code !!!!!

#!/usr/bin/env python3
#

from environs import Env
import lgsvl
import os

env = Env()

def on_waypoint(agent, index):
    print("waypoint {} reached".format(index))

sim = lgsvl.Simulator(env.str("LGSVL__SIMULATOR_HOST", "127.0.0.1"), env.int("LGSVL__SIMULATOR_PORT", 8181))
if sim.current_scene == "BorregasAve":
    sim.reset()
else:
    sim.load("BorregasAve")

spawns = sim.get_spawn()

state = lgsvl.AgentState()
state.transform = spawns[0]

for spawn in sim.get_spawn():
    print(spawn)

#state.transform.position = lgsvl.Vector(3.07,0,-87.25)
forward = lgsvl.utils.transform_to_forward(spawns[0])
right = lgsvl.utils.transform_to_right(spawns[0])

state.velocity.x = -5
state.transform.position = lgsvl.Vector(20,0,5.5)
state.transform.rotation.y = 270

ego = sim.add_agent(env.str("LGSVL__VEHICLE_0", "Lincoln2017MKZ (Apollo 5.0)"), lgsvl.AgentType.EGO, state)

state.transform.position = lgsvl.Vector(10,0,5.5)
state.transform.rotation.y = 270

state.velocity.x = -7

npc1= sim.add_agent("BoxTruck",lgsvl.AgentType.NPC,state)

waypoints=[
    lgsvl.DriveWaypoint(lgsvl.Vector(-5,-2,5.5), 4, lgsvl.Vector(0, 270, 0)),
    lgsvl.DriveWaypoint(lgsvl.Vector(-3,-2,5.5), 3, lgsvl.Vector(0, 270, 0)),
    lgsvl.DriveWaypoint(lgsvl.Vector(-2,-2,5.5), 2, lgsvl.Vector(0, 270, 0)),
    lgsvl.DriveWaypoint(lgsvl.Vector(-1,-2,5.5), 1, lgsvl.Vector(0, 270, 0)),

]

npc1.on_waypoint_reached(on_waypoint)
npc1.follow(waypoints)

# ego.connect_bridge(os.environ.get("BRIDGE_HOST", "192.168.137.3"), 9090)

sim.run()

# sim.run(time_limit=1.0)

Gump0116 avatar Feb 01 '21 15:02 Gump0116

Hi @Gump0116 . Can you explain a bit more what you mean by "physical collision attribute"? When NPC's operate in waypoint mode they do not actually collide with anything (they will drive through objects). However, the collision will be detected by the collision callback.

hadiTab avatar Feb 12 '21 22:02 hadiTab