We have our robot controlled with 2 controllers and were considering switching to one controller because of batteries. We want our wheel base controlled on the left joystick. I.e. Ch2 foward/Backward, Ch1 Left/Right. We use robotIC. Can you please provide a code. Thanks,
God bless
I believe what you are asking for is Arcade Control. You use one joystick to control the movement of the drivetrain. It’s similar to almost all video games today.
Here is a link to the VEX Wiki. It provides a small explanation of what the code does. Here is a [/2;]table/graph]("motor[right) with a considerably larger amount of detail.
As far as the code goes:
I could be wrong here, but say, for example, your left motor value should be 256 and your right value should be 127. The left motor value would limit itself to 127 and instead of going forward and to the left, you’re now going just forward. I realize that the 256/127 isn’t theoretically possible, but you can still have similar values.
Is it just me… or would the /2 make it so that if on the joystick turning equaled 0 and forwards equaled full speed, it would end up only going half speed? I’m pretty sure that’s why I used to not do /2 at all.
Yes. There are ways around this. Particularly through the use of figuring out which value is higher and figuring out what to multiply the highest value by to get 127 and then doing that across both values. Then you have properly scaled values. But dividing by 2 is just as easier and I haven’t tested any of the code itself.
Here is the code that I would develop, but haven’t bothered to test because our team doesn’t use arcade
I usually normalize the drive values. Here is an excerpt from my arcade driove code.
long drive_l_motor;
long drive_r_motor;
// Set drive
drive_l_motor = forward + turn;
drive_r_motor = forward - turn;
// normalize drive so max is 127 if any drive is over 127
int max = abs(drive_l_motor);
if (abs(drive_r_motor) > max)
max = abs(drive_r_motor);
if (max>127) {
drive_l_motor = 127 * drive_l_motor / max;
drive_r_motor = 127 * drive_r_motor / max;
}