Update:
@superbam
@cyclicalobsessive
@KeithW
I am curious how you calculated your turns.
I am working on how to calculate the ratio of the wheel speeds to get the degree of turn I desire based on how far forward the joystick is pressed and how far to the side it is pushed.
(Right now, I am ignoring sign which is forward/back and left/right since once I get a smooth turn based on the two axes, I can always flip the sign for the other direction.)
My current calculations are based on the following:
- Assume the joystick is being pushed forward, so the y-axis value is increasing.
- It’s actually increasing in the negative direction, but I am ignoring sign for the time being)
- Assume a x-axis deflection between zero and one. (centered to all the way to one side.
- Y-axis further forward, (closer to 1), means faster travel up to the limit set by max_speed. (actual_speed = |max_speed * y_axis|)
- As the x-axis is moved further away from center, the ratio of the speeds of the outside wheel to the inside wheel should become greater. (i.e. The inside wheel should become slower as the x-axis is deflected more.
I came up with one formula where the inside wheel was a fraction of max_speed, which didn’t work.
I have modified the formula as follows:
(Note: I haven’t tried this on Charlie yet.)
actual_speed = max_speed * abs(y_axis)
percent_speed = int(((y_axis / x_axis) / 2 ) * 100)
Where
- actual_speed is the forward speed if x_axis = 0 and is the speed of the outside wheel during a turn.
- percent_speed is the percentage of actual_speed that the inside wheel gets.
- “int” is a function that I will probably have to write so that both positive and negative numbers round away from zero to the nearest integer.
- +1.5 => +2
- -1.5 => -2
As it is, the rounding methods available in Python round negative numbers toward zero. - +1.5 => +2
- -1.5 => -1
- -0.5 => ZERO!
Sigh. . . .