Thread created automatically to discuss a document in CD-Media.
LabVIEW Mecanum Programming by: Jogo
This tutorial is a step-by-step implementation of mecanum drive in LabVIEW.
This tutorial is a step-by-step implementation of mecanum drive in LabVIEW. It is between beginner and intermediate LabVIEW, so it assumes some experience with LabVIEW and control loops.
**
Nice presentation. This should prove helpful to teams just getting started with LabVIEW and mecanum.
There’s a small error on Page 19 which may lead some astray:
Wouldn’t it be convienient to–on the push of a button–rotate to the direction you’re traveling?
To calculate this angle, do Math.atan2(Joystick X, -Joystick Y)
Implement a PID loop–the setpoint is the joystick angle, and the process variable is the gyro angle
The above won’t work very well. The joystick angle will be -180…+180, and the gyro angle will be 0…360+
You can’t just pass the joystick angle and gyro angle to the PID as-is. The PID will not like that at all.
For example, if the joystick angle is -1 degree and the gyro is reading +359 degrees, the PID will calculate (and act upon) an error of -1-359 = -360 degrees… even though the vehicle is already pointing in the desired direction.
To use the LabVIEW PID in this situation, you need to do something like this:
Thank you Ether. I added in a solution that I used but neglected to include in the first version. Now that I look at your solution closer, however, yours seems a great deal more elegant.
Sorry about that; I mean in the true/false case structure, there is the"blue thing" that says"L1 rotate_mode." My question is where is that located in labview?
rotate_mode is a global variable that was defined on the immediately preceding slides. L1 is an enumerated constant that was obviously created by right-clicking the input terminal of the variable and choosing Create Constant.
It’s not exactly obvious how to place a reference to an existing global variable. Here’s how to do it:
Right-click on an empty spot in the block diagram to call up the function palette. Choose “Select a vi…” and navigate to the folder containing your robot project. Open “Robot Global Data.vi” and you’ll have a global variable attached to your cursor (it will likely be named “Enable Vision” – don’t worry about it). Click to place that variable on the block diagram. Now you can click on the middle of the variable to bring up a list of all the globals that are part of the Robot Global Data vi. Choose the one you want.
The default is to make a “write” reference. To change it to “read”, right-click on the variable and choose “Change To Read”.
Okay. I got the global variable to show up, and I can connect the constant to it. But when I change the global variable to read, I can’t connect my constants anymore. Did I totally mess up somewhere? This is my third year programming, but I’ve never messed with the global robot data vi.
If you want to put a constant in the global variable, you need to write to it. You would read it if you want to do something with the value it contains.
Okay. On to page 14 I’m getting tired of asking questions. But thanks to everyone for your help. The rotate mode runs into the case structure and then connects to the symbol I can’t seem to find. It’s blue with an arrow and a box with a circle under it.
Also, do need to create a global variable called “header”? If so, what properties does it need to have?
It’s called a Feedback Node. You will find it in the Programming>Structures function subpalette. Its output is the value that was connected to its input the previous time through the loop. It changes color based on what type of data it’s connected to; in this case it’s blue because the data is an (enumerated) integer type.
(The Feedback Node look has changed slightly between LabVIEW 8.6 and LabVIEW 2011. The “box with circle” is now a wider box with an asterisk.)
Hello David. You do need to add a global variable called “header” (numeric), which is used to store the gyro angle each time rotate_mode changes to “straight”.
For tuning the PID function, first right click on the “PID gains” terminal and add a control or a constant, and follow the instructions on page 16. There are plenty of good resources around the web for PID tuning specifics: http://zone.ni.com/devzone/cda/tut/p/id/3782.
If you have more implementation-specific questions, feel free to PM me.
I am also trying to figure out the global variable header. I wasnt sure where to create it or how. So i created a numeric and then create a local variable from the numeric and called it header and used that within my teleop code. Will this work or do i need to create a global somehow?
The Robot Global Data.vi is where you create global variables (if you need them). It’s only a front panel, with no block diagram. Place (or paste) a control of the appropriate type on the front panel, then right-click it and make its label visible if it isn’t already. Change the label to whatever name you want the global variable to be.
To use a global variable, you can either copy one from elsewhere, or use the “Select a VI” item in the function palette to pick the Robot Global Data. You’ll end up with something on your block diagram with a popup menu that lets you choose among all the globals. You can use the right-click menu to make it a “read” or a “write”.