SHARE
TWEET

Untitled

a guest Dec 18th, 2016 86 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. #include "WPILib.h"
  2. #include "Joystick.h"
  3. #include "GenericHID.h"
  4.  
  5. class Robot: public IterativeRobot
  6. {
  7. private:
  8.     RobotDrive drive;
  9.     Joystick joystick1;
  10.  
  11.     TalonSRX *frontRight = new TalonSRX(0);
  12.     TalonSRX *backLeft = new TalonSRX(1);
  13.     Talon *frontLeft = new Talon(0);
  14.     Talon *backRight = new Talon(1);
  15.  
  16.  
  17.     LiveWindow *lw = LiveWindow::GetInstance();
  18.     SendableChooser *chooser;
  19.     const std::string autoNameDefault = "Default";
  20.     const std::string autoNameCustom = "My Auto";
  21.     std::string autoSelected;
  22.  
  23.  
  24.     Robot():     //error is being thrown here
  25.         drive(frontLeft,backLeft,frontRight,backRight),
  26.         joystick1(0),
  27.         chooser()
  28.     {
  29.         drive.SetExpiration(0.1);
  30.     }
  31.  
  32.     void RobotInit()
  33.     {
  34.  
  35.         chooser = new SendableChooser();
  36.         chooser->AddDefault(autoNameDefault, (void*)&autoNameDefault);
  37.         chooser->AddObject(autoNameCustom, (void*)&autoNameCustom);
  38.         SmartDashboard::PutData("Auto Modes", chooser);
  39.     }
  40.  
  41.  
  42.     /**
  43.      * This autonomous (along with the chooser code above) shows how to select between different autonomous modes
  44.      * using the dashboard. The sendable chooser code works with the Java SmartDashboard. If you prefer the LabVIEW
  45.      * Dashboard, remove all of the chooser code and uncomment the GetString line to get the auto name from the text box
  46.      * below the Gyro
  47.      *
  48.      * You can add additional auto modes by adding additional comparisons to the if-else structure below with additional strings.
  49.      * If using the SendableChooser make sure to add them to the chooser code above as well.
  50.      */
  51.     void AutonomousInit()
  52.     {
  53.         autoSelected = *((std::string*)chooser->GetSelected());
  54.         //std::string autoSelected = SmartDashboard::GetString("Auto Selector", autoNameDefault);
  55.         std::cout << "Auto selected: " << autoSelected << std::endl;
  56.  
  57.         if(autoSelected == autoNameCustom){
  58.             //Custom Auto goes here
  59.         } else {
  60.             //Default Auto goes here
  61.         }
  62.     }
  63.  
  64.     void AutonomousPeriodic()
  65.     {
  66.         if(autoSelected == autoNameCustom){
  67.             //Custom Auto goes here
  68.         } else {
  69.             //Default Auto goes here
  70.         }
  71.     }
  72.  
  73.     void TeleopInit()
  74.     {
  75.         float strafe = joystick1.GetRawAxis(2) * -1 + joystick1.GetRawAxis(3);
  76.         float Ymove = joystick1.GetRawAxis(1);
  77.         float Rotate = joystick1.GetRawAxis(0);
  78.  
  79.         if(joystick1.GetRawButton(5) == true && joystick1.GetRawButton(6) == false)
  80.         {
  81.             drive.MecanumDrive_Cartesian(strafe / 2, Ymove / 2, Rotate / 2);
  82.         }
  83.         else if(joystick1.GetRawButton(5) == false && joystick1.GetRawButton(6) == true)
  84.         {
  85.             drive.MecanumDrive_Cartesian(strafe, Ymove, Rotate);
  86.         }
  87.         else
  88.         {
  89.             drive.MecanumDrive_Cartesian(0, 0, 0);
  90.         }
  91.  
  92.     }
  93.  
  94.     void TeleopPeriodic()
  95.     {
  96.  
  97.     }
  98.  
  99.     void TestPeriodic()
  100.     {
  101.         lw->Run();
  102.     }
  103. };
  104.  
  105. START_ROBOT_CLASS(Robot)
RAW Paste Data
Top