|
Re: Turning "Safety" Code
A few things:
You might not want to use set amounts subtracting from the pwms just because that will decrease the sensitivity, as in if the joystick is anywhere between 0 and 56, the speed will be the same. That assumes you aren't assigning the pwm anywhere else, and it's actually in neutral to begin with. If you are mapping the pwm to joystick elsewhere, you're going to run into problems with values going outside the expected range (negative values). Etiher way, it would probably be better to map the values and then multiply by a fraction to get the end result.
Also, this code doesn't only apply when turning. Keep in mind the subtraction will occur independant of the other side of the robot. Assuming you're using tank steering, the robot's max speed will have a reduction if the joysticks are at full forward. If you're using arcade steering, then you might want to check the y... It seems to be only referenced at the neutral point?
Have you tested this, by the way?
|