Go to Post Al's Murphy's law corollary...If it can go wrong, it will on Einstein - Al Skierkiewicz [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 16-04-2006, 22:21
kiettyyyy's Avatar
kiettyyyy kiettyyyy is offline
Registered User
FRC #1538 (The Holy Cows)
Team Role: Engineer
 
Join Date: Mar 2006
Rookie Year: 2005
Location: San Diego, CA
Posts: 181
kiettyyyy has a reputation beyond reputekiettyyyy has a reputation beyond reputekiettyyyy has a reputation beyond reputekiettyyyy has a reputation beyond reputekiettyyyy has a reputation beyond reputekiettyyyy has a reputation beyond reputekiettyyyy has a reputation beyond reputekiettyyyy has a reputation beyond reputekiettyyyy has a reputation beyond reputekiettyyyy has a reputation beyond reputekiettyyyy has a reputation beyond repute
Send a message via AIM to kiettyyyy
How to end an auto mode after gyro gets out of deadband

Hey all,

In my code, i have a gyroscope that gets read from the adc.c and gyro.c where when it gets off the deadband the robot would stop auto mode. But when the gyro gets put back into position (within the deadband) it would keep executing from where it started. Any ideas?
__________________
-Kiet Chau

2004-2008 - Software Developer/Driver on Team #968
2008-2011 - Software Developer/Coach/Mentor/"Engineer" on Team #968
2011-Present - Mentor & Engineer on Team #1538
www.team1538.com

Last edited by kiettyyyy : 16-04-2006 at 22:30.
  #2   Spotlight this post!  
Unread 16-04-2006, 23:52
Donut Donut is offline
The Arizona Mentor
AKA: Andrew
FRC #2662 (RoboKrew)
Team Role: Engineer
 
Join Date: Mar 2005
Rookie Year: 2004
Location: Goodyear, AZ
Posts: 1,307
Donut has a reputation beyond reputeDonut has a reputation beyond reputeDonut has a reputation beyond reputeDonut has a reputation beyond reputeDonut has a reputation beyond reputeDonut has a reputation beyond reputeDonut has a reputation beyond reputeDonut has a reputation beyond reputeDonut has a reputation beyond reputeDonut has a reputation beyond reputeDonut has a reputation beyond repute
Re: How to end an auto mode after gyro gets out of deadband

My guess is you're just doing a direct comparison to the gyro value to determine if you should run autonomous or not. You might want to have a flag that gets set to on when the gyro goes out of the deadband, but it never gets reset. Then have the autonomous only execute when that flag is off.

Could you show us the portion of code controlling autonomous from the gyro?
  #3   Spotlight this post!  
Unread 17-04-2006, 09:05
kaszeta's Avatar
kaszeta kaszeta is offline
Registered User
FRC #0095 (Grasshoppers)
Team Role: Mentor
 
Join Date: Feb 2004
Rookie Year: 2002
Location: Lebanon, NH
Posts: 334
kaszeta is a glorious beacon of lightkaszeta is a glorious beacon of lightkaszeta is a glorious beacon of lightkaszeta is a glorious beacon of lightkaszeta is a glorious beacon of light
Re: How to end an auto mode after gyro gets out of deadband

Quote:
Originally Posted by kiettyyyy
Hey all,

In my code, i have a gyroscope that gets read from the adc.c and gyro.c where when it gets off the deadband the robot would stop auto mode. But when the gyro gets put back into position (within the deadband) it would keep executing from where it started. Any ideas?
Just to keep weird things like this from happening, our code has a global flag (called auto_done) that is set once the autonomous mode is completed. If the flag is set, the autonomous code won't do anything.
  #4   Spotlight this post!  
Unread 17-04-2006, 09:09
KenWittlief KenWittlief is offline
.
no team
Team Role: Engineer
 
Join Date: Mar 2003
Location: Rochester, NY
Posts: 4,213
KenWittlief has a reputation beyond reputeKenWittlief has a reputation beyond reputeKenWittlief has a reputation beyond reputeKenWittlief has a reputation beyond reputeKenWittlief has a reputation beyond reputeKenWittlief has a reputation beyond reputeKenWittlief has a reputation beyond reputeKenWittlief has a reputation beyond reputeKenWittlief has a reputation beyond reputeKenWittlief has a reputation beyond reputeKenWittlief has a reputation beyond repute
Re: How to end an auto mode after gyro gets out of deadband

I dont understand the logic behind your implementation?

The gyro measures the rate of turn of the sensor (degrees rotation per second). On which axis are you going to mount the gyro sensor with the intent that any rotation on that axis will cause auton mode to end

but then to restart (continue) auton mode when the rotation stops ?!
  #5   Spotlight this post!  
Unread 17-04-2006, 09:55
Michael DiRamio Michael DiRamio is offline
Registered User
FRC #1114 (Simbotics)
Team Role: Teacher
 
Join Date: Jan 2006
Rookie Year: 2006
Location: St. Catharines, Ontario, Canada
Posts: 39
Michael DiRamio has a reputation beyond reputeMichael DiRamio has a reputation beyond reputeMichael DiRamio has a reputation beyond reputeMichael DiRamio has a reputation beyond reputeMichael DiRamio has a reputation beyond reputeMichael DiRamio has a reputation beyond reputeMichael DiRamio has a reputation beyond reputeMichael DiRamio has a reputation beyond reputeMichael DiRamio has a reputation beyond reputeMichael DiRamio has a reputation beyond reputeMichael DiRamio has a reputation beyond repute
Re: How to end an auto mode after gyro gets out of deadband

My guess is that they don't want to fire if they have been knocked off angle from the target, but would like to start firing again if their robot once again faces the target.

If so, I'd suggest not ending autonomous mode and trying to start it again, instead modify your autonomous so that each cycle a check is done to determine if you should be firing or not:

<get update from gyro>

if (<gyro in accepted range>)
{ <fire>
} else
{ <don't fire>
}

So that each time the sensor data is updated, the check will be done again.

I'm fairly new at this, so my apologies if I'm off base here.
  #6   Spotlight this post!  
Unread 17-04-2006, 10:50
Kevin Sevcik's Avatar
Kevin Sevcik Kevin Sevcik is offline
(Insert witty comment here)
FRC #0057 (The Leopards)
Team Role: Mentor
 
Join Date: Jun 2001
Rookie Year: 1998
Location: Houston, Texas
Posts: 3,721
Kevin Sevcik has a reputation beyond reputeKevin Sevcik has a reputation beyond reputeKevin Sevcik has a reputation beyond reputeKevin Sevcik has a reputation beyond reputeKevin Sevcik has a reputation beyond reputeKevin Sevcik has a reputation beyond reputeKevin Sevcik has a reputation beyond reputeKevin Sevcik has a reputation beyond reputeKevin Sevcik has a reputation beyond reputeKevin Sevcik has a reputation beyond reputeKevin Sevcik has a reputation beyond repute
Send a message via AIM to Kevin Sevcik Send a message via Yahoo to Kevin Sevcik
Re: How to end an auto mode after gyro gets out of deadband

I've got a better guess. They want the robot to stop moving if it get whacked by another bot, and start again after the gyro settles down. and the robot stops going nuts. In that case, the check for the gyro condition comes before all other auto code. Like thus:

User_Autonomous()
{

gyro state reading goes here

if(gyro in good state)
{
good gyro code goes here
including all counter incrementing, auto mode switching, etc.
}
else
{
code to run if gyro is crazy goes here
could be an alternate automode or something else
stopping motors, etc.
}

}

That's much more pseudo than it is code, of course. You could get fancy and set a flag such that the gyro has to be sane for X loops for it to enter the good auto code. With the above code, the execution could jump into the good auto loop if you happen to catch the gyro fluctuating through a good value.
__________________
The difficult we do today; the impossible we do tomorrow. Miracles by appointment only.

Lone Star Regional Troubleshooter
  #7   Spotlight this post!  
Unread 17-04-2006, 11:02
Tom Bottiglieri Tom Bottiglieri is offline
Registered User
FRC #0254 (The Cheesy Poofs)
Team Role: Engineer
 
Join Date: Jan 2004
Rookie Year: 2003
Location: San Francisco, CA
Posts: 3,187
Tom Bottiglieri has a reputation beyond reputeTom Bottiglieri has a reputation beyond reputeTom Bottiglieri has a reputation beyond reputeTom Bottiglieri has a reputation beyond reputeTom Bottiglieri has a reputation beyond reputeTom Bottiglieri has a reputation beyond reputeTom Bottiglieri has a reputation beyond reputeTom Bottiglieri has a reputation beyond reputeTom Bottiglieri has a reputation beyond reputeTom Bottiglieri has a reputation beyond reputeTom Bottiglieri has a reputation beyond repute
Re: How to end an auto mode after gyro gets out of deadband

Code:
#define KP		1
#define KI		0
#define KD		0
#define WANTED_HEADING	0
#define WANTED_OUTPUT_SPEED		80 //-127 to 127
#define SHOOTING_DEADBAND		20 //4 degree deadband. 20 tenths of a degree = 2 degrees. -2 to 2 = 4 total degrees.

cur_heading = Get_Gyro_Angle();

error = WANTED_HEADING - cur_heading; //if you want the robot to drive straight in auto mode, line up robot, then turn on. cur_heading will be 0 and 0-0=0.
sumError += error;
dError = last_error - error;

if(sumError > 100){
	sumError = 100;
}else if(sumError < -100){
	sumError = -100;
}

//Calculate individual outputs
pOut = error * KP; //proportional gain
iOut = sumError * KI; //integral gain
dOut = dError * KD; //differential gain

//Add for total PID output signal
pidOut = pOut + iOut + dOut;

//limit pidOUT so total output value is in range (0,254)
if(pidOut > 126){
	pidOut = 126;
}else if(pidOut < -127){
	pidOut = -127;
}

//To drive straight, subtract output from either side of the drivebase..
//this should work if pwm01 is left side and pwm02 is right side.
pmw01 = 127 + WANTED_OUTPUT SPEED - pidOut;
pwm02 = 127 + WANTED_OUTPUT SPEED + pidOut;

//Lastly, do other stuff.
if(error >= -SHOOTING_DEADBAND && error <= SHOOTING_DEADBAND){
	Shoot(); //Put whatever you want the robot to "do" here.
}
This will utilize a PID feedback control system to steer and control the shooting of your robot.

This will work the best, but you must know how to tune this piece of code to work with your robot. If you choose to follow this road, please read (in full) this page:
http://www.embedded.com/2000/0010/0010feat3.htm
(it wasnt loading for me.. heres the google cached page)

and this CD paper: http://www.chiefdelphi.com/media/papers/1823?
  #8   Spotlight this post!  
Unread 17-04-2006, 11:29
KenWittlief KenWittlief is offline
.
no team
Team Role: Engineer
 
Join Date: Mar 2003
Location: Rochester, NY
Posts: 4,213
KenWittlief has a reputation beyond reputeKenWittlief has a reputation beyond reputeKenWittlief has a reputation beyond reputeKenWittlief has a reputation beyond reputeKenWittlief has a reputation beyond reputeKenWittlief has a reputation beyond reputeKenWittlief has a reputation beyond reputeKenWittlief has a reputation beyond reputeKenWittlief has a reputation beyond reputeKenWittlief has a reputation beyond reputeKenWittlief has a reputation beyond repute
Re: How to end an auto mode after gyro gets out of deadband

Quote:
Originally Posted by Michael DiRamio
My guess is that they don't want to fire if they have been knocked off angle from the target, but would like to start firing again if their robot once again faces the target.
ok, but the gyro doesnt tell you at what angle you are pointing, it tells the the rate at which the robot is turning

so if the robot turns for any reason it would stop - any reason includes any offset in your drive motors that might cause the robot to not go exactly straight

then when the robot has stopped turning it will start moving again? that doesnt make much sense.

the same for Kevins suggestion - if another robot taps you sideways a little whats the point in shutting the robot down, then starting up again when you stop turning? Either way you have been knocked off your path.
  #9   Spotlight this post!  
Unread 17-04-2006, 11:43
Michael DiRamio Michael DiRamio is offline
Registered User
FRC #1114 (Simbotics)
Team Role: Teacher
 
Join Date: Jan 2006
Rookie Year: 2006
Location: St. Catharines, Ontario, Canada
Posts: 39
Michael DiRamio has a reputation beyond reputeMichael DiRamio has a reputation beyond reputeMichael DiRamio has a reputation beyond reputeMichael DiRamio has a reputation beyond reputeMichael DiRamio has a reputation beyond reputeMichael DiRamio has a reputation beyond reputeMichael DiRamio has a reputation beyond reputeMichael DiRamio has a reputation beyond reputeMichael DiRamio has a reputation beyond reputeMichael DiRamio has a reputation beyond reputeMichael DiRamio has a reputation beyond repute
Re: How to end an auto mode after gyro gets out of deadband

Quote:
Originally Posted by KenWittlief
ok, but the gyro doesnt tell you at what angle you are pointing, it tells the the rate at which the robot is turning.
My guess (another guess!) from the names of the files they are using (adc.c and gyro.c) is that they are using the Kevin Watson gyro code, which uses the rate information to determine a relative angle.

This is all getting highly speculative now though... more information from 968 would make it easier for us all to help
  #10   Spotlight this post!  
Unread 17-04-2006, 17:08
Kevin Sevcik's Avatar
Kevin Sevcik Kevin Sevcik is offline
(Insert witty comment here)
FRC #0057 (The Leopards)
Team Role: Mentor
 
Join Date: Jun 2001
Rookie Year: 1998
Location: Houston, Texas
Posts: 3,721
Kevin Sevcik has a reputation beyond reputeKevin Sevcik has a reputation beyond reputeKevin Sevcik has a reputation beyond reputeKevin Sevcik has a reputation beyond reputeKevin Sevcik has a reputation beyond reputeKevin Sevcik has a reputation beyond reputeKevin Sevcik has a reputation beyond reputeKevin Sevcik has a reputation beyond reputeKevin Sevcik has a reputation beyond reputeKevin Sevcik has a reputation beyond reputeKevin Sevcik has a reputation beyond repute
Send a message via AIM to Kevin Sevcik Send a message via Yahoo to Kevin Sevcik
Re: How to end an auto mode after gyro gets out of deadband

Quote:
Originally Posted by KenWittlief
the same for Kevins suggestion - if another robot taps you sideways a little whats the point in shutting the robot down, then starting up again when you stop turning? Either way you have been knocked off your path.
Well there's a maximum rate limit of 80deg per second that the gyro will measure. Certainly you can't trust it to integrate the rate and reliably determine your angular position if it's near this maximum or fluctuating wildly. And if it's pegged at the maximum, then you can't trust it at all or your integrated angle at any time after that. So I was figuring that if it hit the maximum, or maybe 75% of the maximum, you'd shut your motors down and hope like heck it'd settle down to a trustable value, then start back up again and continue on your merry way. Probably better than forging blindly ahead and hoping for the best.
__________________
The difficult we do today; the impossible we do tomorrow. Miracles by appointment only.

Lone Star Regional Troubleshooter
  #11   Spotlight this post!  
Unread 18-04-2006, 05:06
Travis Covington's Avatar Unsung FIRST Hero
Travis Covington Travis Covington is offline
Engineering Mentor
FRC #0254
Team Role: Engineer
 
Join Date: Oct 2001
Rookie Year: 1998
Location: San Jose, CA
Posts: 574
Travis Covington has a reputation beyond reputeTravis Covington has a reputation beyond reputeTravis Covington has a reputation beyond reputeTravis Covington has a reputation beyond reputeTravis Covington has a reputation beyond reputeTravis Covington has a reputation beyond reputeTravis Covington has a reputation beyond reputeTravis Covington has a reputation beyond reputeTravis Covington has a reputation beyond reputeTravis Covington has a reputation beyond reputeTravis Covington has a reputation beyond repute
Send a message via AIM to Travis Covington
Re: How to end an auto mode after gyro gets out of deadband

Quote:
Originally Posted by kaszeta
Just to keep weird things like this from happening, our code has a global flag (called auto_done) that is set once the autonomous mode is completed. If the flag is set, the autonomous code won't do anything.
This is more along the lines of what we want to happen. Once we get hit and the gyro senses rotation, we want the robot to just stop.
__________________
-Travis Covington

2008-2017 - Engineering Mentor of Team 254
2001-2008 - Engineering Mentor of Team 968
1998-2001 - Mechanical Director/Driver/Member of Team 115
  #12   Spotlight this post!  
Unread 18-04-2006, 08:54
EricS-Team180's Avatar
EricS-Team180 EricS-Team180 is offline
SPAM, the lunchmeat of superheroes!
AKA: Eric Schreffler
FRC #0180 (SPAM)
Team Role: Engineer
 
Join Date: Apr 2002
Rookie Year: 2001
Location: Stuart, Florida
Posts: 561
EricS-Team180 has a reputation beyond reputeEricS-Team180 has a reputation beyond reputeEricS-Team180 has a reputation beyond reputeEricS-Team180 has a reputation beyond reputeEricS-Team180 has a reputation beyond reputeEricS-Team180 has a reputation beyond reputeEricS-Team180 has a reputation beyond reputeEricS-Team180 has a reputation beyond reputeEricS-Team180 has a reputation beyond reputeEricS-Team180 has a reputation beyond reputeEricS-Team180 has a reputation beyond repute
Re: How to end an auto mode after gyro gets out of deadband

Quote:
Originally Posted by Travis Covington
Once we get hit and the gyro senses rotation, we want the robot to just stop.
Let's say that you have a good initial value for your neutral point, and that you can handle the case where each sample bounces around that point a bit ie. you have a stable value for zero rotation. You don't necessarily want to stop for a minor disturbance, such as small irregularities in the carpet, so pick a +/- threshold away from you neutral point, and some time threshold of persistence - (9 passes ~1/4sec?) If you exceed those two thresholds, together, then set a latch variable that stomps on the chassis pwms and sets them to 127.
Then you can turn the two threshold "knobs" to get the behavior you are looking for.

Eric
__________________

Don't PANIC!
S. P. A. M.
  #13   Spotlight this post!  
Unread 18-04-2006, 10:17
KenWittlief KenWittlief is offline
.
no team
Team Role: Engineer
 
Join Date: Mar 2003
Location: Rochester, NY
Posts: 4,213
KenWittlief has a reputation beyond reputeKenWittlief has a reputation beyond reputeKenWittlief has a reputation beyond reputeKenWittlief has a reputation beyond reputeKenWittlief has a reputation beyond reputeKenWittlief has a reputation beyond reputeKenWittlief has a reputation beyond reputeKenWittlief has a reputation beyond reputeKenWittlief has a reputation beyond reputeKenWittlief has a reputation beyond reputeKenWittlief has a reputation beyond repute
Re: How to end an auto mode after gyro gets out of deadband

If you are going through the trouble to read the gyro, and see that your robot is turning when you dont want it to

then instead of having your robot throw up its arms and give up in the middle of auton mode, why not take that same information, feed it to your motor control system, and use that error signal to zero out the turn rate and keep the robot on its original heading?

The gyro chip is very sensitive, as soon as it detects the slightest bit of turn rate you can have your robot fight back to stay straight on its path.

You've come this far, take the last step: close the loop (PID feedback is a beautiful thing!)

In fact, if you design in gyro feedback steering for auton mode, you can leave it engaged for driver mode as well - then all your driver has to do is point the robot with the joystick - if anything pushes it off the drivers intended course then the robot itself will fight back against the outside force to maintaing the drivers desired heading.

Last edited by KenWittlief : 18-04-2006 at 10:22.
  #14   Spotlight this post!  
Unread 18-04-2006, 12:18
EricS-Team180's Avatar
EricS-Team180 EricS-Team180 is offline
SPAM, the lunchmeat of superheroes!
AKA: Eric Schreffler
FRC #0180 (SPAM)
Team Role: Engineer
 
Join Date: Apr 2002
Rookie Year: 2001
Location: Stuart, Florida
Posts: 561
EricS-Team180 has a reputation beyond reputeEricS-Team180 has a reputation beyond reputeEricS-Team180 has a reputation beyond reputeEricS-Team180 has a reputation beyond reputeEricS-Team180 has a reputation beyond reputeEricS-Team180 has a reputation beyond reputeEricS-Team180 has a reputation beyond reputeEricS-Team180 has a reputation beyond reputeEricS-Team180 has a reputation beyond reputeEricS-Team180 has a reputation beyond reputeEricS-Team180 has a reputation beyond repute
Re: How to end an auto mode after gyro gets out of deadband

Quote:
Originally Posted by KenWittlief
You've come this far, take the last step: close the loop (PID feedback is a beautiful thing!)
So true Ken! We've been using the gyro feedback for yaw rate stabilization and heading since 2004 and have found it to be VERY effective
__________________

Don't PANIC!
S. P. A. M.
  #15   Spotlight this post!  
Unread 18-04-2006, 14:08
Matt Krass's Avatar
Matt Krass Matt Krass is offline
"Old" and Cranky. Get off my lawn!
AKA: Dark Ages
FRC #0263 (Sachem Aftershock)
Team Role: Mentor
 
Join Date: Oct 2002
Rookie Year: 2002
Location: Long Island, NY
Posts: 1,187
Matt Krass has a reputation beyond reputeMatt Krass has a reputation beyond reputeMatt Krass has a reputation beyond reputeMatt Krass has a reputation beyond reputeMatt Krass has a reputation beyond reputeMatt Krass has a reputation beyond reputeMatt Krass has a reputation beyond reputeMatt Krass has a reputation beyond reputeMatt Krass has a reputation beyond reputeMatt Krass has a reputation beyond reputeMatt Krass has a reputation beyond repute
Send a message via AIM to Matt Krass
Re: How to end an auto mode after gyro gets out of deadband

Quote:
Originally Posted by KenWittlief
You've come this far, take the last step: close the loop (PID feedback is a beautiful thing!)
Shameless plug, read my PID whitepaper linked in my signature for an introduction to the math and programming behind PID, if you have any specific questions feel free to catch me via PM or email, always happy to help.
__________________
Matt Krass
If I suggest something to try and fix a problem, and you don't understand what I mean, please PM me!

I'm a FIRST relic of sorts, I remember when we used PBASIC and we got CH Flightsticks in the KoP. In my day we didn't have motorized carts, we pushed our robots uphill, both ways! (Houston 2003!)
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

Similar Threads
Thread Thread Starter Forum Replies Last Post
Gyroscope Code Kevin Watson Programming 65 01-03-2008 23:46
Need help with Gyro = Analog Devices ADXRS150EB Jack Jones Technical Discussion 9 18-07-2005 07:00
Updated: Example Gyro Interface Code Kevin Watson Programming 2 28-03-2005 04:36
Example gyro code released. Kevin Watson Programming 60 17-03-2005 18:32


All times are GMT -5. The time now is 23:05.

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