In the example, you’re directly subtracting the values of axis 3 and axis 1 to “layer” them. Why are we subtracting in this example? Because in this case, if my robot is turning, Motor1 will need to spin backward. So however much you turn is however much is subtracted from the motor percentage. Similarly, on the other side of the robot, say Motor4, it would be added instead of subtracted because if my robot is turning then I would need Motor4’s speed value to increase in order to turn.
As always, uploading the code in question makes these things go a lot faster.
A few questions:
1- Have you layered all the code?
2- Did you make all the possible movement diagrams to help you layer your code?
You should do what @Str0ngkatTh1rteen was saying and “layer” the joystick values by adding them so that you don’t have to use if/else statements. Something like
Thank You ALL so much for helping me finally get our drive working correctly. You will all get credit in our notebook and we appreciate you so much!
Sincerely,
21050A
It is, probably, beyond the scope of this topic, but just adding or subtracting joystick axis’ values and passing the sum as the motor control value is less than optimal.
It will kind of work, but if user pushes both sticks to the max - the value will end up 100+100 => 200 and any value over 100 pct will be clipped to 100 percent motor power, which will make controls more sensitive over the narrower range of joystick positions when inputs are combined.
The drivers will eventually learn how to control it, but there are alternative ways to map dual inputs that preserve full usable control range:
Also, some people feel like exponential joystick mapping gives them better control and precision over the robot movements both at low and high speeds: