lgsvl / simulator

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

Missing Pedestrian NavMesh #1427

Open duongtran11 opened 3 years ago

duongtran11 commented 3 years ago

When I hit the play button I got an error "missing Pedestrian NavMesh" and no pedestrian appeared. đà

I did bake the NavMesh, you can see it in the picture above. I can't find answer anywhere, it seems like a really simple problem though

EricBoiseLGSVL commented 3 years ago

This is an issue we have been working on. Simulator raycasts to 0,0,0 or to the first spawninfo objects position to see if it can find a nav mesh because unity doesn't have an api to just check the bundle. You can move the spawn position over a nav mesh or comment out this code until Unity creates this api/we find a better solution.

PedestrianManager.cs line 167

if (NavMesh.SamplePosition(pt, out NavMeshHit hit, 1f, NavMesh.AllAreas))
{
    if (!SimulatorManager.Instance.IsAPI && !Loader.Instance.Network.IsClient)
    {
        var pool = SpawnPedPool();
        if (pool != null)
        {
            if (PedestriansActive)
            {
                SetPedOnMap(true);
            }
        }
        else
        {
            Debug.Log("No pedestrian pool, disabled pedestrian manager ");
            gameObject.SetActive(false);
        }
    }
}
else
{
    var sceneName = SceneManager.GetActiveScene().name;
    Debug.LogWarning($"{sceneName} missing NavMesh at {pt} please create navmesh at this point. Pedestrian manager disabled");
    gameObject.SetActive(false);
}
duongtran11 commented 3 years ago

The thing is it used to work. I didn't have this error until I change the MapOrigin easting and northing coordinates. but the transform positions of MapOrigin remain 0 0 0 Do you recommend comment out the above block of code or just line 167? If comment out the above block of code then I couldn't spawn pedestrians right?

EricBoiseLGSVL commented 3 years ago

Ok let's look at SpawnInfo object in the scene. Is this object just above the nav mesh? If not, do this. Many times users have it below the ground or are missing a collider/tag. Last resort you can comment out the code and just call SpawnPedPool()

EricBoiseLGSVL commented 3 years ago

Also, what sensors are you using? If your sensors "see" the peds then they won't spawn unless you change settings in MapOrigin. There you can set values to ignore this check. Can you screen shot your map origin object?

duongtran11 commented 3 years ago

2021-05-20_103246 2021-05-20_103328 2021-05-20_103533 I did try it. Doesn't work. Double checked, the ground has mesh collider You can see in the picture above I don't have any sensor 2021-05-20_105226 and this is MapOrigin

duongtran11 commented 3 years ago

Alright, I figure it out. Inked2021-05-20_180225_LI The marked parameter in the picture is maximum distance from the spawn position. It was 1 meter back then. Any number bigger than 3 meters should works. Can't explain why is it so for now, just document it here

EricBoiseLGSVL commented 3 years ago

That is very odd that it would need >3. We'll look into this.

duongtran11 commented 3 years ago

FYI, when I set the maximum distance to 1 meter and output position of the NavMeshHit to console: `if (Loader.Instance.Network.IsClient) { return; }

    if (NavMesh.SamplePosition(pt, out NavMeshHit hit, 3f, NavMesh.AllAreas))
    {
        if (!SimulatorManager.Instance.IsAPI && !Loader.Instance.Network.IsClient)
        {
            Debug.Log("NavMeshHit position: " + hit.position);
            SpawnPedPool();
            if (PedestriansActive)
                SetPedOnMap(true);
        }
    }
    else
    {
        Debug.Log("NavMeshHit position: " + hit.position);
        var sceneName = SceneManager.GetActiveScene().name;
        Debug.LogError($"{sceneName} is missing Pedestrian NavMesh");
        gameObject.SetActive(false);
    }`

then position turn out: Screenshot from 2021-05-21 09-04-42

and when I set it to 3 meters it turns out: Screenshot from 2021-05-21 09-07-32