Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged two "ifs" into one #85

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open

Conversation

madacol
Copy link

@madacol madacol commented Oct 17, 2018

Merged this two ifs:
if(!pOnE) outputSum-= kp * dInput;

if(pOnE) output = kp * error;
else output = 0;

into this one:

if(pOnE) output = kp * error;
else { outputSum -= kp * dInput; output = 0; }

I expect a performance improvement by the if reduction, or am I missing something?

I also separated the derivative computing from the ouputSum merging to add comments to indicate where each parameter is being computed.

Changed this:

      /*Compute Rest of PID Output*/
      output += outputSum - kd * dInput;

into this:

      /*Compute derivative*/
      output -= kd * dInput;
      /*Merge*/
      output += outputSum;

I believe it will compile the same, whether is separated or not. But if you don't like this part I'll remake the PR to remove this.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

1 participant