Team-348-2011-FIRST-Robot is a project mainly written in Java, it's free.
A documented example of FIRST robot code
THIS IS A ROUGH DRAFT -- Editing will be done -- Pictures will be added
On comments: The code you'll view will be much more heavily commented than the competition version. I am not against commenting, but under such time constraints I've found comments often fall out of date and can become misleading. I recommend that you comment anything tricky or complex. Beyond that, how you comment is your own choice, just your comments up to date.
This code is intended to run on a FIRST robot for the 2011 challenge Logomotion. If you are not familiar with the game, I recomend you watch the game animation first. See: [[http://www.youtube.com/watch?v=cSc8FWfJQlU][The game animation]] After that, if you have further questions on the basis of the game look up old matches and the official rules manual
** The Drive Train The drive train on this robot is capable of going 20ft/sec and is very finicky, so alot of the code is improving control so that the driver can actually drive. It has one Cim motor powering the left and another powering the right. There is an encoder that allows you to measure speed and distance hooked up (indirectly) to each Cim.
** The Arm The arm is a two stage elevator pulled up by a winch. The winch is powered by a window motor. An encoder is hooked up to the winch so that the height can be measured and it can go to the preset heights of the pegs. It can only reach the middle and upper row in addition to the feeder station.
The grabber is a piece of aluminum lifted by a servo to let pieces in and then dropped to hold pieces while driving.
** Minibot Deployment The minibot deployment system is draw slides propelled forward by constant force springs when a latch is released. The latch is released by spinning a window motor.
** Driver Controls The driver has two joysticks and drives the robot through a method known as tank drive. In tank drive the left joystick controls the left sides speed and the right joystick controls the right side speed. By varying the relative speeds of left and right, the robot can turn in place or while moving forward.
** Secondary Driver Controls The secondary driver controls where a custom box that we made and wired the PSOC controller provided by FIRST. The controls include a 5 position rotary switch for controlling the height of the arm. A switch for over-riding control of the arm. A switch for Deploying the minibot. A three-position switch for getting pieces from the feeder station and placing them on the pegs
JagBot.java The two most important function are =autonPeriodic= and =teleopPeriodic=, they are the "main loop" for the autonomous and human operated periods respectively. For the full story, read the code + comments. DriveTrain.java Arm.java BreakoutBox.java ** Utils.java
Autonomous Autonomous.java Stage.java ZeroArm.java MoveArm.java DriveForward.java PlacePiece.java ** DriveBackward.java
Appendix Encoders CAN Jaguars Motor Servos PWM ** PSOC Micro-controller
Arm Positions
| Num | Peg | Height | | 1 | Top Center | 1.710 | | 2 | Top Outer | 1.620 | | 3 | Middle Center | 0.915 | | 4 | Middle Outer | 0.700 | | 5 | Feeder | |