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

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

Open
Gump0116 opened this issue Feb 1, 2021 · 1 comment

Comments

@Gump0116
Copy link

Gump0116 commented Feb 1, 2021

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)
@hadiTab
Copy link
Contributor

hadiTab commented Feb 12, 2021

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants