底盘相关接口
ChassisFactory
Section titled “ChassisFactory”ChassisFactory 类用于创建底盘实例。
-
方法原型:
create_chassis_from_config(config_file: str) -> ChassisInterface -
参数说明:
参数名称 说明 config_path配置文件路径。配置文件为 JSON 文件,包含以下键值对。
{"chassis_type":"xxx", # 底盘厂商"chassis_name":"chassis", # 底盘名称"ip":"127.0.0.1", # IP 地址"port":51051 # 端口号} -
返回值:
若创建成功,则返回 ChassisInterface 实例;否则返回
None。
ChassisFactoryParam
Section titled “ChassisFactoryParam”ChassisFactoryParam 类用于描述创建底盘时所需的参数。
| 属性 | 数据类型 | 说明 |
|---|---|---|
chassis_type | str | 底盘厂商。 |
chassis_name | str | 底盘名称,例如 "chassis"。 |
ip | str | IP 地址,例如 "127.0.0.1"。 |
port | int | 端口号,例如 54051。 |
ChassisInterface
Section titled “ChassisInterface”ChassisInterface 类提供了一系列用于控制底盘的公共方法,例如移动底盘、获取轮廓和查询状态等。在使用前,请确保已创建底盘实例。
在创建底盘实例后,用户可通过如下方法与底盘建立连接。
-
方法原型:
connect(self) -> alphabot.core.AbcErrorCode -
返回值:
AbcErrorCode.SUCCESS表示成功;其他错误码,请参见 AbcErrorCode。
用户可通过如下方法断开与底盘的连接。
-
方法原型:
disconnect(self) -> alphabot.core.AbcErrorCode -
返回值:
AbcErrorCode.SUCCESS表示成功;其他错误码,请参见 AbcErrorCode。
获取底盘位置和速度
Section titled “获取底盘位置和速度”-
方法原型:
get_pose_speed(self) -> tuple[alphabot.core.AbcErrorCode, ChassisPoseSpeed] -
返回值:
包含两个元素的元组。
元素数据类型 说明 AbcErrorCodeAbcErrorCode.SUCCESS表示成功;其他错误码,请参见 AbcErrorCode。ChassisPoseSpeed底盘位置和速度,具体参见 ChassisPoseSpeed。
获取底盘位置
Section titled “获取底盘位置”-
方法原型:
get_pose(self) -> tuple[alphabot.core.AbcErrorCode, ChassisPose2D] -
返回值:
包含两个元素的元组。
元素数据类型 说明 AbcErrorCodeAbcErrorCode.SUCCESS表示成功;其他错误码,请参见 AbcErrorCode。ChassisPose2D底盘位置,具体参见 ChassisPose2D。
获取底盘速度
Section titled “获取底盘速度”-
方法原型:
get_speed(self) -> tuple[alphabot.core.AbcErrorCode, ChassisTwist] -
返回值:
包含两个元素的元组。
元素数据类型 说明 AbcErrorCodeAbcErrorCode.SUCCESS表示成功;其他错误码,请参见 AbcErrorCode。ChassisTwist底盘速度,具体参见 ChassisTwist。
获取底盘里程数
Section titled “获取底盘里程数”-
方法原型:
get_mileage(self) -> tuple[alphabot.core.AbcErrorCode, int] -
返回值:
包含两个元素的元组。
元素数据类型 说明 AbcErrorCodeAbcErrorCode.SUCCESS表示成功;其他错误码,请参见 AbcErrorCode。int底盘里程数。
获取底盘电池信息
Section titled “获取底盘电池信息”-
方法原型:
get_battery(self) -> tuple[alphabot.core.AbcErrorCode, ChassisBattery] -
返回值:
包含两个元素的元组。
元素数据类型 说明 AbcErrorCodeAbcErrorCode.SUCCESS表示成功;其他错误码,请参见 AbcErrorCode。ChassisBattery底盘电池相关的信息,具体参见 ChassisBattery。
获取底盘状态
Section titled “获取底盘状态”-
方法原型:
get_robot_state(self) -> tuple[alphabot.core.AbcErrorCode, ChassisState] -
返回值:
包含两个元素的元组。
元素数据类型 说明 AbcErrorCodeAbcErrorCode.SUCCESS表示成功;其他错误码,请参见 AbcErrorCode。ChassisState底盘状态相关的信息,具体参见 ChassisState。
获取底盘状态码
Section titled “获取底盘状态码”-
方法原型:
get_status_code(self) -> tuple[alphabot.core.AbcErrorCode, ChassisStatusCode] -
返回值:
包含两个元素的元组。
元素数据类型 说明 AbcErrorCodeAbcErrorCode.SUCCESS表示成功;其他错误码,请参见 AbcErrorCode。ChassisStatusCode底盘相关的状态码,具体参见 ChassisStatusCode。
获取底盘硬件状态
Section titled “获取底盘硬件状态”-
方法原型:
get_hardware_state(self) -> tuple[alphabot.core.AbcErrorCode, ChassisHardwareState] -
返回值:
包含两个元素的元组。
元素数据类型 说明 AbcErrorCodeAbcErrorCode.SUCCESS表示成功;其他错误码,请参见 AbcErrorCode。ChassisHardwareState底盘硬件相关的状态信息,具体参见 ChassisHardwareState。
获取底盘静态变换
Section titled “获取底盘静态变换”-
方法原型:
get_static_tf(self) -> tuple[alphabot.core.AbcErrorCode, list[ChassisTransformStamped]] -
返回值:
包含两个元素的元组。
元素数据类型 说明 AbcErrorCodeAbcErrorCode.SUCCESS表示成功;其他错误码,请参见 AbcErrorCode。list[ChassisTransformStamped]底盘静态变换,具体参见 ChassisTransformStamped。
设置底盘运动速度
Section titled “设置底盘运动速度”-
方法原型:
twist_control(self, linear: float, angular: float) -> alphabot.core.AbcErrorCode -
参数说明:
参数名称 说明 linear线速度 angular角速度 -
返回值:
AbcErrorCode.SUCCESS表示成功;其他错误码,请参见 AbcErrorCode。
设置底盘最大速度
Section titled “设置底盘最大速度”-
方法原型:
set_max_speed(self, max_spd: float) -> alphabot.core.AbcErrorCode -
参数说明:
参数名称 说明 max_spd设置的最大速度 -
返回值:
AbcErrorCode.SUCCESS表示成功;其他错误码,请参见 AbcErrorCode。
-
方法原型:
init_robot(self, pose: ChassisPose2D, update_flg: int) -> alphabot.core.AbcErrorCode -
参数说明:
参数名称 说明 pose底盘位置,具体参见 ChassisPose2D。 update_flg是否更新位置。 -
返回值:
AbcErrorCode.SUCCESS表示成功;其他错误码,请参见 AbcErrorCode。
移动到目标位置
Section titled “移动到目标位置”-
方法原型:
move_to_point_sync(self,x: float,y: float,theta: float,callback: typing.Callable,max_spd: float = 1.0) -> alphabot.core.AbcErrorCode -
参数说明:
参数名称 说明 x目标位置的 X 轴坐标值 y目标位置的 Y 轴坐标值 theta目标位置的朝向 callback回调函数 max_spd最大速度 -
返回值:
AbcErrorCode.SUCCESS表示成功;其他错误码,请参见 AbcErrorCode。
-
方法原型:
to_charge_sync(self, max_spd: float = 1.0) -> alphabot.core.AbcErrorCode -
参数说明:
参数名称 说明 max_spd最大速度 -
返回值:
AbcErrorCode.SUCCESS表示成功;其他错误码,请参见 AbcErrorCode。
-
方法原型:
exit_charge_sync(self, max_spd: float = 1.0) -> alphabot.core.AbcErrorCode -
参数说明:
参数名称 说明 max_spd最大速度 -
返回值:
AbcErrorCode.SUCCESS表示成功;其他错误码,请参见 AbcErrorCode。
-
方法原型:
move_straight_sync(self,distance: float,speed: float,callback: typing.Callable,use_avoid: bool = True) -> alphabot.core.AbcErrorCode -
参数说明:
参数名称 说明 distance移动距离 speed移动速度 callback回调函数 use_avoid是否启用避障 -
返回值:
AbcErrorCode.SUCCESS表示成功;其他错误码,请参见 AbcErrorCode。
-
方法原型:
move_rotate_sync(self,angle: float,speed: float,callback: typing.Callable,use_avoid: bool = True) -> alphabot.core.AbcErrorCode -
参数说明:
参数名称 说明 angle旋转角度 speed旋转速度 callback回调函数 use_avoid是否启用避障 -
返回值:
AbcErrorCode.SUCCESS表示成功;其他错误码,请参见 AbcErrorCode。
获取局部轮廓
Section titled “获取局部轮廓”-
方法原型:
get_local_footprint(self) -> tuple[alphabot.core.AbcErrorCode, list[ChassisPoint32]] -
返回值:
包含两个元素的元组。
元素数据类型 说明 AbcErrorCodeAbcErrorCode.SUCCESS表示成功;其他错误码,请参见 AbcErrorCode。list[ChassisPoint32]轮廓点,具体参见 ChassisPoint32。
获取全局轮廓
Section titled “获取全局轮廓”-
方法原型:
get_global_footprint(self) -> tuple[alphabot.core.AbcErrorCode, list[ChassisPoint32]] -
返回值:
包含两个元素的元组。
元素数据类型 说明 AbcErrorCodeAbcErrorCode.SUCCESS表示成功;其他错误码,请参见 AbcErrorCode。list[ChassisPoint32]轮廓点,具体参见 ChassisPoint32。
获取局部和全局轮廓
Section titled “获取局部和全局轮廓”-
方法原型:
get_all_footprint(self) -> tuple[alphabot.core.AbcErrorCode, tuple[list[ChassisPoint32], list[ChassisPoint32]]] -
返回值:
包含两个元素的元组。
元素数据类型 说明 AbcErrorCodeAbcErrorCode.SUCCESS表示成功;其他错误码,请参见 AbcErrorCode。tuple[list[ChassisPoint32], list[ChassisPoint32]]第一个元素为局部轮廓,第二个元素为全局轮廓。轮廓点相关的数据结构,请参见 ChassisPoint32。
获取静态轮廓(基于 odom 和 base_link 坐标系)
Section titled “获取静态轮廓(基于 odom 和 base_link 坐标系)”-
方法原型:
ai2_get_local_footprint(self) -> tuple[alphabot.core.AbcErrorCode, list[ChassisPoint32]] -
返回值:
包含两个元素的元组。
元素数据类型 说明 AbcErrorCodeAbcErrorCode.SUCCESS表示成功;其他错误码,请参见 AbcErrorCode。list[ChassisPoint32]轮廓点,具体参见 ChassisPoint32。
获取静态轮廓(基于 map 和 base_link 坐标系)
Section titled “获取静态轮廓(基于 map 和 base_link 坐标系)”-
方法原型:
ai2_get_global_footprint(self) -> tuple[alphabot.core.AbcErrorCode, list[ChassisPoint32]] -
返回值:
包含两个元素的元组。
元素数据类型 说明 AbcErrorCodeAbcErrorCode.SUCCESS表示成功;其他错误码,请参见 AbcErrorCode。list[ChassisPoint32]轮廓点,具体参见 ChassisPoint32。
获取静态轮廓
Section titled “获取静态轮廓”-
方法原型:
ai2_get_all_footprint(self) -> tuple[alphabot.core.AbcErrorCode, tuple[list[ChassisPoint32], list[ChassisPoint32]]] -
返回值:
包含两个元素的元组。
元素数据类型 说明 AbcErrorCodeAbcErrorCode.SUCCESS表示成功;其他错误码,请参见 AbcErrorCode。tuple[list[ChassisPoint32], list[ChassisPoint32]]第一个元素为基于 odom 和 base_link 坐标系解算的轮廓,第二个元素为基于 map 和 base_link 坐标系解算的轮廓。
轮廓点相关的数据结构,请参见 ChassisPoint32。
设置局部轮廓
Section titled “设置局部轮廓”-
方法原型:
set_local_footprint(self, points: list[ChassisPoint32]) -> alphabot.core.AbcErrorCode -
参数说明:
参数名称 说明 points轮廓点,具体参见 ChassisPoint32。 -
返回值:
AbcErrorCode.SUCCESS表示成功;其他错误码,请参见 AbcErrorCode。
设置全局轮廓
Section titled “设置全局轮廓”-
方法原型:
set_global_footprint(self, points: list[ChassisPoint32]) -> alphabot.core.AbcErrorCode -
参数说明:
参数名称 说明 points轮廓点,具体参见 ChassisPoint32。 -
返回值:
AbcErrorCode.SUCCESS表示成功;其他错误码,请参见 AbcErrorCode。
设置局部和全局轮廓
Section titled “设置局部和全局轮廓”-
方法原型:
set_all_footprint(self,local_points: list[ChassisPoint32],global_points: list[ChassisPoint32]) -> alphabot.core.AbcErrorCode -
参数说明:
参数名称 说明 local_points局部轮廓点,具体参见 ChassisPoint32。 global_points全局轮廓点,具体参见 ChassisPoint32。 -
返回值:
AbcErrorCode.SUCCESS表示成功;其他错误码,请参见 AbcErrorCode。
获取底盘名称
Section titled “获取底盘名称”-
方法原型:
get_name(self) -> str -
返回值:
底盘名称。
ChassisPoseSpeed
Section titled “ChassisPoseSpeed”| 属性 | 数据类型 | 说明 |
|---|---|---|
map_id | int | 当前地图 ID |
mileage | int | 累计里程数 |
robot_id | int | 底盘 ID |
pose | ChassisPose2D | 2D 位姿 |
twist | ChassisTwist | 速度 |
ChassisPose2D
Section titled “ChassisPose2D”ChassisPose2D 类用于表示底盘 2D 位姿。
| 属性 | 数据类型 | 说明 |
|---|---|---|
theta | float | 朝向 |
x | float | X 轴坐标值 |
y | float | Y 轴坐标值 |
ChassisPoint32
Section titled “ChassisPoint32”ChassisPoint32 类用于表示轮廓点的位置。
| 属性 | 数据类型 | 说明 |
|---|---|---|
x | float | X 轴坐标值 |
y | float | Y 轴坐标值 |
z | float | Z 轴坐标值 |
ChassisTwist
Section titled “ChassisTwist”ChassisTwist 类用于表示底盘速度。
| 属性 | 数据类型 | 说明 |
|---|---|---|
angular | float | 角速度 |
linear | float | 线速度 |
ChassisBattery
Section titled “ChassisBattery”| 属性 | 数据类型 | 说明 |
|---|---|---|
charge_state | ChargeState | 充电状态 |
robot_id | int | 底盘 ID |
power | int | 电量百分比,取值范围为 0~100。 - 100:全满。- 0:无电量。 |
health | int | 电池健康(充满容量/设计容量) |
charge_cycle | int | 循环次数 |
battery_cycle | int | 电池寿命 |
temp_max | int | 电池温度(最高温度) |
success | bool | 请求是否成功。 - True:成功响应请求。- False:未成功处理请求。 |
msg | str | 应答消息描述,通常用于请求未能处理时的原因描述。 |
ChargeState
Section titled “ChargeState”ChargeState 类是一个表示底盘电池充电状态的枚举器。
| 常量成员 | 值 | 说明 |
|---|---|---|
UNDEFINED | 0 | 未定义 |
NOT | 1 | 未充电 |
MANUAL | 2 | 手动充电中 |
AUTO | 3 | 自动充电中 |
ChassisState
Section titled “ChassisState”| 属性 | 数据类型 | 说明 |
|---|---|---|
robot_id | int | 底盘 ID |
state | ChassisStateType | 底盘自动模式状态 |
success | bool | 请求是否成功。 - True:成功响应请求。- False:未成功处理请求。 |
msg | str | 应答消息描述,通常用于请求未能处理时的原因描述。 |
ChassisStateType
Section titled “ChassisStateType”ChassisStateType 类是一个表示底盘状态的枚举器。
| 常量成员 | 值 | 说明 |
|---|---|---|
UNDEFINED | 0 | 未定义 |
UNINIT | 1 | 未初始化 |
IDLE | 2 | 空闲 |
PARKING | 3 | 泊车中 |
TASK | 4 | 任务中 |
WARNING | 5 | 警告 |
FAULT | 6 | 异常 |
FOLLOWING | 7 | 跟随中 |
CHARGING | 8 | 充电中 |
MAPPING | 9 | 构图中 |
ChassisStatusCode
Section titled “ChassisStatusCode”| 属性 | 数据类型 | 说明 |
|---|---|---|
robot_id | int | 底盘 ID |
code | int | 状态码 |
time | int | 时间 |
status_msg | str | 描述 |
robot_task_id | int | 任务 ID |
state | StatusCodeRobotState | 自动模式状态 |
type | ActionType | 动作类型 |
level | StatusLevel | 等级 |
success | bool | 请求是否成功。 - True:成功响应请求。- False:未成功处理请求。 |
msg | str | 应答消息描述,通常用于请求未能处理时的原因描述。 |
StatusCodeRobotState
Section titled “StatusCodeRobotState”| 常量成员 | 值 | 说明 |
|---|---|---|
UNDEFINED | 0 | 未定义 |
UNINIT | 1 | 未初始化 |
IDLE | 2 | 空闲 |
PARKING | 3 | 泊车中 |
TASK | 4 | 任务中 |
WARNING | 5 | 警告 |
FAULT | 6 | 异常 |
FOLLOWING | 7 | 跟随中 |
CHARGING | 8 | 充电中 |
MAPPING | 9 | 构图中 |
ActionType
Section titled “ActionType”ActionType 类是一个表示底盘动作类型的枚举器。
| 常量成员 | 值 | 说明 |
|---|---|---|
UNDEFINED | 0 | 未定义 |
NAV | 1 | 导航 |
STEP_CTRL | 2 | 单步控制 |
SECONDPOS_ENTER | 3 | 二次定位进入 |
SECONDPOS_QUIT | 4 | 二次定位退出 |
CARRY | 5 | 搬运动作 |
WAIT | 6 | 等待 |
CHARGE | 7 | 充电 |
StatusLevel
Section titled “StatusLevel”| 常量成员 | 值 | 说明 |
|---|---|---|
NORMAL | 0 | 正常 |
TIPS | 1 | 提示 |
WARN | 2 | 警告 |
FAULT | 3 | 故障 |
ChassisHardwareState
Section titled “ChassisHardwareState”| 属性 | 数据类型 | 说明 |
|---|---|---|
robot_id | int | 底盘 ID |
lidars | list[HardwareStateType] | repeated 激光雷达 2 |
cameras | list[HardwareStateType] | repeated 摄像头 2 |
success | bool | 请求是否成功。 - True:成功响应请求。- False:未成功处理请求。 |
msg | str | 应答消息描述,通常用于请求未能处理时的原因描述。 |
HardwareStateType
Section titled “HardwareStateType”| 常量成员 | 值 | 说明 |
|---|---|---|
NORMAL | 0 | 正常 |
INFO | 1 | 提示 |
WARN | 16 | 警告 |
FATAL | 17 | 故障 |
ChassisTransformStamped
Section titled “ChassisTransformStamped”| 属性 | 数据类型 | 说明 |
frame_id | str | 父坐标系 |
secs | int | 秒 |
nsecs | int | 纳秒 |
child_frame_id | str | float |
t_x | float | XYZ 坐标值 |
t_y | float | |
t_z | float | |
r_x | float | 四元数 |
r_y | float | |
r_z | float | |
r_w | float |
ChassisOperationState
Section titled “ChassisOperationState”| 属性 | 数据类型 | 说明 |
|---|---|---|
robot_id | int | 底盘 ID |
nav | NavState | 底盘导航相关位信息 |
robot | RobotBit | 底盘位信息 |
success | bool | 请求是否成功。 - True:成功响应请求。- False:未成功处理请求。 |
msg | str | 应答消息描述,通常用于请求未能处理时的原因描述。 |
NavState
Section titled “NavState”| 常量成员 | 值 | 说明 |
|---|---|---|
UNDEFINED | 0 | 未定义 |
NARROW | 1 | 狭窄通道 |
GUIDE | 2 | 引导到达 |
INA_LIFT | 3 | 乘梯中 |
IMPEDE | 4 | 阻碍 |
QR_CODE | 5 | 二维码 |
STAGE | 6 | 分段到达 |
RobotBit
Section titled “RobotBit”| 常量成员 | 值 | 说明 |
|---|---|---|
UNDEFINED | 0 | 未定义 |
TASKABLE | 1 | 可接任务 |