Skip to content

Head APIs

The HeadFactory class provides the following method for creating a head instance.

  • Method:

    create_head_from_config(config_path: str) -> HeadInterface
  • Parameter:

    ParameterDescription
    config_path

    Path to the configuration file. The configuration file must be a JSON file.

    {
    "head_type":"ti5", # Head vendor
    "head_name":"ti5_head", # Head name
    "head_joint_num":2, # Number of head joints
    "can_device":"can0", # CAN device name
    "can_id":0, # CAN node ID (0x00~0xFF)
    "motor_params":[ # Motor parameters
    {
    "motor_id":5, # Motor ID
    "reduction_ratio":51, # Reduction ratio
    "position_max":90, # Maximum rotation angle
    "position_min":-90.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 HeadInterface instance if creation succeeds, otherwise None.

The HeadInterface class provides a series of public methods for controlling the head, such as obtaining head joint angles and controlling head trajectories. Ensure a head instance has been created before using these methods.

After creating a head instance, you can establish a connection to the head 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 head 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 head 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 head 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 head via CAN FD (Controller Area Network Flexible Data-rate), bypassing trajectory planning by the controller. If the method is called correctly, the head 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.Pose]
  • 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.
    PosePose computed by forward kinematics. For details, please refer to Pose.
  • Method:

    get_name(self) -> str
  • Return Value:

    The name of the head 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