Programming a robot for a contest

Click For Summary
SUMMARY

The discussion revolves around programming a virtual robot, referred to as R, for a contest where it competes against other robots. The user seeks to calculate the absolute coordinates of an enemy robot (R2) based on R's known position and orientation. The user has successfully derived R2's position using trigonometric functions but struggles with calculating the correct angle for R's gun to aim at R2, particularly when R2 is in the negative quadrants. The user employs the cosine function and attempts to adjust the angle based on quadrant positioning but encounters inaccuracies in the aiming calculations.

PREREQUISITES
  • Understanding of trigonometric functions, specifically cosine and sine.
  • Familiarity with coordinate systems and absolute positioning.
  • Basic programming skills for implementing algorithms in a robot control context.
  • Knowledge of angle measurement and quadrant identification in a Cartesian plane.
NEXT STEPS
  • Research "trigonometric angle conversion in programming" to refine angle calculations.
  • Explore "robot navigation algorithms" to improve movement and targeting accuracy.
  • Learn about "coordinate transformation techniques" for better handling of relative positions.
  • Investigate "quadrant-specific angle adjustments" to enhance aiming logic for the robot's gun.
USEFUL FOR

This discussion is beneficial for high school students, robotics enthusiasts, and programmers interested in developing algorithms for robot navigation and targeting systems in competitive environments.

eax
Messages
61
Reaction score
0
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 :smile:. I'm in high school 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 can't 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:
Physics news on Phys.org
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))
 
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, let's 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!
 

Similar threads

  • · Replies 4 ·
Replies
4
Views
1K
  • · Replies 3 ·
Replies
3
Views
1K
  • · Replies 5 ·
Replies
5
Views
2K
  • · Replies 1 ·
Replies
1
Views
2K
  • · Replies 7 ·
Replies
7
Views
4K
  • · Replies 4 ·
Replies
4
Views
3K
Replies
4
Views
3K
  • · Replies 1 ·
Replies
1
Views
5K
  • · Replies 9 ·
Replies
9
Views
3K
  • · Replies 9 ·
Replies
9
Views
3K