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

[RobotHardware/robot.cpp] send correct emergency signal when servo alarm #1324

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

Naoki-Hiraoka
Copy link
Contributor

@Naoki-Hiraoka Naoki-Hiraoka commented Sep 13, 2022

RobotHardwareからemergencySignalとしてEMG_SERVO_ERRORが出ていて、このif文によって全身がservo offするにも関わらず、

if (reason == robot::EMG_SERVO_ERROR || reason == robot::EMG_POWER_OFF){
m_robot->servo("all", false);

実際にはEMG_SERVO_ALARMが発生していて、EMG_SERVO_ERRORは発生していない、というバグがあります。

原因は、変数reasonはenumの初期値としてEMG_SERVO_ERRORが入っていて、

typedef enum {EMG_SERVO_ERROR, EMG_FZ, EMG_SERVO_ALARM, EMG_POWER_OFF} emg_reason;

SS_EMERGENCYが発生していてm_reportedEmergencytrueの場合には変数reasonが初期値のまま変更されずに返るためでした。

for (unsigned int i=0; i<numJoints(); i++){
if (!read_servo_alarm(i, &alarm)) continue;
if (alarm & SS_EMERGENCY) {
if (!m_reportedEmergency) {
m_reportedEmergency = true;
o_reason = EMG_SERVO_ALARM;
o_id = i;
}
return true;
}

このバグがあるとemergencyの原因をデバッグすることが困難になってしまうので、変数reasonEMG_SERVO_ALARMを入れてから返るように修正しました。

(関連)
2d088ad
#556
#564

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.

1 participant