Skip to content

Commit

Permalink
BUG: Add missing saturation to controller
Browse files Browse the repository at this point in the history
  • Loading branch information
eric-wieser committed May 19, 2017
1 parent 34e7902 commit 0eb24a5
Showing 1 changed file with 15 additions and 2 deletions.
17 changes: 15 additions & 2 deletions src/policy.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -62,14 +62,27 @@ void setPolicy(const Controller& new_controller)
policyTTParams = new_controller.turntable;
}

float saturate(float p){
// TODO: implement the same saturation as in simulation
if (p > 1) {
return 1;
}
else if (p < -1) {
return -1;
}
else {
return p;
}
}

//! compute the turntable output from the current policy, given the state
float policyTurntable(const LogEntry& state)
{
return computePolicy(policyTTParams, state);
return saturate(computePolicy(policyTTParams, state));
}

//! compute the wheel output from the current policy, given the state
float policyWheel(const LogEntry& state)
{
return computePolicy(policyWheelParams, state);
return saturate(computePolicy(policyWheelParams, state));
}

0 comments on commit 0eb24a5

Please sign in to comment.