AirSim icon indicating copy to clipboard operation
AirSim copied to clipboard

has_collided not updated

Open niknil702 opened this issue 8 years ago • 6 comments

When collision occurs the has_collided sometimes remains set to False even though the values of for example the impact_point vector is updated. The below shows two readings of collision_info, the first one before any collision and the second one after the first collision.

` { 'has_collided': False, 'impact_point': { 'x_val': 0.0, 'y_val': 0.0, 'z_val': 0.0}, 'normal': { 'x_val': 0.0, 'y_val': 0.0, 'z_val': 0.0}, 'object_id': -1, 'object_name': '', 'penetration_depth': 0.0, 'position': { 'x_val': 0.0, 'y_val': 0.0, 'z_val': 0.0}, 'time_stamp': 0}

{ 'has_collided': False, 'impact_point': { 'x_val': 7.556523323059082, 'y_val': -3.422746419906616, 'z_val': -4.774749755859375}, 'normal': { 'x_val': -2.086162567138672e-06, 'y_val': 0.9999998807907104, 'z_val': 0.0}, 'object_id': 181, 'object_name': 'wall3', 'penetration_depth': 9.999999974752427e-07, 'position': { 'x_val': 7.556523323059082, 'y_val': -3.422746419906616, 'z_val': -4.774749755859375}, 'time_stamp': 1524477282691448320} `

niknil702 avatar Apr 23 '18 10:04 niknil702

I think maybe when there is no collision detected ('has_collided': False), then the data of 'impact_point', 'normal', 'penetration_depth' is random generated and they are not true data .

husha1993 avatar Apr 23 '18 19:04 husha1993

The collision seems to be detected because in UE the collision count increases.

Additionally, if I reset the episode based on changes in any other value (e.g. y_val), the collision count in UE never goes above 1. If I wait for has_collided to become true the collision count can sometimes reach 30 before reset. So there seems to be a delay before has_collided is updated.

niknil702 avatar Apr 24 '18 07:04 niknil702

Hi @niknil702 ,

I meet the same issue when I use ('has_collided'), which cannot return False when meet the collision immediately, till now have you sorted out this issue? or any solutions you take to collect the collision information?

Hoshea7 avatar Aug 01 '19 10:08 Hoshea7

Hi @niknil702 ,

I meet the same issue when I use ('has_collided'), which cannot return False when meet the collision immediately, till now have you sorted out this issue? or any solutions you take to collect the collision information?

Yes, my workaround was to look at the timestamp instead. I kept track of the last timestamp and considered it a collision if the timestamp changed. Timestamp field seems reliable.

niknil702 avatar Aug 06 '19 12:08 niknil702

for me, impact_point and position are always changing, even without any collision. but for normal it always change when my agent hit the obstacle.

take a look at my answer at this issue #1986

riyadfebrian avatar Dec 21 '21 14:12 riyadfebrian

I did some testing locally with the simGetCollisionInfo() and I do see collision_info.has_collided get set to true, but it gets reset to false in PawnSimApi::setPoseInternal, so it looks like the true value can only be read in the clock tick immediately after a collision: if any more time elapses between a collsion and a call to simGetCollisionInfo(), you will read collision_info.has_collided after it has reset to false. It's possible this behavior can be changed to only reset collision_info.has_collided after a call to simGetCollisionInfo(), but some testing will need to be done to see if this is a safe change because this variable is being checked elsewhere in PawnSimApi::canTeleportWhileMove(), so there may some unintended consequences to making a change like this.

zimmy87 avatar Dec 22 '21 10:12 zimmy87