Robot position calculation

I made a little simulation for team 36/39 to show how the position and angle of the robot can be calculated on a H drive, the side wheel is assumed to be at the center of gravity so it doesn’t swerve
using this data you can find the yaw to launch at the net



ill go into detail on the math behind it later and maby post the source code of the simulation

how did you make the simulation? did you use a certain program?

i used love2d which uses Lua, it can be ported to C easily though
all the physics and angles are calculated manually

This is awesome! I’m very much looking forward to seeing actual robots perform this sort of magic on the field this year. This year’s game looks like a programmer’s dream come true. :slight_smile:

Reminds me of a favorite game from my mis-spent youth.
http://tartley.com/wp-content/uploads/2007/05/800px-arcade-atari-battlezone1.png

1 Like

ill show a demo with a real robot soon™ (when i get my robot back)

I made the launcher calculation compensate for the robot’s speed
orange is the new calculation and gray is the old

This…:D…is…:D…amazing.

Looks like I should have paid better attention in math classes when I was young. Good golly. Please release an instructional about how you did this. I would love to learn.

Please warn me before you do this so I can have a mop bucket available to clean up all my drool.

That’s one of the coolest things I’ve seen on this forum. What sort of ball launcher are you modeling in this? A flywheel type?

it works for any type of launcher (now atleast), all you need to know how long it will take for the ball to reach the goal

Yes. I don’t want to give away too much about it just yet. I will be updating our team Youtube channel quite frequently come summer and I may post some of the fun things I’ve been working on (like Pentapistons). But you will definitely see this simulation run with a real robot soon. (Yeah, I’m the one who has his robot;))

I’ll have the real robot ready for a summer reveal. Yours will soon fall to my new beast. :smiley:

I’m intrigued to see this in action at the MI summer games.
It looks to me like implementing this to its fullest potential on a robot would require your launching system to be on a turntable of some kind and have a bit of vertical angle change. Are you concerned about motor usage?

I know which pit tables I’m visiting first in August. :slight_smile:

Absolutely not. I have been working my secret technique for this particular purpose.

In the simulation are you simulating tracking the robot thru simulated encoders/accelerometers/gyros or just getting the absolute position of it automatically?

it takes simulated encoder values and calculates the position and angle of a robot automatically, this can easily be used on a real robot to calculate the position

Here is the full video of our simulation. It is longer and much more detailed (although the resolution is questionable.)

its 3D now

the ball trajectory is linear right now, but 3D is pretty much essential to find the pitch to launch at

if you wouldn’t mind me asking how did you calculate the launcher angle?

the launcher yaw is calculated by subtracting the by the net’s position by the time it takes for the ball to reach the net times the robot’s velocity
then calculate the angle from the robot to that position using atan2


launcher.yaw=atan2((net.x-(robot.xvel*projectile.time))-robot.x,(net.y-(robot.yvel*projectile.time))-robot.y)

currently the projectile’s trajectory is linear so projectile.time is calculated like so:


projectile.time=sqrt(abs(net.x-robot.x)^2+abs(net.y-robot.y)^2+math.abs(net.z-robot.z)^2)/projectile.speed

(^ being power, not xor like in C)

Thanks! :smiley: I managed to figure out how to calculate x and y but was having trouble calculating the launcher yaw. How are you calculating velocity?