Author: Thijs Lacquet and Joris Dalderup, Team: NL0032 (Hermes)
Created on: 20-12-2013
This script now consists of ALL TeleOp code needed to complete a full game. However, optimization is still a necessity to make sure that a) All code is human-readeble (Thijs' optimal Dutch is NOT human- readable and shoud be replaced by GBE)
b) The NXT and RobotC do not encounter any issues compiling and running the code an compilations of it.
Note to Stijn: if, when compiling this code, you encounter any problems, befriend j._dalderup on skype. */
//Calibration config: static short THRESHOLD = 5; //Minimum value for controller-axis to be active.
static int SERVOSTATE_HORIZONTALPLATFORM = 0; //Range 0 - 255, servo value of th e platformservo when in horizontal mode static int SERVOSTATE_DUMPPLATFORM= 100; //Range 0 - 255, servo value of the pla tformservo when in dump mode
static int PLATFORM_SERVOSPEED = 0.2; //Range: [-100, 100], gets multiplied to t he platformjoystick from the "gunner" static int MIN_PLATFORMSERVO = 0; //Range: [0, 255], min value of the platformse rvo when the "gunner" controls it static int MAX_PLATFORMSERVO = 255; //Rage: [0, 255], max value of the platform servo when the "gunner" controls it
static int PLATFORMSPEED_LIFT_LOWERS = 5; //Range: [0, ?>, speed of the platform while the lift lowers, this is controlled by the driver
static int LIFTANDPLATFORM_UPDATE_SPEED = 100; //Range: [0, ?>, time in ms betwe en updates of the LiftAndPlatform task, // changing this value also chan ges the speed of PlatformServo when manually controlled by the "Gunner"
//Button config: static int SLOWDRIVE_LEFT_BTN = 5; static int SLOWDRIVE_RIGHT_BTN = 6; static int LIFT_RAISE_BTN = 0; static int LIFT_LOWER_BTN = 0; static int PLATFORM_DUMP_BTN = 0; static int HANGING_ENABLE_BTN = 0; //R1 btn from second joystick
//End of config
bool hang = false;
void initializeRobot() //This gets executed before the start of the match, so se rvo's can be sinitialized to starting postition { servo[PlatformServo] = SERVOSTATE_HORIZONTALPLATFORM; return; }
float DevideJoystick(float joy) //Reduces output from the Joystick to a number b etween -100 and 100 { if (joy > 0) { return (joy / 1.27); } else { return (joy / 1.28); } }
task drive //Makes it possible to drive using the 2 y-axis of the gamepad with t ankdrive { while (true) { getJoystickSettings(joystick); //Updates the joysticks
task main() { initializeRobot(); //Task doe things like setting initial servo values.
waitForStart(); //Waits for the start of the TeleOp phase.
StartTask(drive); StartTask(liftAndPlatform);
bool noError = true; //Besides being useful as tool to crash the program, thi s also prevents some weird error from showing up. while (noError == true) {