Skip to content

Commit

Permalink
Add torque management on servomotors
Browse files Browse the repository at this point in the history
  • Loading branch information
nicolas-rabault committed Aug 1, 2024
1 parent 3c5056f commit 111bdf8
Showing 1 changed file with 30 additions and 0 deletions.
30 changes: 30 additions & 0 deletions pyluos/services/servoMotor.py
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,7 @@ def __init__(self, id, alias, device):
self._target_rot_position = 0.0
self._target_trans_speed = 0.0
self._target_trans_position = 0.0
self._target_torque = 0.0

# report modes
self._rot_position = 0.0
Expand Down Expand Up @@ -390,6 +391,35 @@ def target_trans_position(self, s):
else :
self._push_value("target_trans_position", s)

# torque
@property
def target_torque(self):
if (self._config[ServoMotor._MODE_TORQUE] != True):
print("torque mode could be not enabled in the service please use 'device.service.torque_mode = True' to enable it")
return self._target_torque

@target_torque.setter
def target_torque(self, s):
self._target_torque = s
self._push_value("target_torque", s)

@property
def torque_mode(self):
return self._config[ServoMotor._MODE_TORQUE]

@torque_mode.setter
def torque_mode(self, enable):
self._config[ServoMotor._MODE_TORQUE] = True if enable != 0 else False
if (enable == True) :
self._config[ServoMotor._MODE_LINEAR_POSITION] = False
self._config[ServoMotor._MODE_POWER] = False
self._config[ServoMotor._MODE_ANGULAR_POSITION] = False
self._config[ServoMotor._MODE_ANGULAR_SPEED ] = False
self._config[ServoMotor._MODE_LINEAR_SPEED] = False
self._push_value('parameters', self._convert_config())
time.sleep(0.01)


@property
def trans_position_mode(self):
return self._config[ServoMotor._MODE_LINEAR_POSITION]
Expand Down

0 comments on commit 111bdf8

Please sign in to comment.