02-05-2009 11:34 AM
To all:
We have gotten our robot main.vi to work, and we have gotten our camera code to work when it is run independently in a separate robot main.vi. However, when we put our camera code into autonomous independent.vi, we are having problems handshaking both of these - specifically, coordinating the intitializations of the motors, watchdogs, etc. I am attaching the code that we are running - any help would be greatly appreciated!
John Jauss
Team 1182 Coach
02-06-2009 01:08 PM
I'm not completely certain I've understood your question; are you seeing an error, or just undesired behavior?
The first thing I'd suggest is put a wait into the upper loop in your autonomous mode. All while loops in LabVIEW that execute more than one iteration should contain a wait somewhere in them. Otherwise, LabVIEW will run that loop exclusively, consuming all processor time and preventing other code from executing.
02-06-2009 10:05 PM
Okay, so in this version of the code we run the autonomous and the camera tracks colors and also sends signals to the motors which respond appropriately. Then in teleoperated, it continues to run the autonomous we just tried. The teleoperated basically doesn't even activate - we get no control of the joystick or our pressure switch.
We also tried putting the upper while loop from autonomous to robot main, but the results were the same. We think the global references to the motors are not working properly because they are not working in BOTH autonomous and teleoperated. We have done tests where it worked in only teleoperated and only autonomous, but never both sequentially.
Your recommendation of adding a wait time did not affect our code.
Thanks again for your help
Team 1182
02-09-2009 11:01 AM
Have you used any of the LabVIEW debugging tools (execution highlighting, probes)? To see if your tele-op mode is running, probe the wire that goes into the case structure and see if it is ever set to "TeleOp Execute." You may also want to try execution highlighting to see what is happening, but be aware that it may slow your code to the point that the watchdog will time out (in that case, disable your watchdog timer temporarily).
It is not a good idea to open a reference to the Jaguars inside your autonomous mode, since you've already opened a reference to them in your Basic Robot Main. Instead, use the RobotDriveRef global variable to get access to the motor references. You can use the "Unbundle By Name" and "Index Array" functions to extract references to the two individual motors from the RobotDriveRef.
Try wiring the through Error In and Error out from one function to another and eventually to an indicator so that you can see if an error is occurring (for example, in your TeleOp mode, wire an indicator to the Error Out terminal of SetValue). You don't need the case structure around SetValue, just negate the value that you're reading from the button and pass it directly to SetValue. Also, using "Unbundle By Name" in place of "Unbundle" to get your joystick buttons (and other places) will make your code clearer.
You have a VI named "Servo Tracking State Machinev1.vi" which is not actually a state machine and has an icon labeled "Gimbal Control." You're calling it from two different locations: once in Basic Robot Main, and another time in Autonomous Independent. While I don't think this is causing problems, it also doesn't appear to be helping.
Try to follow left-to-right flow; for example, in Autonomous Independent, the wires leading to "left motor" and "right motor" indicators on the left side of the case structure are unexpected.
I'm not sure any of these will solve your problems, but they should help make your code more readable and easier to debug, and the debugging techniques may lead you to a solution.
02-09-2009 12:46 PM
Thank you for your help - I appreciate your time and attention!
We discovered on Saturday night that the reference to the Jaguars were to blame. We did exactly what you said - we used the global variable to get access to them, and where the RobotDriveRef global variable was placed was to blame. The autonomous and teleoperated were conflicting, as the motor function was being called by both of them, and couldn't be referenced separately!
Thank you for the rest of the suggestions as well -
John Jauss
Team 1182 Coach