|
|
|
![]() |
|
|||||||
|
||||||||
|
|
Thread Tools | Rate Thread | Display Modes |
|
#1
|
||||
|
||||
|
getting g++ and gcc errors
Also getting If and Else if, button value syntax errors in the start of the teleoperatedPeriod
#include "WPILib.h" /** * This is an easy way to keep track of connections * This code assumes the following connections: * - Driver Station: * - USB 1 - Main Drive Xbox controller * - USB 2 - Secondary Xbox * - Robot: * - Digital Sidecar 1: * - PWM 1 - Left Drive * - PWM 2 - Right Drive * - PWM 3 - Shooter * - PWM 4 - Ball Intake * - PWM 5 - Intake arm/lifter * - PWM 6 - Catcher * - PWM 7 - Connected to * - PWM 8 - Connected to * - PWM 9 - Connected to * -Digital Sensors * -I/O 1 - Pneumatic sensor * -I/O 2 - * */ class Robot : public IterativeRobot { RobotDrive *TankDrive; // robot drive system Joystick *Driver_Controller; Joystick *Assistant_Controller; LiveWindow *lw; int autoLoopCounter; Talon *Talon0; //Left Drive Talon *Talon1; //Right Drive Talon *Talon2; //up and down Talon *Talon3; //arm close and open Talon *Talon4; //intake wheels Talon *Talon5; //spare float Left_X_Axis_Driver; //when CamelCase doesn't fit, underscores work too float Right_X_Axis_Driver; //float means long decimel float Left_Y_Axis_Driver; float Right_Y_Axis_Driver; float Left_X_Axis_Assist; //when CamelCase doesn't fit, underscores work too float Right_X_Axis_Assist; //float means long decimel float Left_Y_Axis_Assist; float Right_Y_Axis_Assist; float AutoTimer; public: Robot() : TankDrive(1, 2), // these must be initialized in the same order Driver_Controller(1), // as they are declared above. Assistant_Controller(2), Talon0(0), Talon1(1), Talon2(2), Talon3(3), Talon4(4), Talon5(5), AutoTimer(), lw(NULL), autoLoopCounter(0) { TankDrive-> SetExpiration(0.1); Left_X_Axis_Driver =0; //when CamelCase doesn't fit, underscores work too Right_X_Axis_Driver =0; //float means long decimel Left_Y_Axis_Driver =0; Right_Y_Axis_Driver =0; Left_X_Axis_Assist =0; //when CamelCase doesn't fit, underscores work too Right_X_Axis_Assist =0; //float means long decimel Left_Y_Axis_Assist =0; Right_Y_Axis_Assist =0; } private: void RobotInit() { lw = LiveWindow::GetInstance(); } void AutonomousInit() { autoLoopCounter = 0; } void AutonomousPeriodic(void) { AutoTimer=Timer::Timer(); if(AutoTimer==0){ //starts timer and makes sure everything is stopped void Timer::Start(); Talon1 -> Set(0); Talon2 -> Set(0); Talon3 -> Set(0); Talon4 -> Set(0); Talon5 -> Set(0); } else if(AutoTimer<2){ //Drive forward for 2 seconds Talon1 -> Set(.3); //left drive 30% Talon2 -> Set(-.3); //right drive 30% Talon3 -> Set(0); //shooter 0% Talon4 -> Set(0); //ball intake 0% Talon5 -> Set(0); //intake arm/lifer 50% } else if(AutoTimer<7){ //Move launch motor for 5 seconds Talon1 -> Set(0); //No movement Talon2 -> Set(0); Talon3 -> Set(0); //shooter 100% Talon4 -> Set(0); Talon5 -> Set(0); } else if(AutoTimer<8){ //Robot turning around-1 second (Zero Turn) Talon1 -> Set(.5); //Left drive 50% Talon2 -> Set(-.5); //Right drive 50% (backwards) Talon3 -> Set(0); Talon4 -> Set(0); Talon5 -> Set(0); } else if(AutoTimer<10){ //Nothing going on Talon1 -> Set(0); Talon2 -> Set(0); Talon3 -> Set(0); Talon4 -> Set(0); Talon5 -> Set(0); } else if(AutoTimer>10){ //Nothing going on Talon1 -> Set(0); Talon2 -> Set(0); Talon3 -> Set(0); Talon4 -> Set(0); Talon5 -> Set(0); void Timer::Stop(); //you can do a TON of clever stuff with one timer, and it gets bigger as you add more timers. be sure to take advantage of timers! } } /** XBOX Controller Notes * Buttons: * A=1 * B=2 * X=3 * Y=4 * LB=5 * RB=6 * Back=7 * Start=8 * LeftAnalog=9 * RightAnalog=10 * Axis: * LeftX=1 * LeftY=2 * RightX=4 * RightY=5 * Trigger=3 (Left moves -, Right moves +) */ void TeleopInit() { } void TeleopPeriodic() { void RobotDrive::TankDrive (float leftValue,float rightValue,bool squaredInputs = true); Talon1 -> Set(-Left_Y_Axis_Driver); //Sets speed to Joy stick value Talon2 -> Set(Right_Y_Axis_Driver); if(Driver_Controller->bool GetRawButton(5)==0){ Talon3->Set(1); } else if(Driver_Controller->bool GetRawButton(9)==0){ Talon3->Set(-1); } else{ //never forget your else Talon3->Set(0); } TestPeriodic(); { lw->Run(); } }; 'START_ROBOT_CLASS(Robot); |
| Thread Tools | |
| Display Modes | Rate This Thread |
|
|