View Single Post
  #8   Spotlight this post!  
Unread 15-12-2010, 13:14
Ether's Avatar
Ether Ether is offline
systems engineer (retired)
no team
 
Join Date: Nov 2009
Rookie Year: 1969
Location: US
Posts: 8,065
Ether has a reputation beyond reputeEther has a reputation beyond reputeEther has a reputation beyond reputeEther has a reputation beyond reputeEther has a reputation beyond reputeEther has a reputation beyond reputeEther has a reputation beyond reputeEther has a reputation beyond reputeEther has a reputation beyond reputeEther has a reputation beyond reputeEther has a reputation beyond repute
Re: HELP with TANK DRIVE PROGRAMMING

Quote:
Originally Posted by Mark McLeod View Post
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.



Reply With Quote