|
|
|
![]() |
|
|||||||
|
||||||||
![]() |
|
|
Thread Tools | Rate Thread | Display Modes |
|
|
|
#1
|
||||
|
||||
|
Finding the position of the robot
I'm trying to find out the angle a robot (holonomic) is traveling relative to the side walls of the field. I'm pretty sure that, when using field centric steering, the angle the robot should be traveling is represented by
Code:
theta = atan2(X,Y) * (180/pi); //unit circle stuff |
|
#2
|
||||
|
||||
|
Re: Finding the position of the robot
The gyro gives you the angle of the robot relative to the robot's position at power-up.
from Gyro.java in WPILib: Code:
/** * Use a rate gyro to return the robots heading relative to a starting position. * The Gyro class tracks the robots heading based on the starting position. As the robot * rotates the new heading is computed by integrating the rate of rotation returned * by the sensor. When the class is instantiated, it does a short calibration routine * where it samples the gyro while at rest to determine the default offset. This is * subtracted from each sample to determine the heading. */ |
|
#3
|
||||
|
||||
|
Re: Finding the position of the robot
Thanks I knew that, though. The reason I need to figure out the angle relative to the sides is so that I can calculate the reflection angle off of any one or two walls. I was hoping it could be done computationally using just rangefinders and not the servo or accelerometer, but I think that might take some experimentation to get right. I know it would be easy to do if the robot was always facing the same direction, but it could be facing any direction when it's near a wall. Thanks for your reply
|
|
#4
|
||||
|
||||
|
Re: Finding the position of the robot
Quote:
The gyro gives you the angle the robot is facing relative to its starting position. So if you start with the robot parallel to the sides then the gyro will give you the angle relative to the sides, which is what you said above you are looking for. |
|
#5
|
|||||
|
|||||
|
Re: Finding the position of the robot
Quote:
You COULD do it with rangefinders, two to a side (one at each corner on each side of the robot)--"snap" a measurement and take the difference, which will give you two sides of the triangle, repeat to make sure you aren't bouncing off another robot--but that's probably more trouble than it's worth. However, I think there's another way to do it, provided that you have a camera onboard that can track a vision target. If you can see the target, you can use the size to find how far away you are and the distortion from square (or circular) to find out your angle. If you think about it, this will also enable you to determine such items as whether you are in range to fire, your exact location on the field, and other things about position that you may desire to know. The problem? It might take a bit to figure out how to work it. |
|
#6
|
|||
|
|||
|
Re: Finding the position of the robot
Simple is easy. You could just mount the gyro on something that rotates (bearing, bushing, whirling dervish, whatever) and align the gyro to the field for each match...
|
|
#7
|
|||||
|
|||||
|
Re: Finding the position of the robot
And lock the spinning device right before you start--say, a wedge between two plates. That might be the way to go. (Unless, of course, you like to think your robot is the Tasmanian Devil.)
|
|
#8
|
|||
|
|||
|
Re: Finding the position of the robot
We found the accelerometer to be not as useful as we thought, but others might have had different experiences.
If you use Java, you can simply call 'gyro.reset;' ("gyro" being whatever variable is assigned to the Gyro) to "zero" the Gyro. I would think that the easiest way would be to drive into any of the walls and assign a button to zero the Gyro. Just drive into the wall, zero the Gyro, and then you can tell the angle relative to the side. |
![]() |
| Thread Tools | |
| Display Modes | Rate This Thread |
|
|