hello-robot/stretch_body

External system exit on Robot leads to a dirty exit messages occasionally

Closed this issue · 1 comments

Example, while running gamepad in one terminal and in another terminal executing the command pkill gamepad would lead to the following error output from dynamixel X chain.

For use with S T R E T C H (R) from Hello Robot Inc.
---------------------------------------------------------------------

Key mapped to End-Of-Arm Tool: eoa_wrist_dw3_tool_sg3
Caught signal 15
[WARNING] [wrist_roll]: Dynamixel communication error during enable_pos on wrist_roll: 
Traceback (most recent call last):
  File "/home/hello-robot/repos/stretch_body/body/stretch_body/gamepad_teleop.py", line 458, in mainloop
    self.step_mainloop()
  File "/home/hello-robot/repos/stretch_body/body/stretch_body/gamepad_teleop.py", line 449, in step_mainloop
    self.do_motion(robot=robot)
  File "/home/hello-robot/repos/stretch_body/body/stretch_body/gamepad_teleop.py", line 245, in do_motion
    self.command_robot_joints(robot)
  File "/home/hello-robot/repos/stretch_body/body/stretch_body/gamepad_teleop.py", line 175, in command_robot_joints
    self.wrist_roll_command.stop_motion(robot)
  File "/home/hello-robot/repos/stretch_body/body/stretch_body/gamepad_joints.py", line 490, in stop_motion
    motor.set_velocity(0,self.params['motion']['max']['accel'])
  File "/home/hello-robot/repos/stretch_body/body/stretch_body/dynamixel_hello_XL430.py", line 611, in set_velocity
    self.motor.set_vel(t_des)
  File "/home/hello-robot/repos/stretch_body/body/stretch_body/dynamixel_XL430.py", line 613, in set_vel
    dxl_comm_result, dxl_error = self.packet_handler.write4ByteTxRx(self.port_handler, self.dxl_id,
  File "/home/hello-robot/.local/lib/python3.10/site-packages/dynamixel_sdk/protocol2_packet_handler.py", line 675, in write4ByteTxRx
    return self.writeTxRx(port, dxl_id, address, 4, data_write)
  File "/home/hello-robot/.local/lib/python3.10/site-packages/dynamixel_sdk/protocol2_packet_handler.py", line 643, in writeTxRx
    rxpacket, result, error = self.txRxPacket(port, txpacket)
  File "/home/hello-robot/.local/lib/python3.10/site-packages/dynamixel_sdk/protocol2_packet_handler.py", line 346, in txRxPacket
    rxpacket, result = self.rxPacket(port)
  File "/home/hello-robot/.local/lib/python3.10/site-packages/dynamixel_sdk/protocol2_packet_handler.py", line 257, in rxPacket
    rxpacket.extend(port.readPort(wait_length - rx_length))
  File "/home/hello-robot/.local/lib/python3.10/site-packages/dynamixel_sdk/port_handler.py", line 78, in readPort
    return self.ser.read(length)
  File "/usr/lib/python3/dist-packages/serial/serialposix.py", line 565, in read
    ready, _, _ = select.select([self.fd, self.pipe_abort_read_r], [], [], timeout.time_left())
  File "/home/hello-robot/repos/stretch_body/body/stretch_body/hello_utils.py", line 296, in thread_service_shutdown
    raise ThreadServiceExit
stretch_body.hello_utils.ThreadServiceExit

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/home/hello-robot/.local/bin/stretch_gamepad_teleop.py", line 11, in <module>
    gamepad_teleop.mainloop()
  File "/home/hello-robot/repos/stretch_body/body/stretch_body/gamepad_teleop.py", line 461, in mainloop
    self.robot.stop()
  File "/home/hello-robot/repos/stretch_body/body/stretch_body/robot.py", line 358, in stop
    self.devices[k].stop()
  File "/home/hello-robot/repos/stretch_body/body/stretch_body/dynamixel_X_chain.py", line 111, in stop
    self.motors[motor].stop(close_port=False)
  File "/home/hello-robot/repos/stretch_body/body/stretch_body/wrist_roll.py", line 26, in stop
    self.enable_float_mode()
  File "/home/hello-robot/repos/stretch_body/body/stretch_body/wrist_roll.py", line 21, in enable_float_mode
    self.enable_pos_current_ctrl(current_limit=self.params['current_float_A'])
  File "/home/hello-robot/repos/stretch_body/body/stretch_body/dynamixel_hello_XL430.py", line 676, in enable_pos_current_ctrl
    self.motor.disable_torque()
  File "/home/hello-robot/repos/stretch_body/body/stretch_body/dynamixel_XL430.py", line 457, in disable_torque
    self.handle_comm_result('XL430_ADDR_TORQUE_ENABLE', dxl_comm_result, dxl_error)
  File "/home/hello-robot/repos/stretch_body/body/stretch_body/dynamixel_XL430.py", line 279, in handle_comm_result
    raise DynamixelCommError(comm_error_msg)
stretch_body.dynamixel_XL430.DynamixelCommError: DXL Comm Error on /dev/hello-dynamixel-wrist ID 16. Attempted XL430_ADDR_TORQUE_ENABLE. Result COMM_PORT_BUSY. Error 0. Total Errors 2.

This PR seems to have resolved this issue #278