Open ZiwenWan opened 2 years ago
This is by design. Waypoint mode with the API has collision off. We are looking at possibly changing this.
Thanks for the reply. Do you have any idea whether I could change this in the source code? Thanks!
No problem. You can comment out this line in NPCWaypointBehaviour.cs but it might have other issues.
The suggested method can work. Thanks a lot!
@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.
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.
Are you needing them to pathfind on collision or rag doll?
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:
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:
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.
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.
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.
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?
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
@EricBoiseLGSVL Thanks for the help! I will look into those then.
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!
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.
Here ya go. Maybe this will solve the issue. https://github.com/lgsvl/DefaultNPC https://github.com/lgsvl/Walkers
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.
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.
@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.
OnCollision the method?
OnCollision the method?
Yes
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
}
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.
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](https://user-images.githubusercontent.com/38177263/136632850-d47eb162-2333-4dc9-a28d-422efe572d7c.png)
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!