What I have so far is some skeleton drive code, and I'm pretty sure the encoders are giving me something because I am getting 0's and 1's depending on the way the motors are spinning. However, GetRaw() is supposed to count up or down, not return 0's and 1's.
The encoders are connected to the DIO slots indicated in the code.
Code:
#include "WPILib.h"
class DefaultRobot : public SimpleRobot{
Joystick joystick;
Jaguar leftDriveJag;
Jaguar rightDriveJag;
Jaguar combineJag;
Encoder encoderL;
Encoder encoderR;
public:
DefaultRobot(void):
joystick(1),
leftDriveJag(1),
rightDriveJag(5),
combineJag(3),
encoderL(4, 3, false, Encoder::k4X),
encoderR(2, 1, false, Encoder::k4X)
{
Watchdog().SetExpiration(.75);
}
void Autonomous(void){
}
void OperatorControl(void){
Watchdog().SetEnabled(true);
encoderL.Start();
encoderR.Start();
while(IsOperatorControl()){
Watchdog().Feed();
//Operator Control
printf("%d\n", encoderR.GetRaw());
printf("%d\n", encoderL.GetRaw());
if (joystick.GetRawAxis(4) > 0.2 || joystick.GetRawAxis(4) < -0.2) { //Deadband of .2
leftDriveJag.Set(joystick.GetRawAxis(4)); //Run left motors based on left stick value.
} else {
leftDriveJag.Set(0); //Set the motors to 0.
}
if (joystick.GetRawAxis(2) > .2 || joystick.GetRawAxis(2) < -.2) { //Deadband of .2
rightDriveJag.Set(joystick.GetRawAxis(2)); //Run right motors based on right stick value
} else {
rightDriveJag.Set(0); //Set the right drive motors to 0.
}
if (joystick.GetRawButton(2)){
combineJag.Set(.5);
} else {
combineJag.Set(0);
}
if(joystick.GetRawButton(3)){
combineJag.Set(.25);
} else {
combineJag.Set(0);
}
}
}
};
START_ROBOT_CLASS(DefaultRobot);