How to reduce sensitivity

Hey, so I’ve been using this simple drivetrain code for a lot of the season but I’ve noticed that it is pretty finicky and hard to control the robot. Specifically, I’ve seen random jolts of acceleration and rotation when barely pressing the forward or turning joystick. I was wondering if anyone could give any tips on how to make my code better so there is less sensitivity. Thanks!

Here is my code:

// Stopping the Robot with 0 push/pull of Axis 3 and 1
if (Controller.Axis3.value() == 0 and Controller.Axis1.value() == 0) {
FrontLeftDrive.stop(brakeType::coast); // brake or coast
BackLeftDrive.stop(brakeType::coast); // brake or coast
FrontRightDrive.stop(brakeType::coast); // brake or coast
BackRightDrive.stop(brakeType::coast); // brake or coast
}

// Drive - Left and Right Using Joystick Axis 3 and 1
else if ((Controller.Axis3.value() > 15 or Controller.Axis3.value() < -15) or (Controller.Axis1.value() > 15 or Controller.Axis1.value() < -15)){
FrontLeftDrive.spin(directionType::fwd, Controller.Axis3.value() - Controller.Axis1.value(), velocityUnits::pct);
BackLeftDrive.spin(directionType::fwd, Controller.Axis3.value() - Controller.Axis1.value(), velocityUnits::pct);
FrontRightDrive.spin(directionType::fwd, Controller.Axis3.value() + Controller.Axis1.value(), velocityUnits::pct);
BackRightDrive.spin(directionType::fwd, Controller.Axis3.value() + Controller.Axis1.value(), velocityUnits::pct);
}

This thread did a good job on the topic a while back: Anybody linearized the motor power yet? - #9 by callen

4 Likes

I’d recommend using voltage instead of velocity to control the motors. What’s the difference?

When you tell the motor to go at a specific velocity, the motor is going to work it’s hardest to stay at that velocity. If you told your drive to go forwards at 50% velocity, you’d see a kind of “herky jerky” motion, where it moves, slows down, then continues. You can hear this happen too.

When you use voltage, this middle step of controlling velocity is removed. So when you move at slower speeds, the robot will just move at that speed.

Velocity has its uses, but in my opinion, controlling a drive train in usercontrol is not one of them.

I have some example code here for how to code this, https://github.com/EZ-Robotics/VEXcode-Tutorials/tree/main/Joystick-Control. This is for tank drive, but it should be pretty easy to convert to arcade.

This is another great option! I’d suggest trying voltage first, then implementing the curve.

Good luck!

6 Likes

I’m not sure if this explains the behavior you’re seeing, but your code doesn’t give the drive any instructions if the joysticks are both between -15 and 15 but not 0. So let’s say you push the joystick forward to 16, and then back off to 5. Neither of your conditions apply (it’s not zero, and it’s not > 15) so the motors never get a new command, and they continue at 15%! If your joystick doesn’t return quite to zero, it could even keep driving after you let go of the joystick.

I’d change your initial if condition to the equivalent of “if both axes are between -15 and 15” (consider simplifying that expression with the abs function) and then your “else if” could just be an else.

15% may also be a bigger threshold than you really need.

5 Likes