lgsvl / simulator

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

NPCs float in the air when using VSE waypoint #2126

Open umdreamer opened 1 year ago

umdreamer commented 1 year ago

The NPC gets through the house wall and floats in the air until it gets down the ground. I have add NPCWaypointBehaviour.cs at line 101 to add rb.useGravity = true to get Gravity, but it doesn't work. The waypoints are from ground then to the house roof, and then to the ground. It looks that the NPC just follow the line between two waypoints ignoring any obstacles in on the way.

Any helps?

private void InitNPC()
    {
        Debug.Assert(LaneData != null);
        rb.isKinematic = false;
        rb.useGravity = true;
        controller.MainCollider.isTrigger = true;

image

YuqiHuai commented 1 year ago

I have some information that might help,

  1. Looks like you are trying to make sure the vehicle is on the ground. I am not familiar with useGravity, but I know how to set a waypoint that is on the ground by using raycast

    state = lgsvl.AgentState()
    state.transform = transform
    hit = sim.raycast(state.position, lgsvl.Vector(0, -1, 0), layer_mask)
    state.transform.position = hit.point
    return state
  2. https://github.com/lgsvl/simulator/issues/1802 this issue might be helpful.