Hello everyone. I would like to share how I got my joysticks to be less sensitive for driver control.
Disclaimer: I know this has been explained before in previous topics, but I would like to explain how I did it. I want to emphasize that I am using split control with a 4-wheel drivetrain in this example.
First of all, a normal linear joystick function for a drivetrain looks a little bit like this:
This follows a linear line. If you press the joystick 20%, the motors will drive at 20%. The problem with this is when you are trying to do slight movements, you end up not being able to move without moving to much. It is too finicky for fine movements.
A fix to this is using exponential functions for joystick control.
This is the line 0.0001x³, a cubic line that shares the points (0,0), (100,100), and (-100,-100) with the line x. This line allows for slight movements when pressing the joystick lightly. For example, pressing the joystick 20% only spins the motor at 0.8%, but pressing 100% will still spin the motor at 100%.
You might see the benefit of implementing exponential functions now, but coding them into your drivetrain code is a different problem. Some versions of this have already been explained by other users such as @Sarknought
The difference here is that it doesnāt use split control and Sarknought makes the cubic line using two asymptotes, which is much harder to do.
Here is my code (split control with a 4-wheel drivetrain):
# xā = Left Motor X = [Controller] [3] position + [Controller] [1] position
# xā = Right Motor X = [Controller] [3] position - [Controller] [1] position
# Sets each motor's velocity to 0.0001x³ (shown as 0.0001 * x * x * x)
FrontLeftMotor.set_velocity((0.0001 * (((controller_1.axis3.position() + controller_1.axis1.position()) * (controller_1.axis3.position() + controller_1.axis1.position())) * (controller_1.axis3.position() + controller_1.axis1.position()))), PERCENT)
BackLeftMotor.set_velocity((0.0001 * (((controller_1.axis3.position() + controller_1.axis1.position()) * (controller_1.axis3.position() + controller_1.axis1.position())) * (controller_1.axis3.position() + controller_1.axis1.position()))), PERCENT)
FrontRightMotor.set_velocity((0.0001 * (((controller_1.axis3.position() - controller_1.axis1.position()) * (controller_1.axis3.position() - controller_1.axis1.position())) * (controller_1.axis3.position() - controller_1.axis1.position()))), PERCENT)
BackRightMotor.set_velocity((0.0001 * (((controller_1.axis3.position() - controller_1.axis1.position()) * (controller_1.axis3.position() - controller_1.axis1.position())) * (controller_1.axis3.position() - controller_1.axis1.position()))), PERCENT)
# Spins motor according to the velocity set
FrontLeftMotor.spin(FORWARD)
FrontLeftMotor.spin(FORWARD)
FrontRightMotor.spin(FORWARD)
FrontLeftMotor.spin(FORWARD)
This code is able to get the results we want from the cubic line, and is able to do that by multiplying the joystick% by the line 0.0001x³.
With the simplicity of this code, it doesnāt have to be in C++, in fact I was able to code it in VEXcode v5 Blocks. For newer teams this could be really helpful for drivers who want a little bit more control over their movement.
I hope this makes sense. If you have any questions, please ask.
Payne Stroud
Team 39232