Skip to content

Torso APIs

The TorsoFactoryPose4D class provides the following method for creating a torso instance.

  • Method:

    create_torso_from_config(config_path: str) -> TorsoInterfacePose4D
  • Parameter:

    ParameterDescription
    config_path

    Path 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.

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.

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.SUCCESS indicates success. For other error codes, please refer to AbcErrorCode.

You can disconnect from the torso using the following method.

  • Method:

    disconnect(self) -> alphabot.core.AbcErrorCode
  • Return Value:

    AbcErrorCode.SUCCESS indicates success. For other error codes, please refer to AbcErrorCode.

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:

    Parameter
    Description
    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 False or True.
    - 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.SUCCESS indicates success. For other error codes, please refer to AbcErrorCode.

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:

    Parameter
    Description
    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 False or True.
    - 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.SUCCESS indicates success. For other error codes, please refer to AbcErrorCode.

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:

    Parameter
    Description
    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 False or True.
    - 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.SUCCESS indicates success. For other error codes, please refer to AbcErrorCode.

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:

    Parameter
    Description
    jointsTarget joint positions, in degrees.
  • Return Value:

    AbcErrorCode.SUCCESS indicates success. For other error codes, please refer to AbcErrorCode.

  • Method:

    get_joint_degree(self) -> tuple[alphabot.core.AbcErrorCode, list[float]]
  • Return Value:

    A tuple containing two elements.

    Element TypeDescription
    AbcErrorCodeAbcErrorCode.SUCCESS indicates success. For other error codes, please refer to AbcErrorCode.
    list[float]Current joint angles.
  • Method:

    get_error_flag(self) -> tuple[alphabot.core.AbcErrorCode, list[int]]
  • Return Value:

    A tuple containing two elements.

    Element TypeDescription
    AbcErrorCodeAbcErrorCode.SUCCESS indicates success. For other error codes, please refer to AbcErrorCode.
    list[int]Error codes.
  • Method:

    forward_kinematics(
    self,
    joints: list[float]
    ) -> tuple[alphabot.core.AbcErrorCode, alphabot.core.AbcTorsoPose4D]
  • Parameter:

    Parameter
    Description
    jointsJoint angles.
  • Return Value:

    A tuple containing two elements.

    Element TypeDescription
    AbcErrorCodeAbcErrorCode.SUCCESS indicates success. For other error codes, please refer to AbcErrorCode.
    AbcTorsoPose4DPose computed by forward kinematics. For details, please refer to AbcTorsoPose4D.
  • Method:

    inverse_kinematics(
    self,
    pose: alphabot.core.AbcTorsoPose4D,
    ref_joints: list[float],
    mode: int = 0
    ) -> tuple[alphabot.core.AbcErrorCode, list[float]]
  • Parameters:

    Parameter
    Description
    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 TypeDescription
    AbcErrorCodeAbcErrorCode.SUCCESS indicates success. For other error codes, please refer to AbcErrorCode.
    list[float]Joint angles computed by inverse kinematics.
  • Method:

    set_torso_state_callback(self, arg0: typing.Callable) -> None
  • Parameter:

    Parameter
    Description
    arg0The callback function is called whenever a torso state update is received. The callback function receives a parameter of type AbcTorsoState.
  • Return Value:

    None.

  • Method:

    get_name(self) -> str
  • Return Value:

    The name of the torso instance.

AttributeData TypeDescription
err_codelist[int]Error codes for each joint
joints_currentlist[float]Current for each joint
joints_positionslist[float]Angle for each joint
joints_speedlist[float]Speed for each joint
timestamptyping.AnyTimestamp