Torso APIs
TorsoFactoryPose4D
Section titled “TorsoFactoryPose4D”The TorsoFactoryPose4D class provides the following method for creating a torso instance.
-
Method:
create_torso_from_config(config_path: str) -> TorsoInterfacePose4D -
Parameter:
Parameter Description config_pathPath to the configuration file. The configuration file must be a JSON file.
{"torso_type":"ti5", # Torso vendor"torso_name":"ti5_torso", # Torso name"torso_joint_num":4, # Number of Torso joints"can_device":"can0", # CAN device name"can_id":0, # CAN node ID (0x00~0xFF)"motor_params": [ # Motor parameters{"motor_id": 1, # Motor ID"reduction_ratio": 121, # Reduction ratio"position_max": 1.0, # Maximum rotation angle"position_min":-68.0, # Minimum rotation angle"speed_max": 30, # Maximum rotation speed"speed_min":-30, # Minimum rotation speed"acc_max": 10, # Maximum rotation acceleration"acc_min":-10 # Minimum rotation acceleration}]} -
Return value:
An TorsoInterfacePose4D instance if creation succeeds, otherwise
None.
TorsoInterfacePose4D
Section titled “TorsoInterfacePose4D”The TorsoInterfacePose4D class provides a series of public methods for controlling the torso, such as obtaining torso joint angles and controlling torso motion. Ensure a torso instance has been created before using these methods.
Connect to the Torso
Section titled “Connect to the Torso”After creating a torso instance, you can establish a connection to the torso using the following method.
-
Method:
connect(self) -> alphabot.core.AbcErrorCode -
Return Value:
AbcErrorCode.SUCCESSindicates success. For other error codes, please refer to AbcErrorCode.
Disconnect from the Torso
Section titled “Disconnect from the Torso”You can disconnect from the torso using the following method.
-
Method:
disconnect(self) -> alphabot.core.AbcErrorCode -
Return Value:
AbcErrorCode.SUCCESSindicates success. For other error codes, please refer to AbcErrorCode.
Joint Motion
Section titled “Joint Motion”In joint space, a motion trajectory is planned to drive each joint of the torso to the specified target joint positions.
-
Method:
move_joint_position(self,joints: list[float],v: int,block: bool) -> alphabot.core.AbcErrorCode -
Parameters:
ParameterDescription jointsTarget joint positions, in degrees. vPercentage of the maximum joint linear velocity and acceleration used for planning. Valid range: 0-100. blockBlocking mode flag. Accepts FalseorTrue.
-False: Non-blocking mode. The method returns immediately after successfully sending the motion command to the controller.
-True: Blocking mode. The method waits until the torso completes the motion or an error occurs before returning. -
Return Value:
AbcErrorCode.SUCCESSindicates success. For other error codes, please refer to AbcErrorCode.
Cartesian Linear Motion
Section titled “Cartesian Linear Motion”In Cartesian space, a linear motion trajectory is planned to move the torso along a straight line to the specified target pose.
-
Method:
move_cartesian_linear(self,pose: alphabot.core.AbcTorsoPose4D,v: int,block: bool) -> alphabot.core.AbcErrorCode -
Parameters:
ParameterDescription poseTarget pose. For details, please refer to AbcTorsoPose4D. vPercentage of the maximum joint linear velocity and acceleration used for planning. Valid range: 0-100. blockBlocking mode flag. Accepts FalseorTrue.
-False: Non-blocking mode. The method returns immediately after successfully sending the motion command to the controller.
-True: Blocking mode. The method waits until the torso completes the motion or an error occurs before returning. -
Return Value:
AbcErrorCode.SUCCESSindicates success. For other error codes, please refer to AbcErrorCode.
Move to Target Pose in Joint Space
Section titled “Move to Target Pose in Joint Space”In joint space, a motion trajectory is planned to move the torso to the specified target pose.
-
Method:
move_joint_pose(self,pose: alphabot.core.AbcTorsoPose4D,v: int,block: bool) -> alphabot.core.AbcErrorCode -
Parameters:
ParameterDescription poseTarget pose. For details, please refer to AbcTorsoPose4D. vPercentage of the maximum joint angular velocity and joint angular acceleration used for planning. Valid range: 0-100. blockBlocking mode flag. Accepts FalseorTrue.
-False: Non-blocking mode. The method returns immediately after successfully sending the motion command to the controller.
-True: Blocking mode. The method waits until the torso completes the motion or an error occurs before returning. -
Return Value:
AbcErrorCode.SUCCESSindicates success. For other error codes, please refer to AbcErrorCode.
Angle Pass-through
Section titled “Angle Pass-through”Joint angles are sent to the torso via CAN FD (Controller Area Network Flexible Data-rate), bypassing trajectory planning by the controller. If the method is called correctly, the torso executes the motion immediately.
-
Method:
move_joint_position_canfd(self, joints: list[float]) -> alphabot.core.AbcErrorCode -
Parameter:
ParameterDescription jointsTarget joint positions, in degrees. -
Return Value:
AbcErrorCode.SUCCESSindicates success. For other error codes, please refer to AbcErrorCode.
Get Current Joint Angles
Section titled “Get Current Joint Angles”-
Method:
get_joint_degree(self) -> tuple[alphabot.core.AbcErrorCode, list[float]] -
Return Value:
A tuple containing two elements.
Element Type Description AbcErrorCodeAbcErrorCode.SUCCESSindicates success. For other error codes, please refer to AbcErrorCode.list[float]Current joint angles.
Get Error Information
Section titled “Get Error Information”-
Method:
get_error_flag(self) -> tuple[alphabot.core.AbcErrorCode, list[int]] -
Return Value:
A tuple containing two elements.
Element Type Description AbcErrorCodeAbcErrorCode.SUCCESSindicates success. For other error codes, please refer to AbcErrorCode.list[int]Error codes.
Compute Forward Kinematics
Section titled “Compute Forward Kinematics”-
Method:
forward_kinematics(self,joints: list[float]) -> tuple[alphabot.core.AbcErrorCode, alphabot.core.AbcTorsoPose4D] -
Parameter:
ParameterDescription jointsJoint angles. -
Return Value:
A tuple containing two elements.
Element Type Description AbcErrorCodeAbcErrorCode.SUCCESSindicates success. For other error codes, please refer to AbcErrorCode.AbcTorsoPose4DPose computed by forward kinematics. For details, please refer to AbcTorsoPose4D.
Compute Inverse Kinematics
Section titled “Compute Inverse Kinematics”-
Method:
inverse_kinematics(self,pose: alphabot.core.AbcTorsoPose4D,ref_joints: list[float],mode: int = 0) -> tuple[alphabot.core.AbcErrorCode, list[float]] -
Parameters:
ParameterDescription poseThe target pose. For details, please refer to AbcTorsoPose4D. ref_jointsReference joint angles. modeSolution mode. Accepts 0 or 1. Default is 0.
-0: Single-step solution.
-1: Iterative search solution. -
Return Value:
A tuple containing two elements.
Element Type Description AbcErrorCodeAbcErrorCode.SUCCESSindicates success. For other error codes, please refer to AbcErrorCode.list[float]Joint angles computed by inverse kinematics.
Register Torso State Callback Function
Section titled “Register Torso State Callback Function”-
Method:
set_torso_state_callback(self, arg0: typing.Callable) -> None -
Parameter:
ParameterDescription arg0The callback function is called whenever a torso state update is received. The callback function receives a parameter of type AbcTorsoState. -
Return Value:
None.
Get Torso Name
Section titled “Get Torso Name”-
Method:
get_name(self) -> str -
Return Value:
The name of the torso instance.
AbcTorsoState
Section titled “AbcTorsoState”| Attribute | Data Type | Description |
|---|---|---|
err_code | list[int] | Error codes for each joint |
joints_current | list[float] | Current for each joint |
joints_positions | list[float] | Angle for each joint |
joints_speed | list[float] | Speed for each joint |
timestamp | typing.Any | Timestamp |