View Single Post
  #21   Spotlight this post!  
Unread 31-12-2016, 11:39
Ether's Avatar
Ether Ether is offline
systems engineer (retired)
no team
 
Join Date: Nov 2009
Rookie Year: 1969
Location: US
Posts: 7,995
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: Drivetrain PID tuning

Quote:
Originally Posted by Jaci View Post
Code:
float gyro_heading = ... your gyro code ...
float desired_heading = get_heading(time, profile);
float delta_angle = desired_heading - gyro_heading; // This is our error in alignment
float turn_power = 0.8 * (-1/80) * delta_angle;   // Change these coefficients as required...
It might be helpful to slightly modify one line of code:

float delta_angle = desired_heading - gyro_heading; // This is our error in alignment

float delta_angle = MATH.IEEEremainder(desired_heading - gyro_heading,360); // This is our error in alignment


https://www.chiefdelphi.com/forums/s...3&postcount=36
https://msdn.microsoft.com/en-us/lib...vs.110%29.aspx
http://en.cppreference.com/w/cpp/numeric/math/remainder



Last edited by Ether : 31-12-2016 at 12:08. Reason: added hyperlinks
Reply With Quote