Dismiss Notice
Join Physics Forums Today!
The friendliest, high quality science and math community on the planet! Everyone who loves science is here!

Homework Help: Programming a robot for a contest

  1. May 3, 2005 #1

    eax

    User Avatar

    I am programming a robots movements(virtual robot not a physical, like a game) its a contest, I asked last year students that did this contest and there robot got to 4th place by a fluke, their robot did random stuff :rofl:. I'm in highschool grade 11. University students are also partisipating in this event, last year their robot shot ahead of other robots. Thats what I want to do.

    I know the obsolute position of my own robot(lets call my robot R for Robo) and its rotation, also its rotation of stuff like gun, and radar for detecting other robots. If the R detects another robot, R only knows the distance between R and the robot, and the degrees it would have to turn to face the robot. So I need to convert this to obsolute coordinates so when R moves around it can look where it last scene the robot.

    If I can get the obsolute coordinates of the enemy robot, its all I need for my plan to shoot ahead of its path. I already tested this plan out and it works good if R is just standing still and not moving. How may I get obsolute coordinates of the enemy robot?

    I tryed doing this my self but R is rotated so I cant just add obsolute coordinates of R to enemy robots. I'm lost I don't know how to do this.

    Thanks in advance!
     
    Last edited: May 3, 2005
  2. jcsd
  3. May 3, 2005 #2

    OlderDan

    User Avatar
    Science Advisor
    Homework Helper

    R's position is (x,y) (known) and he is facing in direction A (known) relative to the reference, which I will assume is the +x axis. The second robot R2 is a distance D2 (R2D2; cute heh :rolleyes: ) from R in a direction B from the direction R is facing.

    Let R turn B to face R2. R will know the direction (A+B) he is facing relative to the +x axis after this turn. The position of R2 is then (x+D2cos(A+B), y+D2sin(A+B))
     
  4. May 4, 2005 #3

    eax

    User Avatar

    Thanks!

    I have one problem, I tryed my self using sign, I even made if statements for different quadrants on the plane for this.

    I have after movement converted R2 to be relative to R now I need to get the angle to move the gun on it. 0 degrees is up, I can't seem to get it to aim properly. I have worked with something similar before but 0 degrees was right.

    Knowing 0 degrees is up, lets say after converting R2 relative to R the R2(x,y) lay in the bottom left quadrant where x & y are negative. How may I calculate the angle there,

    Iam doing this
    angle = acos(-R2(x)/R2(distance from R))
    since R2(x) is negative I make the whole thing be positive.
    angle = angle + 90
    I added by 90 for bottom quadrant
    angle = angle * -1
    I inverse it for other quadrant

    It doesn't work properly. Whats wrong?

    Thanks in advance!
     
Share this great discussion with others via Reddit, Google+, Twitter, or Facebook