Quote:
Originally Posted by Mark McLeod
P.S.
Not that you've said you have this issue, but if turning at low power is a problem with your robot you can also do something in software that doesn't require adding sensors, physically changing the gearing, or swapping out sticky wheels for slicks.
In your code you can avoid applying the power reduction to any turning component or make just turning a higher percentage. For example, if one of your joysticks is forward and the other is backward, then don't reduce the power to the joysticks. If they are both forward but to varying degrees, so you get a curved driving path, then leave the difference between the sticks alone and only reduce the straight component.
|
Here's one possible implementation of what Mark has suggested:
Let Y1 be the left joystick command and Y2 be the right joystick command.
Then compute these modified joystick commands:
Y1' = [(a+1)*Y1 + (a-1)*Y2]/2
Y2' = [(a-1)*Y1 + (a+1)*Y2]/2
where "a" is your speed adjustment factor, e.g. 0.25
Then send the modified Y1' and Y2' commands to the tank drive vi.
This transformation yields Y1' and Y2' values which are always in the range -1 to +1 (assuming that Y1 and Y2 were in that range).
It also handles cases where [(Y1>0) and (Y2<0)] or [(Y1<0) and (Y2>0)], so no conditional logic is required.