Go to Post As a team leader if I do not INSPIRE I have failed, and I do not like to fail. - Mike Martus [more]
Home
Go Back   Chief Delphi > Technical > Programming
CD-Media   CD-Spy  
portal register members calendar search Today's Posts Mark Forums Read FAQ rules

 
Closed Thread
 
Thread Tools Rate Thread Display Modes
  #1   Spotlight this post!  
Unread 20-06-2013, 13:44
ekapalka's Avatar
ekapalka ekapalka is offline
Registered User
FRC #3216
 
Join Date: Dec 2012
Location: Bermuda
Posts: 277
ekapalka has a spectacular aura aboutekapalka has a spectacular aura about
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
where X and Y are the axes on a joystick, but I need to know the angle the robot is actually traveling, so I think I need to use a gyro and accelerometer. Normally, I would need two coordinates to come up with the slope of a line which I could then find the angle from, but I'm not sure how to do this with a gyro and accelerometer. Has anyone done this before? Thanks!
  #2   Spotlight this post!  
Unread 20-06-2013, 14:52
Ether's Avatar
Ether Ether is offline
systems engineer (retired)
no team
 
Join Date: Nov 2009
Rookie Year: 1969
Location: US
Posts: 8,077
Ether has a reputation beyond reputeEther has a reputation beyond reputeEther has a reputation beyond reputeEther has a reputation beyond reputeEther has a reputation beyond reputeEther has a reputation beyond reputeEther has a reputation beyond reputeEther has a reputation beyond reputeEther has a reputation beyond reputeEther has a reputation beyond reputeEther has a reputation beyond repute
Re: Finding the position of the robot

Quote:
Originally Posted by ekapalka View Post
...
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   Spotlight this post!  
Unread 20-06-2013, 17:39
ekapalka's Avatar
ekapalka ekapalka is offline
Registered User
FRC #3216
 
Join Date: Dec 2012
Location: Bermuda
Posts: 277
ekapalka has a spectacular aura aboutekapalka has a spectacular aura about
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   Spotlight this post!  
Unread 20-06-2013, 17:44
Ether's Avatar
Ether Ether is offline
systems engineer (retired)
no team
 
Join Date: Nov 2009
Rookie Year: 1969
Location: US
Posts: 8,077
Ether has a reputation beyond reputeEther has a reputation beyond reputeEther has a reputation beyond reputeEther has a reputation beyond reputeEther has a reputation beyond reputeEther has a reputation beyond reputeEther has a reputation beyond reputeEther has a reputation beyond reputeEther has a reputation beyond reputeEther has a reputation beyond reputeEther has a reputation beyond repute
Re: Finding the position of the robot

Quote:
Originally Posted by ekapalka View Post
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 think you may have misunderstood what I wrote.

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   Spotlight this post!  
Unread 20-06-2013, 19:13
EricH's Avatar
EricH EricH is offline
New year, new team
FRC #1197 (Torbots)
Team Role: Engineer
 
Join Date: Jan 2005
Rookie Year: 2003
Location: SoCal
Posts: 19,789
EricH has a reputation beyond reputeEricH has a reputation beyond reputeEricH has a reputation beyond reputeEricH has a reputation beyond reputeEricH has a reputation beyond reputeEricH has a reputation beyond reputeEricH has a reputation beyond reputeEricH has a reputation beyond reputeEricH has a reputation beyond reputeEricH has a reputation beyond reputeEricH has a reputation beyond repute
Re: Finding the position of the robot

Quote:
Originally Posted by Ether View Post
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.
Not all robots will start parallel to the sides of the field. It's often advantageous to NOT start parallel to the side, in which case, a "best guess" at the value probably won't help.


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.
__________________
Past teams:
2003-2007: FRC0330 BeachBots
2008: FRC1135 Shmoebotics
2012: FRC4046 Schroedinger's Dragons

"Rockets are tricky..."--Elon Musk

  #6   Spotlight this post!  
Unread 20-06-2013, 23:17
DELurker DELurker is offline
Former Engineering Mentor
AKA: William Lydick
no team (n/a)
 
Join Date: Mar 2011
Rookie Year: 2011
Location: Delaware, US
Posts: 268
DELurker has a brilliant futureDELurker has a brilliant futureDELurker has a brilliant futureDELurker has a brilliant futureDELurker has a brilliant futureDELurker has a brilliant futureDELurker has a brilliant futureDELurker has a brilliant futureDELurker has a brilliant futureDELurker has a brilliant futureDELurker has a brilliant future
Re: Finding the position of the robot

Quote:
Originally Posted by EricH View Post
Not all robots will start parallel to the sides of the field. It's often advantageous to NOT start parallel to the side, in which case, a "best guess" at the value probably won't help.
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...
__________________
----------------------------------------------
With 1370 --
2012 Rutgers District Event Champions with 1676/56
2012 Lenape District Event Finalists with 2191/1691

2013 TCNJ District Event QuarterFinalists with 1143/4750, Gracious Professionalism Award
2013 Bridgewater-Raritan District Event Semi-Finalists with 4285/223
2013 MAR Championship Finalists (Backup) with 222/11/1403; Gracious Professionalism Award
  #7   Spotlight this post!  
Unread 20-06-2013, 23:19
EricH's Avatar
EricH EricH is offline
New year, new team
FRC #1197 (Torbots)
Team Role: Engineer
 
Join Date: Jan 2005
Rookie Year: 2003
Location: SoCal
Posts: 19,789
EricH has a reputation beyond reputeEricH has a reputation beyond reputeEricH has a reputation beyond reputeEricH has a reputation beyond reputeEricH has a reputation beyond reputeEricH has a reputation beyond reputeEricH has a reputation beyond reputeEricH has a reputation beyond reputeEricH has a reputation beyond reputeEricH has a reputation beyond reputeEricH has a reputation beyond repute
Re: Finding the position of the robot

Quote:
Originally Posted by DELurker View Post
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...
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.)
__________________
Past teams:
2003-2007: FRC0330 BeachBots
2008: FRC1135 Shmoebotics
2012: FRC4046 Schroedinger's Dragons

"Rockets are tricky..."--Elon Musk

  #8   Spotlight this post!  
Unread 20-06-2013, 23:20
thinker&planner thinker&planner is offline
Registered User
AKA: CAAAAAD
no team
Team Role: Mechanical
 
Join Date: Jan 2013
Rookie Year: 2013
Location: Tallahassee, FL
Posts: 115
thinker&planner is a splendid one to beholdthinker&planner is a splendid one to beholdthinker&planner is a splendid one to beholdthinker&planner is a splendid one to beholdthinker&planner is a splendid one to beholdthinker&planner is a splendid one to beholdthinker&planner is a splendid one to behold
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.
Closed Thread


Thread Tools
Display Modes Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Forum Jump


All times are GMT -5. The time now is 03:04.

The Chief Delphi Forums are sponsored by Innovation First International, Inc.


Powered by vBulletin® Version 3.6.4
Copyright ©2000 - 2017, Jelsoft Enterprises Ltd.
Copyright © Chief Delphi