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

No collision effects with NPC vehicle controlled by waypoints following #1802

Open
ZiwenWan opened this issue Oct 8, 2021 · 21 comments
Open
Labels
answered Waiting for response enhancement New feature or request

Comments

@ZiwenWan
Copy link

ZiwenWan commented Oct 8, 2021

Hi,

I recently met some problem when I run the simulation with Apollo 5.0 and SVL (version 2021.2). I controlled a NPC vehicle by setting waypoints. When the collision happens, there is no collision effects in simulation. The assets are the default ones in SVL store (for ego vehicle: Jagur 2015, for NPC vehicle: Sedan).
image

I manually verify that when I drive the ego vehicle manually, the ego vehicle can have collision effects with NPC vehicle. I am wondering whether there are some problems in waypoints following mode such that the collision effect is missing.

Thanks a lot!

@EricBoiseLGSVL
Copy link
Contributor

This is by design. Waypoint mode with the API has collision off. We are looking at possibly changing this.

@EricBoiseLGSVL EricBoiseLGSVL added answered Waiting for response enhancement New feature or request labels Oct 9, 2021
@ZiwenWan
Copy link
Author

ZiwenWan commented Oct 9, 2021

Thanks for the reply. Do you have any idea whether I could change this in the source code? Thanks!

@EricBoiseLGSVL
Copy link
Contributor

No problem. You can comment out this line in NPCWaypointBehaviour.cs but it might have other issues.
image

@ZiwenWan
Copy link
Author

The suggested method can work. Thanks a lot!

@AIasd
Copy link

AIasd commented Dec 12, 2021

@ZiwenWan @EricBoiseLGSVL Hi, I wonder does this also work for the collisions among the NPC vehicles (i.e. the vehicles not controlled by the user and both follow some specified waypoints)? I am following the instruction here and still observe no collision effects between NPC vehicles themselves.

Another related question is about pedestrians. Is there a way to enable their collision effects with other vehicles? Right now they just follow waypoints and "passing through" everything along the way.

@EricBoiseLGSVL
Copy link
Contributor

This should enable, did you make a new binary after altering the above code?

What do you mean collision effects? The pedestrian will not stop moving if hit with NPC or Ego. It will continue to try to walk through the vehicle. API pedestrians are set to kinematic here in PedestrianWaypointBehaviour.cs. You can set that to false but it may cause issues with pathing.
image

Are you needing them to pathfind on collision or rag doll?

@AIasd
Copy link

AIasd commented Dec 14, 2021

Hi @EricBoiseLGSVL ,

Thank you for your reply! I indeed commented out the line of controller.MainCollider.isTrigger = true; and rebuilt the simulator in Unity. However, the passing through among two waypoints following NPC vechiles still happen as shown in the following video:

2021-12-14.13-52-34.mp4

In terms of pedestrian, after I set RB.isKinematic = true; (along with commenting out controller.MainCollider.isTrigger = true;) the passing through still happen as shown in the following video where a pedestrian passing the a school bus:

2021-12-14.14-07-28.mp4

Two possible behaviors for the pedestrians are acceptable: 1.the pedestrian stops if a collision happens (as a rag doll). Something similar to the case in the CARLA simulator as shown below.
ragdolls

2.the pedestrian keeps trying to finish the path but will be blocked (rather than passing through) by the vehicle. When the vehicle moves away, the pedestrian then finishes the original path.

@EricBoiseLGSVL
Copy link
Contributor

How are you adding the NPCs? Are you using API commands?
Videos are great, thanks for posting.
Sorry, collision is not supported with current simulator. You will need to look through the code on how you are spawning the npcs/peds and see where the collider is toggled off or layer changed. We don't have plans to add rag doll or repathing for pedestrians at this time.

@AIasd
Copy link

AIasd commented Dec 14, 2021

Hi @EricBoiseLGSVL ,
Thank you for the reply! Yes, I am using the Python API to add the NPCs.
The relevant lines look like the following

p = sim.add_agent(vehicle_types[vehicle.model], lgsvl.AgentType.NPC, state)
p.follow(wps, False, waypoints_path_type='BezierSpline')

