Quote:
Originally Posted by KyleS
How would I get the Xbox controller to work with tank drive correctly? It's a pain the team insists on using it, but oh well. Just not sure how to combine the multiple axis's into something like TankDrive.
|
You need to create a JoyStick object and a RobotDrive object. Then you just need to call the TankDrive() method of the RobotDrive class with the values from the left and right analog stick on the xbox controller.
Should look something like this:
Code:
void MySimpleRobot::OperatorControl()
{
RobotDrive* pTeleopDrive = new RobotDrive(1,2,3,4);
Joystick* pDriverXbox = new Joystick(1);
while(IsOperatorControl() && IsEnabled())
{
pTeleopDrive->TankDrive(pDriverXbox->GetRawAxis(2), pDriverXbox->GetRawAxis(5));
}
}
The 1,2,3,4 passed to the constructor of the RobotDrive represent the channels on the digital side car that your motor controllers are connected to. The value of 1 passed to the JoyStick constructor represents the usb port that your xbox controller is connected to. The 2 passed to GetRawAxis is for the Y-axis of the left analog stick and the 5 is for the Y-axis of the right analog stick.