![]() |
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? |
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? |
Re: How to end an auto mode after gyro gets out of deadband
Quote:
|
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 ?! |
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. |
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. |
Re: How to end an auto mode after gyro gets out of deadband
Code:
#define KP 1This 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? |
Re: How to end an auto mode after gyro gets out of deadband
Quote:
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. |
Re: How to end an auto mode after gyro gets out of deadband
Quote:
This is all getting highly speculative now though... more information from 968 would make it easier for us all to help :) |
Re: How to end an auto mode after gyro gets out of deadband
Quote:
|
Re: How to end an auto mode after gyro gets out of deadband
Quote:
|
Re: How to end an auto mode after gyro gets out of deadband
Quote:
Then you can turn the two threshold "knobs" to get the behavior you are looking for. Eric |
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. |
Re: How to end an auto mode after gyro gets out of deadband
Quote:
|
Re: How to end an auto mode after gyro gets out of deadband
Quote:
|
Re: How to end an auto mode after gyro gets out of deadband
Thanks for all the replies..
We know how to write a PID loop but, thats not what were looking for. What im actually trying to do is to totally kill the autonomous mode after the gyro gets out of the deadband in code, but once it goes back into the dead band, the code was once again running. I need to stop the bot once it gets out of the dead band and make sure its going to not re execute while its back into the deadband. Getting it still?? Heres what I have in my code so far. Code:
|
Re: How to end an auto mode after gyro gets out of deadband
Quote:
Code:
if(setauto != 2... |
Re: How to end an auto mode after gyro gets out of deadband
How's 'bout something like this:
Code:
. |
| All times are GMT -5. The time now is 08:17. |
Powered by vBulletin® Version 3.6.4
Copyright ©2000 - 2017, Jelsoft Enterprises Ltd.
Copyright © Chief Delphi