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

Add torque management #199

Merged
merged 2 commits into from
Aug 14, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions pyluos/services/load.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
from .service import Service
import time


class Load(Service):
Expand Down
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
Loading