When you say “It didn’t work well”, what specifically didn’t work the way you intended?
BTW, talk about overkill with those speed controllers!!
Here is a quick video I did of a Gyro Stabilized Vex Kiwi robot. So far, it works great. Next step…More speed!!!
Working on similar. One issue I’ve been running into is the transition between turning and not turning. On the comp bot (H drive) this year we just have the driver toggle between heading lock mode and not. But that’s not really a great solution long term. Any suggestions?
How I got the Vex Kiwi to transition between Gyro stabilization (Heading Lock) and open loop control is really simple. I just sampled the “Rotation” input from the joystick, and used a “window” to detect when rotation was being commanded. Any rotation input outside the window caused the gyro input to be ignored and allowed the rotation command to control the rotation of the robot. As soon as the rotation input entered the window again, the current gyro direction value was set to zero and then the gyro direction was used to control the rotation once again.
One key to making this transition smooth is to set the “window” to closely match the range of the “Rotation” command deadband that doesn’t quite make a change in the robot’s rotation.
IIRC, that range for the Vex was from >122 to <130.
TI jaguars was all we had for extra motor controllers. We’re on low supply. :’(
I actually saw your video with the vex and decided to wire it up with one of our Cortex’s.
The problem was that the gyro reading would constantly decrease like there was some kind of drift even though the robot wouldn’t be rotating. I don’t know why it was doing that, and I only had a class period (1hr 15m) to work on code and getting everything worked out.
I could work on it some more and try to get it to work, but I’m much more fluent in LabVIEW than robotC so I’d rather try getting an FRC sized prototype working.
Clearly a FRC sized prototype is the direction we are heading as well.
As for your gyro drift. The initialization process may not be completing properly before the robot is moved.
I added the red LED to mine to indicate when the initialization process has finished. This bot is coded in “C” using MPLab as the IDE. It’s old school, but the principals are the same.
You want “heading hold” when the driver is not commanding a turn, right? Use whatever joystick input commands the turn to turn off heading hold whenever it’s not at neutral, and turn it back on again after the turn is finished. That could be as soon as the joystick is back at neutral, or it could be slightly delayed to account for the robot’s inertia. See how the driver likes the handling with various amounts of delay in the reactivation of heading hold mode.
So, we attempted this, however as Bill Nye reminds us constantly, “Inertia is a property of matter”. The heading lock controller (tuned) would take over as soon as we let go of the stick and it would oscillate because the gyro reading we were going to was behind where we actually were (because robot has inertia when it spins). A delay would resolve this issue. I was curious if there was a better way than that. We thought about sampling the gyro rate and if it was 0 and the commanded rate was 0 we could enable heading lock. As it stands, we drive so little in any given match (HP loader) that it wasn’t an issue.
Other approaches I thought about doing but in the end just went with the simple “hold this to lock heading” :
- PID controller on gyro_rate
- Settling time
- Scrapping it and saying “back in my day we didn’t have fancy gyros to hold our heading, we did it uphill, both ways, with drill motors”
- Telling the mechanical folks we were never turning and all systems needed to be on a turret
The problem with using both the command AND rate being at 0 is that you would rarely ever see a gyro rate of 0. Vibration, noise, and drift will all give a reading out of a gyro. All of these tend to average out around 0 if a good calibration is achieved, but it still rarely stops at 0.
As Alan suggested,
Use whatever joystick input commands the turn to turn off heading hold whenever it’s not at neutral, and turn it back on again after the turn is finished. That could be as soon as the joystick is back at neutral, or it could be slightly delayed to account for the robot’s inertia. See how the driver likes the handling with various amounts of delay in the reactivation of heading hold mode.
As for your other suggested options, these two should work quite well.
This made me laugh pretty hard.