Skip to content

Getting Started

This section will help you quickly master the basic structure and usage of the Python API.

Before you begin development, ensure your Python environment meets the following requirements:

  • Operating System: Ubuntu 22 or later.
  • Python: Version 3.10.

After setting up the Python development environment, you can install the alphabot module using the pip tool.

  1. Open a terminal and navigate to the python directory of the extracted SDK package.

    Terminal window
    cd python
  2. Install the alphabot module via pip.

    Terminal window
    pip install .

You can browse the .pyi interface files in the alphabot directory to understand the interface module organization.

The alphabot module provides several ready-to-use classes, which can be imported via from alphabot import <class_name>.

Class NameDescriptionModule
ArmFactoryCreates a robotic arm instancealphabot.arm
ArmFactoryParamDescribes robotic arm parameters
ArmInterfaceMain interface for robotic arm control
ArmForceSensorForce sensor data
ArmRealtimeStateReal-time state of the robotic arm
GripperStateGripper state
JointStateJoint state
PeripheralReadWriteParamsConfigures Modbus communication parameters
ChassisFactoryCreates a chassis instancealphabot.chassis
ChassisInterfaceMain interface for chassis control
ChassisBatteryChassis battery information
ChassisPoint32Footprint point position
ChassisPose2D2D pose of the chassis
ChassisPoseSpeedChassis pose and velocity
ChassisStateChassis state
ChassisStatusCodeChassis status codes
ChassisTransformStampedData related to static transforms
ChassisTwistChassis twist
ChassisOperationStateChassis operation state
NavStateChassis navigation information
RobotBitChassis bit information
HeadFactoryCreates a head instancealphabot.head
HeadInterfaceMain interface for head control
AbcHeadStateHead joint state
TorsoFactoryPose4DCreates a torso instancealphabot.torso
TorsoInterfacePose4DMain interface for torso control
AbcTorsoStateTorso joint state
SensorFactoryCreates sensors and depth camerasalphabot.sensor
SyncDataPackageSynchronized sensor data package
SyncModeSynchronization mode
SyncPolicySynchronization policy
RGBDataRGB image data
RGBDDataRGB + Depth image data
DepthCameraDepth camera
DepthSensorParamDepth sensor parameters
EStopMonitorEmergency stop button monitoralphabot.estop
EStopMConfigMonitor configuration
ESStateEmergency stop button state
ArmKinematicsRobotic arm kinematicsalphabot.algo
ArmTypeRobotic arm type
TorsoKinematicsTorso kinematics
admittance_control_lawAdmittance control law
AbcErrorCodeError codesalphabot.core
AbcTorsoPose4DTorso pose
ArmCurrentStatusCurrent robotic arm status code
EulerEuler angles
Pose3D pose
Position3D position
QuaternionQuaternion
SensorStatusSensor status
SensorTypeSensor type

Refer to the example programs under the examples directory to learn how to call core interfaces.

For example, the sample code in Python\examples\arm\arm_factory_example.py is shown below.

import sys
import os
from alphabot import ArmFactory, ArmFactoryParam
def main():
"""Main function"""
# Parameter validation
if len(sys.argv) < 2:
print(f"Usage: {sys.argv[0]} <configuration_file_path>")
print(f"Example: {sys.argv[0]} config/left_arm.json")
return 1
config_path = sys.argv[1]
print("===== ArmFactory Sample Program =====")
try:
print("\n----- Method 1: Creating a Robotic Arm Using Parameters -----")
# Configure robotic arm parameters
param = ArmFactoryParam({
"arm_type": "realman",
"arm_name": "right_arm",
"ip": "192.168.1.18",
"port": "8080",
"udp_ip": "192.168.1.102",
"udp_port": "8089",
"udp_cycle": "5"
})
# Create a robotic arm instance form arm parameters
arm1 = ArmFactory.create_arm(param)
if not arm1:
print("Failed to create robotic arm instance")
return 1
print(f"Successfully created robotic arm: {arm1}")
print("\n----- Method 2: Creating a Robotic Arm Using Configuration File -----")
# Create a robotic arm instance from configuration file
arm2 = ArmFactory.create_arm_from_config(config_path)
if not arm2:
print("Failed to create robotic arm instance from configuration file")
return 1
print(f"Successfully created robotic arm from configuration file: {arm2}")
return 0
except Exception as e:
print(f"Exception occurred: {e}")
return 1
if __name__ == "__main__":
sys.exit(main())

Through the above example program, you can quickly learn how to create an instance of the robotic arm interface and connect to the robotic arm. Other example programs follow similar structures and calling conventions. Please refer to more example programs for further learning.

The following uses Python\examples\arm\arm_factory_example.py as an example to explain the execution process.

  1. Open a terminal and navigate to the directory where the example program is located.

    Terminal window
    cd python/examples/arm
  2. Execute the python command to run the program. This example requires passing the robotic arm configuration file path as a parameter.

    Terminal window
    python arm_factory_example.py ../config/left_arm.json

The execution steps for other example programs are similar; follow the steps above.

Through this section, you have learned the basic structure and usage of the Python interface. We recommend further exploring other example programs and developing with reference to the Python API documentation.