# Programming a robot for a contest

• eax
In summary, the programmer wants to know how to get the coordinates of an enemy robot so they can shoot ahead of its path. They tried doing it themselves, but it didn't work properly. They need to know how to calculate the angle to move the gun on their robot.
eax
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 . 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:
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 ) 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!

## What is the purpose of programming a robot for a contest?

The purpose of programming a robot for a contest is to make it perform a specific task or series of tasks autonomously. This allows the robot to compete against other robots and demonstrate its capabilities.

## What programming languages are commonly used for programming a robot for a contest?

Some common programming languages for programming a robot for a contest include C++, Python, Java, and LabVIEW. The specific language used may depend on the type of robot and the requirements of the contest.

## How do you ensure the robot's programming is accurate and efficient?

To ensure accuracy and efficiency, the robot's programming must be thoroughly tested and debugged. This may involve running simulations, performing trial runs, and making adjustments as needed. It is also important to have a clear understanding of the contest rules and objectives to ensure the programming aligns with them.

## What are some key considerations when programming a robot for a contest?

When programming a robot for a contest, it is important to consider factors such as the robot's capabilities and limitations, the objectives of the contest, and the time constraints. It may also be necessary to consider the environment in which the contest will take place, as this can impact the robot's performance.

## What skills are needed to successfully program a robot for a contest?

Programming a robot for a contest requires a strong understanding of programming concepts and techniques, as well as knowledge of the specific programming language being used. It also requires problem-solving skills, attention to detail, and the ability to work under pressure. Additionally, familiarity with robotics and the specific type of robot being programmed can be beneficial.

### Similar threads

• General Discussion
Replies
3
Views
697
• DIY Projects
Replies
4
Views
2K
• Engineering and Comp Sci Homework Help
Replies
4
Views
1K
• Programming and Computer Science
Replies
1
Views
2K
• Engineering and Comp Sci Homework Help
Replies
9
Views
2K
• STEM Academic Advising
Replies
9
Views
1K
• DIY Projects
Replies
4
Views
2K
• General Discussion
Replies
5
Views
990
• STEM Career Guidance
Replies
4
Views
1K
• STEM Career Guidance
Replies
2
Views
2K