Thank you!! Since we just finished the chassis, we're trying to get it working using the library code... and there have been some complications. We can rotate flawlessly, and we can drive in a more-or-less straight line (probably due to our ancient 2 axis joystick with no deadzone). The problem we're having is that we can't strafe (and the x axis, y axis, and rotation are all mixed up). When we try to strafe, the robot simply spins the wheels towards or away from the central point of the robot (i.e the front two wheels spin inwards and the back two wheels spin inwards xor vice versa) and it stays in place or runs in circles. The rollers are arranged in an "X" pattern when viewed from the top. Here's the code we're using, in case it's related to that...
Code:
#include <WPILib.h>
class DefaultRobot : public SimpleRobot
{
Joystick *Saitek;
Talon *frontLeft;
Talon *frontRight;
Talon *backLeft;
Talon *backRight;
RobotDrive *myRobot;
public:
DefaultRobot(void)
{ //these must be called in the same order as initialized
Saitek = new Joystick(1);
frontLeft = new Talon(2,1);
backLeft = new Talon(2,2);
frontRight = new Talon(2,3);
backRight = new Talon(2,4);
myRobot = new RobotDrive(frontLeft, backLeft,
frontRight, backRight);
}
void Autonomous(void)
{
while(IsAutonomous())
{
}
}
void OperatorControl(void)
{
float tval, sval;
while (IsOperatorControl())
{
float xVal = Saitek->GetRawAxis(1);
float yVal = Saitek->GetRawAxis(2);
bool trigButton = Saitek->GetRawButton(1);
bool leftButton = Saitek->GetRawButton(2);
bool midlButton = Saitek->GetRawButton(3);
bool rightButton = Saitek->GetRawButton(4);
myRobot->MecanumDrive_Cartesian(sval*0.5, tval*0.25, -yVal*0.25, 0.0);
if (leftButton && !rightButton){ tval = -1; }
else if (rightButton && !leftButton) { tval = 1; }
else if (leftButton && rightButton) { tval = 0; }
else tval = 0;
if (midlButton && !trigButton) { sval = -1; }
else if (trigButton && !midlButton) { sval = 1; }
else if (trigButton && midlButton) { sval = 0; }
else sval = 0;
//backRight->Set(0.25);
//backLeft->Set(0.25);
//frontRight->Set(0.25);
//frontLeft->Set(0.25);
}
}
};
START_ROBOT_CLASS(DefaultRobot);
Thanks!
[edit] Also, if we tell an individual motor to do something (i.e just sending a value to a single motor controller), the other motors move and twitch... I have no idea how to fix this