|
|
|
![]() |
|
|||||||
|
||||||||
![]() |
|
|
Thread Tools |
Rating:
|
Display Modes |
|
|
|
#1
|
||||
|
||||
|
Re: Mecanum - use of gyro
Quote:
Take your Z-axis (yaw rate) command from your joystick and integrate it (with a gain tuning constant) to create a yaw angle command. Take the accumulated yaw angle measurement from the gyro and subtract it from the yaw angle command to form the yaw angle error. Now you can feed this yaw angle error into a PID. The output from the PID is your modified yaw rate command Z' which gets sent (along with your fwd/rev and strafe joystick commands) to your mecanum logic which converts them in to the four wheel speeds. |
|
#2
|
||||
|
||||
|
Re: Mecanum - use of gyro
Attached is an example LabVIEW implementation.
I'm not an experienced LabVIEW programmer but I think this is correct. Note that with the LabVIEW PID vi, you feed in the setpoint and process variable, not the error. The vi also does the output range limiting for you. The constant K1 adjusts the sensitivity of your joystick Z-axis command. The Z' output from the PID is your controlled yaw rate command which gets fed into your mecanum wheel speed calculation along with the fwd/rev and strafe joystick commands. To tune the PID, try starting with proportional only. Last edited by Ether : 01-12-2010 at 18:30. Reason: added comments and reset button to vi |
|
#3
|
||||
|
||||
|
Re: Mecanum - use of gyro
Ether is correct.
The example is excellent, but is missing a WAIT function. The input to the PID function overrides automatic delta time calculation, but does not actually slow the loop down. Note that you are not restrained to the 50hz loop rate. If you want your PID to respond more quickly, you can increase the loop rate. 50hz is simply the maximum rate you can receive new data from your joysticks. |
|
#4
|
||||
|
||||
|
Re: Mecanum - use of gyro
Quote:
I have a question though: This "automatic delta time calculation" ... where in the documentation is that explained? The help file says only this: Quote:
Quote:
|
|
#5
|
|||
|
|||
|
Re: Mecanum - use of gyro
Quote:
Because the VI's default for dt is -1, the default behavior is for it to calculate its own dt internally based on the timer. When you wire something real up to it, that will disable the timer and use that value instead. |
|
#6
|
||||
|
||||
|
Re: Mecanum - use of gyro
Quote:
|
|
#7
|
||||
|
||||
|
Re: Mecanum - use of gyro
Yes.
In this case, I would expect it to be accurate within 1 millisecond. |
|
#8
|
||||
|
||||
|
Re: Mecanum - use of gyro
Quote:
I'm surprised to hear you say that. Please elaborate. Have you ever measured the realtime jitter in the Teleop loop of the FRC Framework ? |
|
#9
|
||||
|
||||
|
Re: Mecanum - use of gyro
I have.
I was actually expecting this to be placed in a Periodic tasks, and estimating. I know this code is not likely to take 20ms to execute, and in looking at time-to-execute in loops, it's usually the value wired into the wait function (occasionally plus or minus a millisecond). As for the packet jitter from the DS, I have done more detailed testing. Packets tend to arrive in multiples of 20ms, but and are usually within 2 milliseconds. (This is assuming you're only running the DS and robot for 1 match. Strange things happen over several hours.) Most packets arrive at 40ms (that is to say, half the packets the DS sends aren't received by the robot). It's likely a packet-free period greater than 500ms will occur 10 times within 1 match. EDIT: I'm assuming it's inconsequential, but I measured from the loop in Robot Main, and from the DriverStation StartCommunication.vi, not from Teleop itself. The purpose of the tests was to examine the reliability of the Driver Station, not the determinacy of Teleop.vi and RobotMode.vi. Last edited by kamocat : 02-12-2010 at 23:11. |
|
#10
|
||||
|
||||
|
Re: Mecanum - use of gyro
Quote:
Last edited by Ether : 02-12-2010 at 23:28. |
|
#11
|
||||
|
||||
|
Re: Mecanum - use of gyro
Quote:
Oops, I forgot to answer your question. Yes, that's what I'm saying. I'll take the chance of making an untested estimate, assuming no-one hangs their life on it. [/EDIT] It's be interesting to do a decent test. (I didn't use image processing last year, so that probably made a difference) I wonder if it would be more deterministic if we made the wait function sequential (using a flat sequence structure)? Last edited by kamocat : 02-12-2010 at 23:37. |
|
#12
|
|||
|
|||
|
Re: Mecanum - use of gyro
Thanks for all the great feedback. We tried out the example VI last night. We inserted it in the Timed-Tasks area with a 20ms wait loop.
We had to debug some other problems that ate up much of our time last night, but once we got past that it sort of worked. PID gains were VERY sensitive. We had lots of trouble getting a stable AND responsive control loop. Tried using a P-only loop, but responses ranged from 1) robot studdering to get to desired angle or 2) robot overshooting and wildly rotating back-forth. Had to keep P<0.02 in order for it to be stable (but not really responsive). Will try tweaking the gains more next week. Have others had this much trouble tuning a PID loop? |
|
#13
|
|||
|
|||
|
Re: Mecanum - use of gyro
Quote:
Even if you aren't, though, the benefit of the automatic delta time calculation is that your controller will still behave well even in the presence of jitter. It simply measures the jitter and uses the actual time instead of the ideal time when computing the I and D terms. |
|
#14
|
||||
|
||||
|
Re: Mecanum - use of gyro
Quote:
You know more about LabVIEW than I do, but I find that surprising. I would have thought that the way LabVIEW protects critical sections would create more software latency than that. |
|
#15
|
||||
|
||||
|
Re: Mecanum - use of gyro
Quote:
Out of curiousity I looked at the PID block diagram to see what numerical integration algorithm it uses. Not being very adept at LabVIEW I couldn't parse it (and it wasn't commented). Is it simple Euler or something more sophisticated ? |
![]() |
| Thread Tools | |
| Display Modes | Rate This Thread |
|
|
Similar Threads
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| Why you WANT to use a Gyro this year | JesseK | Electrical | 10 | 19-01-2010 15:49 |
| [FTC]: Anyone know how to use the Gyro? | ttldomination | FIRST Tech Challenge | 0 | 31-01-2009 21:19 |
| Ever use a helicopter heading hold gyro before? | seanwitte | Electrical | 7 | 16-01-2008 12:59 |
| how can you use a gyro in autonomous mode | magical hands | Programming | 3 | 02-01-2004 13:31 |
| Gyro Chip: How To Use | archiver | 1999 | 3 | 23-06-2002 21:57 |