Skip to content

Commit

Permalink
Merge pull request #827 from snozawa/robot_check_pdcontroller
Browse files Browse the repository at this point in the history
Add check for m_robot in PDcontroller (#796)
  • Loading branch information
fkanehiro committed Sep 27, 2015
2 parents 711c373 + 7054a11 commit 4699727
Showing 1 changed file with 9 additions and 1 deletion.
10 changes: 9 additions & 1 deletion rtc/PDcontroller/PDcontroller.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -157,7 +157,15 @@ RTC::ReturnCode_t PDcontroller::onExecute(RTC::UniqueId ec_id)
qold[i] = q;
qold_ref[i] = q_ref;
m_torque.data[i] = -(q - q_ref) * Pgain[i] - (dq - dq_ref) * Dgain[i];
double tlimit = m_robot->joint(i)->climit * m_robot->joint(i)->gearRatio * m_robot->joint(i)->torqueConst * tlimit_ratio[i];
double tlimit;
if (m_robot && m_robot->numJoints() == dof) {
tlimit = m_robot->joint(i)->climit * m_robot->joint(i)->gearRatio * m_robot->joint(i)->torqueConst * tlimit_ratio[i];
} else {
tlimit = (std::numeric_limits<double>::max)() * tlimit_ratio[i];
if (i == 0 && loop % 500 == 0) {
std::cerr << "[" << m_profile.instance_name << "] m_robot is not set properly!! Maybe ModelLoader is missing?" << std::endl;
}
}
if (loop % 100 == 0 && m_debugLevel == 1) {
std::cerr << "[" << m_profile.instance_name << "] joint = "
<< i << ", tq = " << m_torque.data[i] << ", q,qref = (" << q << ", " << q_ref << "), dq,dqref = (" << dq << ", " << dq_ref << "), pd = (" << Pgain[i] << ", " << Dgain[i] << "), tlimit = " << tlimit << std::endl;
Expand Down

0 comments on commit 4699727

Please sign in to comment.