motor subpackage
Introduction
The “motor” subpackage of the RoCS Client SDK provides functionalities related to controlling and managing robot motors. It allows you to enable or disable specific motors, set motor parameters, move motors to desired angles, and retrieve motor-related information.
Modules
rocs_client.motor.motor: Module for motor control and management.
motor module
- class rocs_client.motor.motor.Motor(ssl: bool = False, host: str = '127.0.0.1', port: int = 8001)
Bases:
RobotBase
- disable_hand()
Disable the Hand for individual control.
- disable_motor(no: str, orientation: str)
Disable the specified motor.
- Parameters:
no (str) – Motor number.
orientation (str) – Motor orientation.
- enable_hand()
Enable the Hand for individual control.
- enable_motor(no: str, orientation: str)
Enable the specified motor.
- Parameters:
no (str) – Motor number.
orientation (str) – Motor orientation.
- get_hand_position()
Get the current position of the robot’s hand.
- Returns:
- Return data with the following fields:
code (int): Return code. 0 indicates success, -1 indicates failure.
msg (str): Return message. “ok” indicates normal, failure returns an error message.
data (dict): Data object containing specific data.
- Return type:
Dict
- get_motor_pvc(no, orientation: str)
Get the Position, Velocity, and Current (PVC) information for a specific motor.
- Parameters:
no (str) – Motor number.
orientation (str) – Motor orientation.
- Returns:
- Return data with the following fields:
code (int): Return code. 0 indicates success, -1 indicates failure.
msg (str): Return message. “ok” indicates normal, failure returns an error message.
data (dict): PVC information including position, velocity, and current.
- Return type:
Dict
Examples:
{ "code": 0, "msg": "ok", "data": { "no": "4", "orientation": "right", "position": "85.00", "velocity": "0.0123", "current": "0.85674" } }
- limits: list
- move_motor(no, orientation: str, angle: float)
Move a specific motor to the specified angle.
- Parameters:
no (str) – Motor number.
orientation (str) – Motor orientation.
angle (float) – Target angle for the motor.
- set_motor_pd(no: str, orientation: str, p: float = 0.36, d: float = 0.042)
Set the parameters for a Proportional-Derivative (PD) control mode for a specific motor.
This function allows you to configure the proportional (P) and derivative (D) gains for the motor. Providing valid values for ‘no’ (motor number), ‘orientation’ (motor orientation), ‘p’ (proportional gain), and ‘d’ (derivative gain) is crucial for accurate and stable motor control.
- Parameters:
no (str) – Motor number.
orientation (str) – Motor orientation.
p (float) – Proportional gain value.
d (float) – Derivative gain value.
- set_motor_pd_flag(no: str, orientation: str)
Set PD mode for a specific motor.
- Parameters:
no (str) – Motor number.
orientation (str) – Motor orientation.
- class rocs_client.motor.motor.MotorScheme(no: str, orientation: str, angle: float = 0)
Bases:
object
MotorScheme Class
Represents a motor with specific attributes.
- Attribute:
no (str): The identifier or label for the motor.
orientation (str): The orientation of the motor.
angle (float, optional): The angle associated with the motor. Defaults to 0.
Example
# Creating an instance of the Motor class
motor_instance = Motor(no=”1”, orientation=”Vertical”, angle=45.0)
Note
The Motor class is decorated with the @dataclass decorator, which automatically generates special methods like __init__ based on the class attributes.
- angle: float = 0
- no: str
- orientation: str