|
Re: HELP - Dashboard Digital Inputs to Select Autonomous Modes
Thanks for the help, Alan. This is where I ended up.
This is my autonomous code for 2013. It was my first time writing an autonomous code and it took way longer to figure out than I’d like to admit. The robot has a flat conveyor on top and a blocker arm. The idea is that discs are dropped onto the conveyor from the feeder station and then ferried to the low goal where they are conveyed into the goal. The blocker starts in the vertical position because it is outside the frame perimeter when it’s folded down.
There are 2 autonomous modes.
Mode 1 – The robot simply drives forward enough for the blocker arm to clear the tower then lowers the blocker arm.
Mode 2 – The robot drives forward, stops, lowers the blocker arm, waits for a time to allow other robots to move if necessary, continues to drive to the low goal, and dumps the discs into the low goal.
The driver switches between modes using the Digital Inputs on the Driver Station within the I/O tab. Mode 2 also uses the Analog Inputs in the I/O tab to set the time the robot waits. Both these inputs can be set anytime before the match, even while the Driver Station computer is connected to the field. The Driver Station remembers what settings (auto mode, wait time, etc.) were used last. We used this system this season and not only was it surprisingly simple, it also worked great.
Below is a screen capture of the final code. I'm not sure if it's " technically correct" or "optimized" but it worked perfectly every time. I also included a picture of the robot for reference.
a. Case Structure (Programming > Structures) - This switches between T/F and a numbered set based on what is input into it. Mine takes an integer.
b. Flat Sequence Structure (Programming > Structures)
c. Drive Safety Config (WPI Robotics Laboratory > RobotDrive > Advanced) - I'm not even sure this is necessary but other examples had it...
d. Wait (Programming > Timing)
e. Build Array (Programming > Array)
f. Boolean Array to Number (Programming > Boolean)
g. Multiply (Mathematics > Numeric)
h. To Unsigned Long Integer (Programming > Numeric > Conversion) - Because the Analog input is a "64 bit real" (orange), it needs to be converted to a 32 bit integer (blue) before the Wait function will accept it.
|