|
Re: Manual Velocity PID, anyone successful?
Gyro yaw correction sample pseudocode:
--------
Angular_Vel = Gyro_Value - GYRO_CENTER;
Error = Desired_Angular_Vel - Angular_Vel; // Set Desired to 0 to go straight
Left_Drive += K * Angular_Vel;
Right_Drive -= K * Angular_Vel;
--------
Define K to be a constant somewhere.
The +/- may vary depending on the gyro orientation (upside down) or drivetrain definition of forward.
Also, be sure to check the bounds on your drive motors (final value must be between 0 and 254).
Watch the types (signed, unsigned, char, int) you choose so as not to overflow.
|