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

Allow to change to torque control mode #1326

Open
wants to merge 26 commits into
base: master
Choose a base branch
from

Conversation

rafaelxero
Copy link
Contributor

This PR is to bring the modifications of https://github.com/rafaelxero/hrpsys-base/tree/PosTorqueCtrl-rebase (which I used for my torque control experiments) to master branch.
It basically allows to change the joint control mode to torque and adds some functions to iob.h.
I have removed code that was not ultimately used.

…e maximum difference between angle and command, and added test for the torque
…a check if a new tauRef does not delay for more than a number of cycles
…mented out a protection for the current angles that causes problems
lib/io/iob.cpp Outdated
@@ -527,18 +527,32 @@ int read_ulimit_angle(int id, double *angle)
{
return FALSE;
}

Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It is better to minimize diff.

* @retval FALSE otherwise
*/
int write_ulimit_angle(int id, double angle);

Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Are these necessary? They are not called in this PR.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@fkanehiro In this PR they are not used, but in the PosTorqueCtrl-rebase branch of hrp5p-iob, that I will try to merge soon, I have a standalone program called modify_joint_limits (https://github.com/isri-aist/hrp5p-iob/blob/PosTorqueCtrl-rebase/iob/modify_joint_limits.cpp) that uses those functions

Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If they are not relevant to this PR, I think they should be removed from this PR.

In addition, as adding APIs will break compatibility, you need to use ROBOT_IOB_VERSION to add APIs.
Moreover, I prefer not to add these APIs. Because they will enable normal users to implement dangerous programs.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Got it... I have removed these APIs in d8d245f



bool allowTorqueControlMode; // Added by Rafa

Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please remove "... by Rafa" :-)

@@ -61,7 +62,8 @@ RobotHardware::RobotHardware(RTC::Manager* manager)
m_rstate2Out("rstate2", m_rstate2),
m_RobotHardwareServicePort("RobotHardwareService"),
// </rtc-template>
dummy(0)
allowTorqueControlMode(true),
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is this necessary? There is no way to change its value.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sorry for this, it remained after being used by code which was not ultimately used and that I erased
Solved by d068033

@@ -1048,18 +1050,18 @@ bool robot::setJointControlMode(const char *i_jname, joint_control_mode mode)
for (int i=0; i < numJoints(); i++) {
write_control_mode(i, mode);
}
std::cerr << "[RobotHardware] setJointControlMode for all joints : " << mode << std::endl;
// std::cerr << "[RobotHardware] setJointControlMode for all joints : " << mode << std::endl; // Commented out by Rafa
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It is better not to change the current behavior.

Comment on lines 665 to +672
bool robot::checkEmergency(emg_reason &o_reason, int &o_id)
{
int state;
joint_control_mode mode;
for (unsigned int i=0; i<numJoints(); i++){
read_servo_state(i, &state);
if (state == ON && m_servoErrorLimit[i] != 0){
read_control_mode(i, &mode);
if (state == ON && m_servoErrorLimit[i] != 0 && mode != JCM_TORQUE){
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In current JSK JAXON control board's imprementation,

  • JCM_POSITION means position control.
  • JCM_TORQUE means position control + command_torque.

While the robot is hanged by the crane, we use JCM_TORQUE with high position pdgain. After the robot is put on the ground, we reduce position pdgain (or set position pdgain to zero).

If JCM_TORQUE with high position pdgain, servoErrorLimitCheck is necessary.
If JCM_TORQUE with low (or zero) position pdgain, servoErrorLimitCheck should be deactivated.

We currently modify read_servo_state function in our iob.cpp to switch servoErrorLimitCheck.

int read_servo_state(int id, int *s)
{
  *s = 0;
  if (servo_state[id] == ON &&
      pgain[id] > THRESHOLD)
    *s = 1;
  return TRUE;
}

After this PR is merged, JCM_TORQUE mode always disables servoErrorLimitCheck. So we have to change our software. @kindsenior

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.

3 participants