Shop OBEX P1 Docs P2 Docs Learn Events
angle of rotation to reach goal — Parallax Forums

angle of rotation to reach goal

RozaRoza Posts: 11
edited 2013-11-04 20:18 in Robotics
I am working on to drive Eddie toward the goal in simulated Reference platform robot 2011. My problem is how to calculate the angle of rotation that is required to face the goal. For example if the initial position of eddie is (4, 0.003, 8.3) with orientation (0,0,0) and the goal position (tv stand) is (9.582, 0.204,14.227) in simulation environment, then how much rotation is needed for desired heading to the goal?
Pls help me in solving the problem.

Comments

  • Duane DegnDuane Degn Posts: 10,588
    edited 2013-11-03 14:15
    I'm not very familiar with Eddie but I like to think I'm pretty good at trig and I'd be glad to offer some help if I can. What I don't understand is the coordinates appear to be for 3D space while Eddie is a 2D robot. Can the last component of the coordinates be ignored?

    What sort of number is the orientation? Does (0, 0, 0) represent a heading vector?
  • RozaRoza Posts: 11
    edited 2013-11-03 17:28
    I think it is a heading vector. Still couldn't figure out how to calculate the rotation angle needed to face the goal.
    Thank you
  • Duane DegnDuane Degn Posts: 10,588
    edited 2013-11-03 18:05
    Roza wrote: »
    I think it is a heading vector. Still couldn't figure out how to calculate the rotation angle needed to face the goal.
    Thank you

    To compute an angle from coordinates one uses the arctangent function. The arctangent function (theta = atan(y/x)) will return an angle between -pi/2 and pi/2. Many computer programs and programming languages have an Atan2 function which will return a result between -pi and pi (or sometime the return value will be between 0 and 2*pi).

    This assumes the points are in two dimensional space. For rotations in three dimensional space the calculations quickly become very complicated. To calculate rotations in 3D space you either need to use rotation matrices or quaternions (there may be other alternatives I'm not familiar with).

    The difference in the ways angles are calculated in 2D space vs 3D space is why I asked:
    Duane Degn wrote: »
    What I don't understand is the coordinates appear to be for 3D space while Eddie is a 2D robot. Can the last component of the coordinates be ignored?

    Whether or not you need to calculate angles in 2D space or 3D space is an important detail. I would think since the Eddie robot can't fly, 2D calculations would be sufficient.
  • RozaRoza Posts: 11
    edited 2013-11-03 23:46
    I did this. But the angle is around 2 deg. But seeing the simulation environment it should be around 200 deg
  • Duane DegnDuane Degn Posts: 10,588
    edited 2013-11-04 07:56
    Roza wrote: »
    I did this. But the angle is around 2 deg. But seeing the simulation environment it should be around 200 deg

    When I punch the numbers into a calculator I get 2.06 degrees. This seems correct since the TV stand and the Eddie are very close to the y axis.

    From the numbers you gave, it appears the Eddie starts out pointing almost right at the TV stand.

    Is this not what you see? Can you use the snipping tool (a Windows program) and capture the screen image?
  • RozaRoza Posts: 11
    edited 2013-11-04 17:04
    original.jpg
    afterRotation2.06.jpg
    desired.jpg

    The first one is the original environment, 2nd is after the rotation (2.06 deg), next one is what I want. Here goal is tvstand which is just behind the black sofa
    Thank you
    1024 x 530 - 49K
    1024 x 528 - 46K
    1024 x 529 - 48K
  • Duane DegnDuane Degn Posts: 10,588
    edited 2013-11-04 20:18
    Roza wrote: »
    The first one is the original environment, 2nd is after the rotation (2.06 deg), next one is what I want. Here goal is tvstand which is just behind the black sofa
    Thank you

    Well this doesn't make sense to me. I'm inclined to think the robot's direction has been defined incorrectly. The most likely error would be the rear of the robot was defined as the front but your third picture doesn't look like the robot is pointed at 182.06 degrees so I'm not sure about that.

    I think I'm running out of ideas. Maybe someone else on the forum has some experience with this software?
Sign In or Register to comment.