where sim is an lgsvl.Simulator instance and wps is a list of lgsvl.DriveWaypoint.

Regarding pedestrian collider, do you know what files I can potentially look into for that?

@EricBoiseLGSVL
Copy link
Contributor

No problem. Sorry we can't add this feature right now. Look to AddAgent to see where the logic starts for API. Then Pedestrian waypoint behaviour controller and manager. Same for NPC

@AIasd
Copy link

AIasd commented Dec 15, 2021

@EricBoiseLGSVL Thanks for the help! I will look into those then.

@AIasd
Copy link

AIasd commented Dec 16, 2021

Hi @EricBoiseLGSVL ,
I wonder can this be potentially caused by the fact that when I "build from source" following the instruction, I did not build the assets but just copying the AssetBundle folder from the release version(2021.3)? If so, where can I find the source code for the NPC vehicles and pedestrians in order to build these assets?
Thanks!

@AIasd
Copy link

AIasd commented Dec 16, 2021

Actually, I also tried to build the assets and nothing changed so this is probably not the cause. I also tried to use on_collision for the NPC vehicles and pedestrians to try to change their behaviors when they "pass through" each other. However, it seems that the on_collision won't be triggered.

@EricBoiseLGSVL
Copy link
Contributor

Here ya go. Maybe this will solve the issue.
https://github.com/lgsvl/DefaultNPC
https://github.com/lgsvl/Walkers

@AIasd
Copy link

AIasd commented Dec 16, 2021

Hi @EricBoiseLGSVL ,
Thank you for sharing the links! I tried building assets as well but nothing changed so this is probably not the cause.

I also tried to use on_collision for the NPC vehicles and pedestrians to try to change their behaviors when they "pass through" each other. However, it seems that the on_collision won't be triggered.

@EricBoiseLGSVL
Copy link
Contributor

Darn, well you will need to do some significant refactoring to enable this feature change. Walk through the npc initialization and inspect the npc in the unity editor while running to see why the collider is not working. Then you will need to change the on collision to make sure it works with the change to trigger systems.

It worries me that other users have collision after making the change but you are not. I feel something is still not being correctly changed.

@AIasd
Copy link

AIasd commented Jan 4, 2022

@EricBoiseLGSVL Happy New Year! I have a question regarding on_collision. In the 2021.3 official release version, should on_collision defined for an NPC vehicle be triggered for its collision with another NPC vehicle (both are waypoint followers)? I tried this and on_collision is not triggered.

@EricBoiseLGSVL
Copy link
Contributor

OnCollision the method?

@AIasd
Copy link

AIasd commented Jan 4, 2022

OnCollision the method?

Yes

@EricBoiseLGSVL
Copy link
Contributor

EricBoiseLGSVL commented Jan 5, 2022

If you look at NPCController.cs it is the base class for all NPCs. The OnCollision method is only looking for agent layer collision. You will need to add a check for the NPCs or peds.

void OnCollisionEnter(Collision collision)
    {
        if (collision.gameObject.layer == agentLayer)
        {
            ApiManager.Instance?.AddCollision(gameObject, collision.gameObject, collision);
            SimulatorManager.Instance.AnalysisManager.IncrementNPCCollision();
            ActiveBehaviour?.OnAgentCollision(collision.gameObject);
        }
    }

you can also see that this method calls the active behaviour OnAgentCollision method. In NPCWaypointBehaviour there is a todo. You will need to copy NPCLaneFollowBehaviour code or add your own.

NPCLaneFollowBehaviour

public override void OnAgentCollision(GameObject go)
    {
        isForcedStop = true;
        controller.SetNPCHazards(true);
    }

NPCWaypointBehaviour

public override void OnAgentCollision(GameObject go)
    {
        // TODO
    }

@AIasd
Copy link

AIasd commented Jan 7, 2022

Hi @EricBoiseLGSVL thanks a lot! this is very helpful!

I also realized that I did not comment out rb.isKinematic = true; for NPCWaypointBehaviour which caused that OnCollisionEnter was not entered.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
answered Waiting for response enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

3 participants