My team has a competition in a little under a week, and we recently converted our robot’s code to use a drivetrain as opposed to controlling all four drive motors separately. I configured the drive train for split arcade, and sent the code to my builder for him to upload.
When he uploaded it, however, the drive moved in super random ways. Like, he pulled back on the left stick, and it moved forward, then he pulled forward, and it moved back. He pulled forward again, and it briefly went forward before going back. Before that test, whenever he moved the right(turning) stick, it would move in reverse.
I’m super confused by this, as it’s a drivetrain configuration thing and not a code thing.
Any help is appreciated, but we really are in quite a rush.
Thank you for reading!
First thing’s first: post your code. If it’s in blocks, take a clear screenshot and post that, if it’s in text, post it in message by doing three backticks in the line above, and the line afterwards.
It should look like this (```). I would love to help you with your code, but obviously I can’t do that if I can’t see it. You could also try downloading your code again, sometimes that helps.
You may have forgotten to reverse some motors, or reversed the wrong motors. You could look at your setup to see. Another way to try to fix the problem is to reuse the old code if you have it saved.
The thing is that it’s just drivetrain configuration. Like, I set up the drivetrain for split arcade with the controller. We’ve elected to do this because we just converted the drive from a 3 motor to a four motor, and it’s the quickest and easiest way to do that.
This is most likely the issue. But the thing is, it’s not doing the same thing every time. It’s like it’s procedurally generating ways to mess up. And it’s in a drivetrain, so I’m not exactly sure how to individually reverse motors.
I would normally absolutely do this. However, this is the only version of code we have that has a 4 motor drive, and going back through and converting old code is honestly more trouble than it’s worth. We’ve tried it once already, and literally nothing on the code worked. As in, the controller wasn’t responding to anything. I’m usually a really solid programmer, but this is really baffling me.
I posted screenshots below of the controller config and the drivetrain setup, just in case anything there is faulty, which it very well could be.
Did you comment out or delete the previous code? It may be that both the old code and the new drivetrain are simultaneously sending conflicting motor instructions.
This looks like vexcode pro. This is how you can reverse individual motors. However, you will have to code the arcade drive yourself.
Go to robotconfig.cpp and you should see something like this:
motor Left1 = motor(PORT1, ratio6_1, false);
motor Left2 = motor(PORT2, ratio6_1, false);
motor Right1 = motor(PORT4, ratio6_1, false);
motor Right2 = motor(PORT5, ratio6_1, false);
motor_group leftDrive(Left1, Left2);
motor_group rightDrive(Right1, Right2);
drivetrain robot(leftDrive, rightDrive, 10.2101761, 10, 8, distanceUnits::in, 36/60);
Copy this code and put it in main.cpp. After this, remove the drivetrain you made with the gui in vexcode and code the drivetrain. Arcade drives look something like this:
int leftspeed = Controller1.Axis3.position + Controller1.Axis1.position;
int rightspeed = Controller1.Axis3.position - Controller1.Axis1.position;
This worked, with a little troubleshooting. Thank you so much!
Just to let you know, the turn function in auton won’t work like this. You may need to adjust the drivetrain parameters. It goes like this:
drivetrain robot(leftDrive, rightDrive, wheelTravel, trackWidth, wheelBase, distanceUnits, gearRatio)
The wheel travel is the wheel diameter times pi(3.1415).
The trackwidth is the width of the robot, wheel to wheel
The wheelbase is the length from axle to axle
The units can be inches or cm
The gear ratio is motor : driven.