View Single Post
  #4   Spotlight this post!  
Unread 26-08-2010, 10:11
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: Auto trimming using the gyro

Quote:
Originally Posted by baronep View Post
I need to figure out the correct formula to modify the z joystick value based on the gyro input and the current z axis joystick input (as if I were turning).

Does anyone have any ideas as to how to do this?

You could try the following simple approach, which is similar to what Team 341 (Miss Daisy) used successfully:


Code:
if (Z!=0) Z'=Z else Z'=-K*gyro_rate;

Z is the joystick value from its "rotate" command axis

Z' is the modified value of Z

gyro_rate is the rotation speed reading from the gyro

K is a tuning constant, which you can adjust experimentally.



what the code does is this:

a) when you are commanding rotation (Z is not zero), your rotate command (Z) is passed through unmodified as an open-loop command

b) when you are commanding zero rotation (ie Z is zero), the gyro's rotation signal is used instead of Z=0 to create a Z command to cancel out the rotation.


A slightly different approach might be:

Code:
Z' = K*(Z-gyro_rate);
... which is a "P" (proportional) controller which uses your joystick Z value and the gyro signal to create the modified Z' command. This controller acts to make the robot's sensed rotational velocity match the joystick command regardless of whether it is zero or non-zero.

~

Last edited by Ether : 26-08-2010 at 11:34.
Reply With Quote