Menu

#377 possible issue with checkRobotCollision

Future Release
closed
4
2023-02-26
2015-11-08
No

Greetings,
I'm trying to figure out an issue I'm having while checking for collisions in my robot code. I have had a look at the source code and think I understand it fairly well, so if my test is valid then I think I could even describe the issue. I'm going to assume that this is the case and say it in words first:
My tank is moving in the (general) right direction and so is the enemy's. Only he is moving faster. At t=30 there is no collision. At t=31 the two tanks intersect. As I understand it- a random enemy is selected to move first- so let's assume that my tank moves first- still going right, checks for collisions(with enemy at t=30) and correctly finds none. Now the enemy moves- checks for collisions(with us at t=31) and finds that the tanks intersect. However the collision angle is found to be 92 degrees(in my case) so the tank is cosidered to be moving away so no collision at t=31..Had it been the enemy that's picked in the above draw- then no issue.
Now here are the numbers. Please keep in mind that these might not be 100% accurate(but I believe they are close).
t=30
us: x=134.45025098314335(x_right=152.45025098314335), y=426.38877213922046, v=-3.8078486034815286, h=2.609524471367071(149.51)
other: x=173.56235848421312(x_left=155.56235848421312), y=404.66258717661003, v=8.0, h=3.8131960807874643(218.48)
d(us,other) = 44.741301570303 (intersects=false)
ourBearing = -0.5316957180460498 (-30.46)
otherBearing = 1.4062253261233506 (80.57)

t=31
us: x=133.5330992970147(x_right=151.5330992970147), y=427.9467044603125, v=-1.8078486034815286, h=2.609524471367071(149.51)
other: x=168.63216745062928(x_left=150.63216745062928), y=398.362329658827, v=8.0, h=3.8055951275319826(218.04)
d(us,other) = 45.90402833790138 (intersects=true)
ourBearing = -0.3383745199352166 (-19.38)
otherBearing = 1.607147477489665 (92.08)
{
angle = atan2(other.x - us.x, other.y - us.y) = -0.8704532501270366
movedx = velocity * sin(other.heading) = -4.930191033583835
movedy = velocity * cos(other.heading) = -6.300257517783026
bearing = 1.6071369295205669 ((92.08- not using FastMath this time- hence the small difference)
would_be_x = 173.56235848421312 (x_left=155.56235848421312)
would_be_y = 404.66258717661003
}

d(us(30),us(31))=1.807849643214792(~=v)
d(other(30),other(31))=8.000001776125576(~=v)

Discussion

  • Galin LIPCHEV

    Galin LIPCHEV - 2015-11-08

    Oops, sorry didn't mean to post it here. And also I meant 'left' direction :)

     
  • Galin LIPCHEV

    Galin LIPCHEV - 2015-11-08

    And here is an afterthought: what if we had two robots going straight for each other(axis aligned) at full speed- and say that at t=30 their distance is between 44 & 52 (sides at distances between 8 and 16). At t=31 the tanks would be in a collision- however only the tank that moves second would raise an event(stating that it's his fault). Meanwhile if the tanks were to be at a distance between 36 & 44 at t=30 then each of them would raise an event (hence twice the damage taken).

     
  • Flemming N. Larsen

    • status: open --> closed
     

Log in to post a comment.