yesterday we test our driving with a xbox 360 controller. it worked fine except for one thing. One of the motors is moving, what we think, twice the speed of the others. We have changed the pwms and double check the connection to the jaguars. Could it be the code???
For reference here is our Telop code
void OperatorControl(void)
{
myRobot.SetSafetyEnabled(true);
en1.Reset();
gyro.Reset();
AxisCamera &robocam = AxisCamera::GetInstance();
robocam.WriteResolution((AxisCamera::Resolution_t)3);
robocam.WriteBrightness(0);
Wait(3.0);
while (IsOperatorControl())
{
// read digital inputs
unsigned short leftValue = left->Get() ? 4 : 0; // read the line tracking sensors
unsigned short middleValue = middle->Get() ? 2 : 0;
unsigned short rightValue = right->Get() ? 1 : 0;
//Look for line sensor inputs only when right bumber is pressed
if (xbox.GetRightBumper()){
switch(leftValue + middleValue + rightValue){
case(0x0): // normal operation
case(0x5):
case(0x7):{
//printf("no line found
");
//void MecanumDrive_Cartesian(float x, float rotation, float y, float gyroAngle = 0.0);
if (!xbox.GetLeftBumper()){
myRobot.MecanumDrive_Cartesian(xbox.GetLeftX(), xbox.GetRightY(), -xbox.GetLeftY(), 0); //Mecanum drive at full speed
}
else{
myRobot.MecanumDrive_Cartesian(xbox.GetLeftX()/2, xbox.GetRightY()/2, -xbox.GetLeftY()/2, 0);//Mecanumdrive at half speed
}
break;
}
case(0x1): // straif right
case(0x3):{
// printf("right leftstickX = %f, abs = %i
",leftstick.GetX(), abs((int)leftstick.GetX()));
float leftvalue = (fabs(xbox.GetLeftX())/-2);
//printf("right leftstickX = %f
", leftvalue);
myRobot.MecanumDrive_Cartesian(leftvalue, 0, -xbox.GetLeftX(), 0);
break;
}
case(0x2):{ // keep going
//printf("middle
");
myRobot.MecanumDrive_Cartesian(0, 0, -xbox.GetLeftX(), 0);
break;
}
case(0x4): // straif left
case(0x6):{
//printf("left
");
float rightvalue = (fabs(xbox.GetLeftX())/2);
//printf("left leftstickX = %f
", rightvalue);
myRobot.MecanumDrive_Cartesian(rightvalue, 0, -xbox.GetLeftX(), 0);
break;
}
default:
break;
}
}
else {
//This is how the robot will drive if the right bumper is not pressed
//void MecanumDrive_Cartesian(float x, float rotation, float y, float gyroAngle = 0.0);
if (!xbox.GetLeftBumper()){
myRobot.MecanumDrive_Cartesian(-xbox.GetLeftX(), -xbox.GetRightY(), -xbox.GetLeftY(), 0); //Mecanum drive at full speed
}
else{
myRobot.MecanumDrive_Cartesian(-xbox.GetLeftX()/2, -xbox.GetRightY()/2, -xbox.GetLeftY()/2, 0);//Mecanumdrive at half speed
}
}
Anyone know what the problem is cause we cant figure it out and its getting frustrating…
You did not describe too much detail on what the problem was. For example, under what condition when the problem occurred (i.e. which button did you push or what were the joystick positions, basically which code path it took)? Which motor is moving twice the speed as the others? What happens if you move the joysticks? I don’t quite understand your code. While it is teleop code, you are reading the light sensors to follow the line but yet you are also reading the joysticks too? Are you doing some sort of assisted drive? If you want somebody to comment, you need to give more details on what you are trying to do and what are the symptoms.
Not an expert by any means, but hopefully someone will come along that can help more. In the meantime, have you tried calibrating the jaguars? They should be pre-calibrated, but it’s worth a shot if you have nothing else to try.
We got it
Just curious. What was the problem and solution?
We had to recalivrate them