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

Fix issues with collided vehicle not being detected #1924

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

emocat
Copy link

@emocat emocat commented Dec 20, 2021

When on_collision is set on the ego vehicle and it collides with a npc, we notice that Python API returns NULL through the ws socket with lgsvl:

{"result":{"events":[{"type":"collision","agent":"eb657a86-0d2a-4bd5-9d91-184469100ee7","other":null,"contact":{"x":107.696556091309,"y":0.237456381320953,"z":32.5612945556641}}]}}

Obviously that other object in AddCollision() is not corresponded with added agent objects before:

public void AddCollision(GameObject obj, GameObject other, Collision collision = null)
{
if (!Collisions.Contains(obj) || (collision != null && collision.gameObject.layer == roadLayer))
{
return;
}
string uid1, uid2;
if (AgentUID.TryGetValue(obj, out uid1))
{
var j = new JSONObject();
j.Add("type", new JSONString("collision"));
j.Add("agent", new JSONString(uid1));
if (AgentUID.TryGetValue(other, out uid2))
{
j.Add("other", new JSONString(uid2));
}
else
{
j.Add("other", JSONNull.CreateOrGet());
}

We notice implementation of OnTriggerEnter in VehicleController.cs is a bit different from that in NPCController.cs. After modifying collision.gameObject to collision.attachedRigidbody.gameObject, the collided vehicles can be successfully resolved.

@CLAassistant
Copy link

CLAassistant commented Dec 20, 2021

CLA assistant check
All committers have signed the CLA.

@emocat emocat changed the title Fix issues with collision vehicle not being detected Fix issues with collided vehicle not being detected Dec 20, 2021
@xli149
Copy link

xli149 commented May 23, 2022

Hi emocat,

I've made the change as you suggested and run random-traffic-local through the Python API. However, the return value is still None for collision npcs. Could you give any suggestions?
@emocat
Best,
Chris

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

Successfully merging this pull request may close these issues.

None yet

3 participants