Ok. We’re back again unfortunately. Our x drive has randomly stopped working. Nothing has been changed mechanically or through the program. It drives forward, backward, and turns normally, however, it does not strafe. No matter what combination of +'s and -'s we try, we cannot get it to work normally again.
I’m not sure if it helps, but here is our drive code:
I believe that Jarred was meaning to use the right joystick (Ch1 and Ch2) for x/y movement, and the left joystick (Ch4) for rotation.
Jarred, an easy way to figure out which motors need to be reversed on an “x” holonomic drive is to consider positive to be forwards, as with most other drive types. As such, write your code as if positive motor power leads to the drive moving forwards. An example of doing this with your code (with similar styling to Cody’s) would be:
word deadband(word input, unsigned word threshold)
{
return (abs(input) > threshold) ? input : 0;
}
task usercontrol()
{
const unsigned word kThreshold = 15;
word x = 0, y = 0, r = 0;
while (true) {
x = deadband(vexRT[Ch1], kThreshold);
y = deadband(vexRT[Ch2], kThreshold);
r = deadband(vexRT[Ch4], kThreshold);
//Remote Control Commands - [Toggle]
motor[frontleft] = y + x + r;
motor[frontright] = y - x - r;
motor[backleft] = y - x + r;
motor[backright] = y + x - r;
}
}
This code will work on any “x” holonomic drive, as long as the motors have already been reversed correctly in Motors and Sensors Setup such that positive motor power leads to forwards movement. An easy way to determine whether or not any of your motors need to be reversed differently is to use a program such as the following:
When running this code, see if pushing the right joystick forwards makes the robot move forwards. If not, determine which wheels are spinning in the wrong direction, taking note that the associated motors need to be reversed. Reverse those motors in your original software through the Motors and Sensors Setup.
Thank you. We have finally gotten it. After another hour of trying to figure out how this works, I got it to work correctly. Do you have any explanation of HOW exactly the code works in this way? Like how it goes
… I don’t get the logic behind this so I was struggling. But i finally saw your comments in the code saying that C1LY was the Y axis etc and it clicked. But I’d like to know why it works in this format.