So I had a working arcade control before but I decided to flip the front of the robot to the opposite side to make getting cones easier. Basically all I did was reverse all the motors on the drive base and it works fine except when I go left on the left joystick it turns my robot right and vice versa. I tried everything from changing the pluses and minuses as well as flipping the values for both sides of the drive base but both attempts resulted in a non functioning drive base. Here’s the working code with the flipped left and right controls:
motor[frontleft]=l+r;
motor[midleft]=l+r;
motor[backleft]=l+r;
motor[frontright]=r-l; I think this should match all the other rights… l-r
motor[midright]=l-r;
motor[backright]=l-r;
That makes it much easier to see what is going on with the math.
Then, I would agree with @sazrocks, next you should to rename the motors so the motors on the new left side are named left_____ and make sure the new front motors are named such.
I have never tried using a #define for a changing value, but I believe that it works. The names on your #define lines are backwards IMO, Ch3 is on the left vertical and Ch1 is the right horizontal. If you simply switch them to be correctly labeled I think that will fix it.
To turn right the left side goes forward and the right side comes back. Moving the right stick right is a positive 127, so the motors should be getting this:
motor[frontleft]=l+127;
motor[midleft]=l+127;
motor[backleft]=l+127;
motor[frontright]=l-127;
motor[midright]=l-127;
motor[backright]=l-127;
Which is correct, assuming the motors are all reversed in the pragmas/wires correctly.
Glad I could help. Make sure the motors are all still plugged in, at all the connections. Try it again after an hour or so, it could just be overheated. But motors can burn out, so it could be that as well.
That is very odd… My only thought would be that one of the motors in the new code is trying to go the opposite direction as the other two on that side. Maybe it was reversed in the pragmas by accident? but that would make it not move that side very well at all, and you said it work for a little while… so I don’t really think that could be it.
Here’s the problem, and it may take some thinking to understand. If I flip my robot around, it goes backward instead of forward, even when I push the same joystick, right? But if I press a turn control after turning the robot around, it’ll still go clockwise. Reversing motors does not reverse turn direction.
I’m not sure what the specific problem is, but I can say you’re coding in an extremely risky way and a very intensive way. You don’t really want to keep checking the r and l values (as mentioned above, the Ch1 & Ch3 choice is confusing, but whatever…) for every motor you set. At some point you’re going to change how you’re pushing the joystick. Odds are that will happen in the middle of when you’re setting the motors because you spend much more time inside the if statement than on the if statement’s check. That is likely to mean you’re frequently setting your three motors on a single side to different values. What you should do is something more like this:
Get rid of those #define’s, replacing them with
int r;
int l;
And start your while loop this way:
while(true){
int r = vexRT[Ch3];
int l = vexRT[Ch1];
…
Your code will now be far less resource-intensive as well as ceasing to set motors on the same side to different values any time the joysticks shift (which is pretty much always unless you’re not using them since it’s hard to hold your fingers super-still).
Thank you for the tip! I also figured out the problem, one of the motors on the drive base went bad and had to be replaced. Also the thing about the l and r being switched is due to pure laziness, when I first wrote the program I had the channels backwards so I swapped them instead of replacing every single l and r lol