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

Accessors for af joints #241

Open
wants to merge 3 commits into
base: ambf-2.0
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
25 changes: 25 additions & 0 deletions ambf_framework/afFramework.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3232,6 +3232,19 @@ bool afJointController::createFromAttribs(afJointControllerAttributes *a_attribs
return true;
}

////
/// \brief afCartesianController::setLinearGains
/// \param a_P
/// \param a_I
/// \param a_D
///
void afJointController::setLinearGains(double a_P, double a_I, double a_D){
m_P = a_P;
m_I = a_I;
m_D = a_D;
}


double afJointController::computeOutput(double process_val, double set_point, double current_time){
uint n = queue_length - 1;
for (uint i = 0 ; i < n ; i++){
Expand Down Expand Up @@ -3782,6 +3795,18 @@ double afJoint::getEffort(){
}


void afJoint::setLinearGains(double a_P, double a_I, double a_D) {
this->m_controller.setLinearGains(a_P, a_I, a_D);
}

vector<double> afJoint::getLinearGains() {
vector<double> v;
v.push_back(this->m_controller.getP_lin());
v.push_back(this->m_controller.getI_lin());
v.push_back(this->m_controller.getD_lin());
return v;
}

///
/// \brief afSensor::afSensor
/// \param a_afWorld
Expand Down
13 changes: 13 additions & 0 deletions ambf_framework/afFramework.h
Original file line number Diff line number Diff line change
Expand Up @@ -404,6 +404,13 @@ class afJointController: public afJointControllerAttributes{
// Store the last effort command to compute and bound max impulse
double m_last_cmd = 0;

// Get Controller Gains
inline double getP_lin(){return m_P;}
inline double getI_lin(){return m_I;}
inline double getD_lin(){return m_D;}

void setLinearGains(double a_P, double a_I, double a_D);

double computeOutput(double process_val, double set_point, double current_time);

void boundImpulse(double& effort_cmd);
Expand Down Expand Up @@ -1350,6 +1357,12 @@ class afJoint: public afBaseObject{

bool isFeedBackEnabled(){return m_enableFeedback;}

// Set the gain of this joint
void setLinearGains(double a_P, double a_I, double a_D);

// Get the gain of this joint
vector<double> getLinearGains();

protected:

string m_childName;
Expand Down