Skip to content

Commit

Permalink
Merge pull request ros-controls#59 from ipa-mig/kinetic-devel
Browse files Browse the repository at this point in the history
rollback API changes in PID class
  • Loading branch information
bmagyar authored Jun 28, 2016
2 parents 2852da6 + 9b76491 commit 3c1ee1b
Show file tree
Hide file tree
Showing 3 changed files with 30 additions and 5 deletions.
4 changes: 1 addition & 3 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -58,12 +58,10 @@ add_library(${PROJECT_NAME}
src/sinusoid.cpp
src/limited_proxy.cpp
)
add_dependencies(${PROJECT_NAME} ${PROJECT_NAME}_gencfg) # wait for dynamic reconfigure
add_dependencies(${PROJECT_NAME} ${${PROJECT_NAME}_EXPORTED_TARGETS} ${catkin_EXPORTED_TARGETS})

target_link_libraries(${PROJECT_NAME} ${TinyXML_LIBRARIES} ${catkin_LIBRARIES} ${Boost_LIBRARIES})

add_dependencies(${PROJECT_NAME} ${PROJECT_NAME}_gencpp) # wait for msgs

if(CATKIN_ENABLE_TESTING)
# Tests
catkin_add_gtest(pid_tests test/pid_tests.cpp)
Expand Down
15 changes: 13 additions & 2 deletions include/control_toolbox/pid.h
Original file line number Diff line number Diff line change
Expand Up @@ -123,6 +123,15 @@ class Pid
*/
struct Gains
{
// Optional constructor for passing in values without antiwindup
Gains(double p, double i, double d, double i_max, double i_min)
: p_gain_(p),
i_gain_(i),
d_gain_(d),
i_max_(i_max),
i_min_(i_min),
antiwindup_(false)
{}
// Optional constructor for passing in values
Gains(double p, double i, double d, double i_max, double i_min, bool antiwindup)
: p_gain_(p),
Expand Down Expand Up @@ -183,7 +192,7 @@ class Pid
* \param i_max The max integral windup.
* \param i_min The min integral windup.
*/
void initPid(double p, double i, double d, double i_max, double i_min, bool antiwindup);
void initPid(double p, double i, double d, double i_max, double i_min, bool antiwindup = false);

/*!
* \brief Zeros out Pid values and initialize Pid-gains and integral term limits
Expand All @@ -195,6 +204,7 @@ class Pid
* \param i_max The max integral windup.
* \param i_min The min integral windup.
*/
void initPid(double p, double i, double d, double i_max, double i_min, const ros::NodeHandle& /*node*/);
void initPid(double p, double i, double d, double i_max, double i_min, bool antiwindup, const ros::NodeHandle& /*node*/);

/*!
Expand Down Expand Up @@ -242,6 +252,7 @@ class Pid
* \param i_max The max integral windup.
* \param i_min The min integral windup.
*/
void getGains(double &p, double &i, double &d, double &i_max, double &i_min);
void getGains(double &p, double &i, double &d, double &i_max, double &i_min, bool &antiwindup);

/*!
Expand All @@ -258,7 +269,7 @@ class Pid
* \param i_max The max integral windup.
* \param i_min The min integral windup.
*/
void setGains(double p, double i, double d, double i_max, double i_min, bool antiwindup);
void setGains(double p, double i, double d, double i_max, double i_min, bool antiwindup = false);

/*!
* \brief Set PID gains for the controller.
Expand Down
16 changes: 16 additions & 0 deletions src/pid.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,16 @@ Pid::~Pid()
{
}

void Pid::initPid(double p, double i, double d, double i_max, double i_min,
const ros::NodeHandle& /*node*/)
{
initPid(p, i, d, i_max, i_min);

// Create node handle for dynamic reconfigure
ros::NodeHandle nh(DEFAULT_NAMESPACE);
initDynamicReconfig(nh);
}

void Pid::initPid(double p, double i, double d, double i_max, double i_min, bool antiwindup,
const ros::NodeHandle& /*node*/)
{
Expand Down Expand Up @@ -192,6 +202,12 @@ void Pid::reset()
cmd_ = 0.0;
}

void Pid::getGains(double &p, double &i, double &d, double &i_max, double &i_min)
{
bool antiwindup;
getGains(p, i, d, i_max, i_min, antiwindup);
}

void Pid::getGains(double &p, double &i, double &d, double &i_max, double &i_min, bool &antiwindup)
{
Gains gains = *gains_buffer_.readFromRT();
Expand Down

0 comments on commit 3c1ee1b

Please sign in to comment.