Skip to content

Commit

Permalink
Merge pull request #27 from iory/effort
Browse files Browse the repository at this point in the history
Support torque vector using difference of reference and actual vectors
  • Loading branch information
iory authored Jan 20, 2024
2 parents 26b3f6d + 7700c1a commit c644047
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 0 deletions.
9 changes: 9 additions & 0 deletions rcb4/armh7interface.py
Original file line number Diff line number Diff line change
Expand Up @@ -404,6 +404,15 @@ def reference_angle_vector(self, servo_ids=None):
ServoStruct, slot_name='ref_angle')[servo_ids]
return ref_angles

def servo_error(self, servo_ids=None):
if servo_ids is None:
servo_ids = self.search_servo_ids()
if len(servo_ids) == 0:
return np.empty(shape=0)
error_angles = self.read_cstruct_slot_vector(
ServoStruct, slot_name='error_angle')[servo_ids]
return error_angles

def servo_id_to_index(self, servo_ids=None):
if servo_ids is None:
servo_ids = self.search_servo_ids()
Expand Down
3 changes: 3 additions & 0 deletions ros/kxr_controller/node_scripts/rcb4_ros_bridge.py
Original file line number Diff line number Diff line change
Expand Up @@ -349,6 +349,7 @@ def run(self):
break
try:
av = self.arm.angle_vector()
torque_vector = self.arm.servo_error()
except RuntimeError as e:
self.unsubscribe()
rospy.signal_shutdown('Disconnected {}.'.format(e))
Expand All @@ -362,6 +363,8 @@ def run(self):
msg.position.append(
np.deg2rad(
av[self.id_to_index[servo_id]]))
msg.effort.append(
torque_vector[self.id_to_index[servo_id]])
msg.name.append(name)
self.current_joint_states_pub.publish(msg)

Expand Down

0 comments on commit c644047

Please sign in to comment.