数据结构

本节描述 Daystar API 中使用的数据结构和消息类型。这些数据结构通过 pybind11 从 C++ 绑定到 Python,用于与机器人系统进行通信。

数据结构分为以下几类:

  • 基础消息类型: ROS 标准消息和几何消息,用于构建更复杂的数据结构

  • 自定义消息类型: Daystar 特有的消息类型,如状态码、导航参数等

  • 接口层响应: API 函数返回的接口层响应对象

  • ROS层服务响应: 底层 ROS 服务的响应结构

  • 事件类型: 异步事件回调使用的数据结构

基础消息类型

ROS 标准消息类型 (std_msgs)

Time

class Time
class Time(sec: int = 0, nanosec: int = 0)

Bases: object

property nanosec: int
property sec: int

ROS 时间戳。

Python 类: Time

字段:

  • sec (int): 秒

  • nanosec (int): 纳秒(0–999999999)

示例:

from daystar_api.lowlevel_skills import Time

# 方式 1:空构造 + setter
t = Time()
t.sec = 42
t.nanosec = 500000000

# 方式 2:kwargs / 位置参数
t = Time(sec=42, nanosec=500000000)
t = Time(42, 500000000)

ROS 几何消息类型 (geometry_msgs)

Point

class Point
class Point(x: float = 0.0, y: float = 0.0, z: float = 0.0)

Bases: object

property x: float
property y: float
property z: float

三维空间中的点。

Python 类: Point

字段:

  • x (float): X 坐标

  • y (float): Y 坐标

  • z (float): Z 坐标

示例:

from daystar_api.lowlevel_skills import Point

# 方式 1:空构造 + setter
point = Point()
point.x = 1.0
point.y = 2.0
point.z = 0.0

# 方式 2:位置参数
point = Point(1.0, 2.0, 0.0)

# 方式 3:kwargs(可省略部分字段,缺省为 0.0)
point = Point(x=1.0, y=2.0)

Quaternion

class Quaternion
class Quaternion(x: float = 0.0, y: float = 0.0, z: float = 0.0, w: float = 1.0)

Bases: object

property w: float
property x: float
property y: float
property z: float

四元数表示的方向。

Python 类: Quaternion

字段:

  • x (float): X 分量

  • y (float): Y 分量

  • z (float): Z 分量

  • w (float): W 分量(标量部分)

示例:

from daystar_api.lowlevel_skills import Quaternion

# 方式 1:空构造(默认 identity,w=1.0),setter 仍可用
quat = Quaternion()
quat.x = 0.0
quat.y = 0.0
quat.z = 0.0
quat.w = 1.0  # 无旋转(也是空构造的默认值)

# 方式 2:位置参数(w 缺省取 1.0 = identity rotation)
quat = Quaternion(0.0, 0.0, 0.0)        # 等价 identity
quat = Quaternion(0.0, 0.0, 0.0, 1.0)   # 显式 identity

# 方式 3:kwargs(w 缺省取 1.0 = identity rotation)
quat = Quaternion(x=0.5)   # (0.5, 0, 0, 1.0)

Pose

class Pose
class Pose(position: Point = {'x': 0.0, 'y': 0.0, 'z': 0.0}, orientation: Quaternion = {'w': 1.0, 'x': 0.0, 'y': 0.0, 'z': 0.0})

Bases: object

property orientation: Quaternion
property position: Point

位置和方向的组合。

Python 类: Pose

字段:

  • position (Point): 位置

  • orientation (Quaternion): 方向

示例:

from daystar_api.lowlevel_skills import Pose, Point, Quaternion

# 方式 1:空构造 + setter(orientation 默认 identity,w=1.0 已自动)
pose = Pose()
pose.position.x = 1.0
pose.position.y = 2.0
pose.position.z = 0.0
pose.orientation.w = 1.0  # 显式 setter 仍可用,但默认值已经是 1.0

# 方式 2:kwargs / 位置参数(orientation 缺省取 identity,无需手设 w=1)
pose = Pose(position=Point(1.0, 2.0, 0.0))
pose = Pose(Point(1.0, 2.0, 0.0))   # 等价的位置参数写法

# 方式 3:完整参数
pose = Pose(Point(1.0, 2.0, 0.0), Quaternion(0.0, 0.0, 0.0, 1.0))

PoseStamped

class PoseStamped
class PoseStamped(header: Header = {'frame_id': '', 'stamp': {'nanosec': 0, 'sec': 0}}, pose: Pose = {'orientation': {'w': 1.0, 'x': 0.0, 'y': 0.0, 'z': 0.0}, 'position': {'x': 0.0, 'y': 0.0, 'z': 0.0}})

Bases: object

property header: Header
property pose: Pose

带时间戳和坐标系的位姿。

Python 类: PoseStamped

字段:

  • header (Header): 时间戳和坐标系信息

  • pose (Pose): 位姿

示例:

from daystar_api.lowlevel_skills import PoseStamped, Pose, Point, Header

# 方式 1:空构造 + setter(内嵌 pose 已是 identity-orientation)
pose_stamped = PoseStamped()
pose_stamped.header.frame_id = "map"
pose_stamped.pose.position.x = 1.0
pose_stamped.pose.position.y = 2.0
pose_stamped.pose.orientation.w = 1.0  # 默认已是 1.0

# 方式 2:kwargs(内嵌 pose 默认 identity-orientation,无需手设 w=1)
pose_stamped = PoseStamped(
    header=Header(frame_id="map"),
    pose=Pose(Point(1.0, 2.0, 0.0)),
)

# 方式 3:位置参数
pose_stamped = PoseStamped(Header(frame_id="map"), Pose(Point(1.0, 2.0, 0.0)))

Vector3

class Vector3
class Vector3(x: float = 0.0, y: float = 0.0, z: float = 0.0)

Bases: object

property x: float
property y: float
property z: float

三维向量。

Python 类: Vector3

字段:

  • x (float): X 分量

  • y (float): Y 分量

  • z (float): Z 分量

示例:

from daystar_api.lowlevel_skills import Vector3

# 方式 1:空构造 + setter
vec = Vector3()
vec.x = 1.0
vec.y = 0.0
vec.z = 0.0

# 方式 2:位置参数
vec = Vector3(1.0, 0.0, 0.0)

# 方式 3:kwargs(可省略部分字段,缺省为 0.0)
vec = Vector3(x=1.0)

Twist

class Twist
class Twist(linear: Vector3 = {'x': 0.0, 'y': 0.0, 'z': 0.0}, angular: Vector3 = {'x': 0.0, 'y': 0.0, 'z': 0.0})

Bases: object

property angular: Vector3
property linear: Vector3

线速度和角速度。

Python 类: Twist

字段:

  • linear (Vector3): 线速度 (m/s)

  • angular (Vector3): 角速度 (rad/s)

示例:

from daystar_api.lowlevel_skills import Twist, Vector3

# 方式 1:空构造 + setter(linear/angular 默认全 0)
twist = Twist()
twist.linear.x = 0.5  # 前进 0.5 m/s
twist.angular.z = 0.1  # 左转 0.1 rad/s

# 方式 2:kwargs(linear/angular 默认全 0 Vector3)
twist = Twist(linear=Vector3(0.5, 0.0, 0.0), angular=Vector3(z=0.1))

# 方式 3:位置参数
twist = Twist(Vector3(0.5, 0.0, 0.0), Vector3(0.0, 0.0, 0.1))

PoseWithCovariance

class PoseWithCovariance
class PoseWithCovariance(pose: Pose = {'orientation': {'w': 1.0, 'x': 0.0, 'y': 0.0, 'z': 0.0}, 'position': {'x': 0.0, 'y': 0.0, 'z': 0.0}}, covariance: list[float[36]] = [0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0])

Bases: object

property covariance: list[float[36]]
property pose: Pose

带协方差的位姿。

Python 类: PoseWithCovariance

字段:

  • pose (Pose): 位姿

  • covariance (list[float]): 6×6 协方差矩阵(行优先 36 元素)

示例:

from daystar_api.lowlevel_skills import PoseWithCovariance, Pose, Point

# 方式 1:空构造
pwc = PoseWithCovariance()

# 方式 2:kwargs(pose 默认 identity-orientation,covariance 默认全 0)
pwc = PoseWithCovariance(pose=Pose(Point(1.0, 2.0, 0.0)))

# 方式 3:显式 covariance
cov = [0.0] * 36
cov[0] = 0.1   # x 方差
pwc = PoseWithCovariance(covariance=cov)

TwistWithCovariance

class TwistWithCovariance
class TwistWithCovariance(twist: Twist = {'angular': {'x': 0.0, 'y': 0.0, 'z': 0.0}, 'linear': {'x': 0.0, 'y': 0.0, 'z': 0.0}}, covariance: list[float[36]] = [0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0])

Bases: object

property covariance: list[float[36]]
property twist: Twist

带协方差的速度。

字段:

  • twist (Twist): 线速度 + 角速度

  • covariance (list[float]): 6×6 协方差矩阵(36 元素)

示例:

from daystar_api.lowlevel_skills import TwistWithCovariance, Twist, Vector3

twc = TwistWithCovariance(twist=Twist(linear=Vector3(0.5, 0, 0)))

PoseWithCovarianceStamped

class PoseWithCovarianceStamped
class PoseWithCovarianceStamped(header: Header = {'frame_id': '', 'stamp': {'nanosec': 0, 'sec': 0}}, pose: PoseWithCovariance = {'covariance': [0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0], 'pose': {'orientation': {'w': 1.0, 'x': 0.0, 'y': 0.0, 'z': 0.0}, 'position': {'x': 0.0, 'y': 0.0, 'z': 0.0}}})

Bases: object

property header: Header
property pose: PoseWithCovariance

带时间戳和坐标系的协方差位姿(常用于定位发布)。

字段:

  • header (Header): 时间戳和坐标系

  • pose (PoseWithCovariance): 协方差位姿

示例:

from daystar_api.lowlevel_skills import PoseWithCovarianceStamped, Header

pwcs = PoseWithCovarianceStamped(header=Header(frame_id='map'))

机械臂消息类型

CartesianTarget

class CartesianTarget

Bases: object

property rpy: Vector3

geometry_msgs/Vector3 roll-pitch-yaw 滚转-俯仰-偏航(单位:度)

property x: float

x (m)

property y: float

y (m)

property z: float

z (m)

笛卡尔空间末端目标位姿,位置 + 欧拉角 RPY 表示。用于 move_tool() / compute_ik() / plan_trajectory() 等接口的目标位姿入参。

字段:

  • x (float): X 坐标(米)

  • y (float): Y 坐标(米)

  • z (float): Z 坐标(米)

  • rpy (Vector3): 滚转-俯仰-偏航欧拉角(角度,单位:度)

示例:

from daystar_api.lowlevel_skills import CartesianTarget

target = CartesianTarget()
target.x = 0.4
target.y = 0.1
target.z = 0.3
target.rpy.z = 90.0

JointTrajectory

class JointTrajectory

Bases: object

property header: Header

std_msgs/Header

property joint_names: list[str]

string[] joint names

property points: list[JointTrajectoryPoint]

JointTrajectoryPoint[]

关节轨迹,由一组关节名与时序轨迹点构成。plan_trajectory() / get_trajectory() 的结果即为此类型,可直接传给 execute_path() 执行。

字段:

  • header (Header): 时间戳和坐标系信息

  • joint_names (list[str]): 关节名称列表

  • points (list[ JointTrajectoryPoint ]): 轨迹点序列

JointTrajectoryPoint

class JointTrajectoryPoint

Bases: object

property accelerations: list[float]

float64[] joint accelerations

property effort: list[float]

float64[] joint effort

property positions: list[float]

float64[] joint positions 关节位置(单位:度)

property time_from_start: Duration

builtin_interfaces/Duration

property velocities: list[float]

float64[] joint velocities

关节轨迹中的单个时序点。

字段:

  • positions (list[float]): 各关节位置(角度,单位:度)

  • velocities (list[float]): 各关节速度

  • accelerations (list[float]): 各关节加速度

  • effort (list[float]): 各关节力矩

  • time_from_start (Duration): 相对轨迹起点的时间偏移

自定义消息类型

Daystar 自定义消息类型

class State
class State(code: StateCode = ..., describe: str = '')

Bases: object

property cn: str

StateCode 对应的中文说明

property code: StateCode

state

property describe: str

description

State

通用状态码和描述。

Python 类: State

字段:

  • code (int): 状态码

    • 0: SUCCESS - 成功

    • 1: FAIL - 失败

    • 1002: TIMEOUT - 超时

    • 1010: ACTION_REQUEST_TIMEOUT - 动作请求超时

    • 1015: ACTION_CANCELED - 动作被取消

  • describe (str): 状态描述文本

示例:

from daystar_api.lowlevel_skills import State

# 读取响应中的 state(最常见用法)
response = navigation_to_location("kitchen")
if response.state.code == 0:
    print(f"成功: {response.state.describe}")
else:
    print(f"失败 (code={response.state.code}): {response.state.describe}")

# 主动构造 State(code 默认 0=SUCCESS,describe 默认空字符串)
ok = State(describe="ok")               # State(code=0, describe='ok')
fail = State(code=1, describe="failed") # 显式指定失败状态

MsgTravelParams

class MsgTravelParams
class MsgTravelParams(speed_mode: int = 0, distance_tolerance: float = 0.0, gait: int = 0, disable_body_obstacle_avoidance: bool = False, ignore_final_yaw: bool = False, path_following_mode: int = 0, direction_constraint: int = 0)

Bases: object

property direction_constraint: int

0=UNKNOWN, 1=NONE(无限制), 2=NO_TURN(禁止掉头), 3=FORWARD(正走), 4=REVERSE(倒走)

Type:

Direction constraint

property disable_body_obstacle_avoidance: bool

True to disable, False to enable

Type:

Disable body obstacle avoidance

property distance_tolerance: float

Distance tolerance in meters - threshold for maximum distance that defines when goal is reached

property gait: int

0=UNKNOWN, 1=GAIT_AUTO, 2=GAIT_TROT(对角小跑), 3=GAIT_CRAWL(爬行), 4=GAIT_AMBLE(缓行), 5=GAIT_SLOPE(斜坡), 6=GAIT_SENSE_STAIR(感知楼梯), 7=GAIT_NORMAL_STAIR(普通楼梯), 8=GAIT_STEEP_STAIR(陡峭楼梯), 9=GAIT_GRADUAL_STAIR(平缓楼梯), 10=GAIT_RL

Type:

Gait mode

property ignore_final_yaw: bool

True to ignore goal orientation, False to match goal orientation

Type:

Ignore final yaw

property path_following_mode: int

0=PATH_MODE_UNKNOWN, 1=PATH_MODE_DEFAULT(默认循线), 2=PATH_MODE_OFF(自由导航), 3=PATH_MODE_AUTO(自动选择), 4=PATH_MODE_STRICT(严格循线)

Type:

Path following mode

property speed_mode: int

0=UNKNOWN, 1=NORMAL, 2=LOW, 3=HIGH

Type:

Speed mode

导航行为参数。

Python 类: MsgTravelParams

字段:

  • speed_mode (int): 速度模式

    • 0: UNKNOWN

    • 1: NORMAL - 正常速度

    • 2: LOW - 低速

    • 3: HIGH - 高速

  • distance_tolerance (float): 到达目标的距离容差(米),默认 0.5

  • gait (int): 步态模式(仅四足机器人)

    • 1: AUTO - 自动

    • 2: TROT - 小跑

    • 3: WALK - 行走

  • disable_body_obstacle_avoidance (bool): 是否禁用机身避障,默认 False

  • ignore_final_yaw (bool): 是否忽略终点朝向,默认 False

  • path_following_mode (int): 路径跟随模式,默认 1

  • direction_constraint (int): 方向约束,默认 1

示例:

from daystar_api.lowlevel_skills import MsgTravelParams

# 方式 1:空构造 + setter
params = MsgTravelParams()
params.speed_mode = 2  # 低速模式
params.distance_tolerance = 0.3  # 30cm 到达容差
params.ignore_final_yaw = True  # 不要求朝向

# 方式 2:kwargs(推荐)
params = MsgTravelParams(speed_mode=1, gait=1)

# 方式 3:完整位置参数
params = MsgTravelParams(2, 0.3, 1, False, True, 1, 1)

navigation_to_location("bedroom", travel_params=params)

Note

speed_mode / gait / path_following_mode / direction_constraint 的默认值为 0(UNKNOWN),即镜像 ROS msg 结构体默认。在实际导航调用前请显式 赋有效枚举值(如 speed_mode=1 表示 NORMAL)。

BatteryState

class BatteryState
class BatteryState(header: Header = {'frame_id': '', 'stamp': {'nanosec': 0, 'sec': 0}}, voltage: float = 0.0, temperature: float = 0.0, current: float = 0.0, charge: float = 0.0, capacity: float = 0.0, design_capacity: float = 0.0, percentage: float = 0.0, power_supply_status: int = 0, power_supply_health: int = 0, power_supply_technology: int = 0, present: bool = False, cell_voltage: list[float] = [], cell_temperature: list[float] = [], location: str = '', serial_number: str = '')

Bases: object

property capacity: float

Battery capacity in Amp-hours (Ah)

property cell_temperature: list[float]

Temperature of individual cells (degC)

property cell_voltage: list[float]

Voltage of individual cells (V)

property charge: float

Current charge in Amp-hours (Ah)

property current: float

Current in Amperes (A), negative indicates discharge

property design_capacity: float

Design capacity in Amp-hours (Ah)

property header: Header

Header timestamp

property location: str

Location/identifier of the battery

property percentage: float

Battery charge percentage (0.0-100.0)

property power_supply_health: int

Power supply health (UNKNOWN=0, GOOD=1, OVERHEAT=2, DEAD=3, OVERVOLTAGE=4, etc.)

property power_supply_status: int

Power supply status (UNKNOWN=0, CHARGING=1, DISCHARGING=2, NOT_CHARGING=3, FULL=4)

property power_supply_technology: int

Power supply technology (UNKNOWN=0, NIMH=1, LION=2, LIPO=3, LIFE=4, NICD=5, LIMN=6)

property present: bool

Battery present (true/false)

property serial_number: str

Serial number of the battery

property temperature: float

Temperature in Celsius (degC)

property voltage: float

Voltage in Volts (V)

电池状态信息(镜像 sensor_msgs/BatteryState)。

Python 类: BatteryState

字段:

  • header (Header): 时间戳和坐标系

  • voltage (float): 电压 (V)

  • temperature (float): 温度 (degC)

  • current (float): 电流 (A),负值表示放电

  • charge (float): 当前电量 (Ah)

  • capacity (float): 容量 (Ah)

  • design_capacity (float): 设计容量 (Ah)

  • percentage (float): 电量百分比 (0.0–1.0)

  • power_supply_status (int): 电源状态枚举

  • power_supply_health (int): 电池健康度枚举

  • power_supply_technology (int): 电池技术类型枚举

  • present (bool): 电池是否存在

  • cell_voltage (list[float]): 各电芯电压 (V)

  • cell_temperature (list[float]): 各电芯温度 (degC)

  • location (str): 电池位置标识

  • serial_number (str): 序列号

示例:

from daystar_api.lowlevel_skills import BatteryState

# 方式 1:空构造 + setter
bs = BatteryState()
bs.percentage = 0.85

# 方式 2:kwargs(缺省字段全部取 ROS msg 结构体默认)
bs = BatteryState(voltage=24.0, percentage=0.85, present=True)

FileInfo

class FileInfo
class FileInfo(name: str = '', last_update_time: str = '', md5: str = '')

Bases: object

property last_update_time: str

00:03”

Type:

最后更新时间,格式 “2026-04-12 20

property md5: str

文件 MD5 校验值

property name: str

文件名(含后缀)

文件信息(用于地图等资源文件清单)。

Python 类: FileInfo

字段:

  • name (str): 文件名(含后缀)

  • last_update_time (str): 最后更新时间,格式 "2026-04-12 20:00:03"

  • md5 (str): 文件 MD5 校验值

示例:

from daystar_api.lowlevel_skills import FileInfo

# 方式 1:空构造 + setter
info = FileInfo()
info.name = "office.pgm"

# 方式 2:kwargs / 位置参数
info = FileInfo(name="office.pgm", md5="d41d8cd98f00b204e9800998ecf8427e")
info = FileInfo("office.pgm", "2026-04-12 20:00:03", "d41d8cd98f00b204e9800998ecf8427e")

MapFileInfo

class MapFileInfo
class MapFileInfo(map_name: str = '', file_info: list[FileInfo] = [])

Bases: object

property file_info: list[FileInfo]

该地图下的文件列表

property map_name: str

地图名称(文件夹名)

地图文件信息(包含文件夹下的文件列表)。

Python 类: MapFileInfo

字段:

  • map_name (str): 地图名称(文件夹名)

  • file_info (list[FileInfo]): 该地图下的文件列表

示例:

from daystar_api.lowlevel_skills import MapFileInfo, FileInfo

# 方式 1:空构造 + setter
m = MapFileInfo()
m.map_name = "office_floor1"

# 方式 2:kwargs / 位置参数
m = MapFileInfo(map_name="office_floor1", file_info=[FileInfo(name="map.pgm")])
m = MapFileInfo("office_floor1", [FileInfo(name="map.pgm")])

接口层响应结构

所有 lowlevel_skills 函数返回的响应都遵循统一结构:

response = {
    "state": State,      # 包含 code 和 describe
    "response": {...}    # 具体的响应数据
}

导航相关响应

IntelligentNavigationResponse

class IntelligentNavigationResponse

Bases: object

has_future()

Return True when a non-blocking future is attached.

Return type:

bool

property future: NavigationFuture

NavigationFuture handle for non-blocking calls (block=False).

None when the call was blocking (block=True).

Examples:

resp = navigation_to_location("kitchen", block=False)
if resp.future:
    result = resp.future.get(timeout=60)
property response: IntelligentNavigation_Result
property state: State

导航操作的响应。

字段:

  • state (State): 操作状态

  • response (IntelligentNavigation_Result): 导航结果

    • result (int): 结果代码

    • error_code (int): 错误代码

    • error_msg (str): 错误消息

示例:

response = navigation_to_location("kitchen")
print(f"状态码: {response.state.code}")
print(f"结果: {response.response.result}")
if response.response.error_code != 0:
    print(f"错误: {response.response.error_msg}")

定位相关响应

GetCurrentPoseServiceResponse

class GetCurrentPoseServiceResponse

Bases: object

property response: SrvAPIGetCurrentPose_Response
property state: State

获取当前位姿的响应。

字段:

示例:

response = get_current_pose()
if response.response.success:
    pose = response.response.location_pose
    print(f"位置: ({pose.position.x}, {pose.position.y})")

SetLocationResponse

class SetLocationResponse

Bases: object

property response: SrvAPISetLocalization_Response

Result of the response

property state: State

State of the response

字段:

  • success (bool): 是否成功

  • message (str): 状态消息

示例:

response = set_localization(pose)
if response.response.success:
    print("定位设置成功")

位置点管理响应

GetAvailableLocationResponse

class GetAvailableLocationResponse

Bases: object

property locations: list

Get locations as a list of dictionaries

property state: State

State of the response

获取可用位置点的响应。

字段:

  • (State): 操作状态

  • locations (list[Point]): 位置点列表,每个包含:

    • name (str): 位置点名称

    • pose (Pose): 位置点的位姿

示例:

response = get_available_location()
for loc in response.locations:
    print(f"{loc.name}: ({loc.pose.position.x}, {loc.pose.position.y})")

AddLocationServiceResponse

class AddLocationServiceResponse

Bases: object

property response: SrvAPIGetCurrentPose_Response
property state: State

增加点位的相应。

字段:

示例:

response = add_location("A")
if response.response.success:
     print("打点成功!")

DeleteLocationResponse

class DeleteLocationResponse

Bases: object

property result: bool

Result of the response

property state: State

State of the response

删除位置点的响应。

字段:

  • (State): 操作状态

  • result (bool): 是否删除成功

示例:

response = delete_location("old_point")
if response.result:
    print("位置点已删除")

相机和图像响应

CaptureImageResponse

class CaptureImageResponse

Bases: object

property response: SrvAPICaptureImage_Response

Service response

property state: State

State of the response

拍照操作的响应。

字段:

示例:

response = capture_image("photo_001")
if response.response.success:
    print(f"拍照成功: {response.response.message}")

GetAvailableImagesResponse

class GetAvailableImagesResponse

Bases: object

property response: SrvAPIGetAvailableImages_Response

Service response

property state: State

State of the response

获取已拍摄图像列表的响应。

字段:

示例:

response = get_available_images()
if response.response.success:
    for img in response.response.image_names:
        print(f"图像: {img}")

GetAvailableVideosResponse

class GetAvailableVideosResponse

Bases: object

property response: SrvAPIGetAvailableVideos_Response

Service response

property state: State

State of the response

获取已保存视频列表的响应。

字段:

示例:

response = get_available_videos()
if response.response.success:
    for video in response.response.video_names:
        print(f"视频: {video}")

云台控制响应

GetCurrentPTZFResponse

class GetCurrentPTZFResponse

Bases: object

property focus: int

Get focus

property pan: float

Get pan

property state: State

State of the response

property tilt: float

Get tilt

property zoom: float

Get zoom

获取云台位置的响应。

字段:

  • (State): 操作状态

  • pan (float): 当前水平角度

  • tilt (float): 当前垂直角度

  • zoom (float): 当前变焦值

  • focus (int): 当前对焦值

示例:

response = get_ptzf()
if response.state.code == 0:
    print(f"Pan: {response.pan}°")
    print(f"Tilt: {response.tilt}°")

SetPTZFServiceResponse

class SetPTZFServiceResponse

Bases: object

property response: SrvSetPtzf_Response

Result of the response

property state: State

State of the response

设置云台位置的响应。

字段:

示例:

response = set_ptzf(pan=30.0, tilt=15.0)
if response.response.result:
    print("云台位置设置成功")

地图和建图响应

GetAvailableMapsResponse

class GetAvailableMapsResponse

Bases: object

property response: SrvAPIGetAvailableMaps_Response

Service response

property state: State

State of the response

获取可用地图列表的响应。

字段:

示例:

response = get_available_maps()
if response.response.success:
    for map_name in response.response.map_names:
        print(f"地图: {map_name}")

StartMappingResponse

class StartMappingResponse

Bases: object

property response: SrvAPIStartMapping_Response

Service response

property state: State

State of the response

开始建图的响应。

字段:

示例:

response = start_mapping("new_map")
if response.response.success:
    print(f"建图已开始: {response.response.message}")

StopMappingResponse

class StopMappingResponse

Bases: object

property response: SrvAPIStopMapping_Response

Service response

property state: State

State of the response

停止建图的响应。

字段:

示例:

response = stop_mapping()
if response.response.success:
    print("建图已停止")

LoadMapResponse

class LoadMapResponse

Bases: object

property response: SrvAPILoadMap_Response

Service response

property state: State

State of the response

加载地图的响应。

字段:

示例:

response = load_map("office_floor1")
if response.response.success:
    print("地图加载成功")

运动控制相关响应

StandUpResponse

class StandUpResponse

Bases: object

property response: SrvRobotCommand_Response

RobotCommand service response

property state: State

State of the response

控制机器人站立的响应。

字段:

  • (State): 操作状态

  • response (RobotCommand_Response): 命令执行结果

    • result (bool): 是否成功

LieDownResponse

class LieDownResponse

Bases: object

property response: SrvRobotCommand_Response

RobotCommand service response

property state: State

State of the response

控制机器人躺下的响应。

字段:

  • (State): 操作状态

  • response (RobotCommand_Response): 命令执行结果

    • result (bool): 是否成功

GetRobotStateResponse

class GetRobotStateResponse

Bases: object

property robot_state: RobotState

Robot state (RobotState enum)

property state: State

State of the response

获取机器人状态的响应。

字段:

  • (State): 操作状态

  • robot_state (RobotState): 机器人当前状态枚举值

RobotCommandResponse

class RobotCommandResponse

Bases: object

property response: SrvRobotCommand_Response

RobotCommand service response

property state: State

State of the response

机器人通用命令的响应。

字段:

  • (State): 操作状态

  • response (RobotCommand_Response): 命令执行结果

    • result (bool): 是否成功

GetControlModeResponse

class GetControlModeResponse

Bases: object

property control_mode: ControlMode

Control mode (ControlMode enum)

property state: State

State of the response

获取控制模式的响应。

字段:

GetGaitResponse

class GetGaitResponse

Bases: object

property gait_type: GaitType

Gait type (GaitType enum)

property state: State

State of the response

获取步态类型的响应。

字段:

GoToDockResponse

class GoToDockResponse

Bases: object

property response: SrvRobotCommand_Response

RobotCommand service response

property state: State

State of the response

前往充电座的响应。

字段:

  • (State): 操作状态

  • response (RobotCommand_Response): 命令执行结果

    • result (bool): 是否成功

LeaveDockResponse

class LeaveDockResponse

Bases: object

property response: SrvRobotCommand_Response

RobotCommand service response

property state: State

State of the response

离开充电座的响应。

字段:

  • (State): 操作状态

  • response (RobotCommand_Response): 命令执行结果

    • result (bool): 是否成功

GetDockStateResponse

class GetDockStateResponse

Bases: object

property dock_state: DockState

Dock state (DockState enum)

property state: State

State of the response

获取充电座状态的响应。

字段:

GetBatteryStateResponse

class GetBatteryStateResponse

Bases: object

property battery_state: BatteryState

Complete battery state from sensor_msgs/BatteryState

property is_valid: bool

Whether battery_state data is valid (true) or stale/unavailable (false)

property state: State

State of the response

获取电池状态的响应。

字段:

  • (State): 操作状态

  • is_valid (bool): 数据是否有效

  • battery_state (sensor_msgs/BatteryState): 完整的电池信息

IsChargeResponse

class IsChargeResponse

Bases: object

property is_charging: bool

Whether robot is charging (true/false)

property state: State

State of the response

检查充电状态的响应。

字段:

  • (State): 操作状态

  • is_charging (bool): 是否正在充电

SendCmdVelResponse

class SendCmdVelResponse

Bases: object

property state: State

State of the response

property success: bool

Whether cmd_vel was published successfully

发送速度控制命令的响应。

字段:

  • (State): 操作状态

  • success (bool): 命令是否发布成功

GetDriverStateResponse

class GetDriverStateResponse

Bases: object

property driver_state: DriverEnableState

UNKNOWN/ENABLED/ENABLING/ENABLE_FAILED/DISABLED

Type:

Driver enable state (DriverEnableState enum)

property state: State

State of the response

获取驱动器使能状态的响应。

字段:

GetEmergencyStateResponse

class GetEmergencyStateResponse

Bases: object

property emergency: bool

True if robot is in software emergency-stop state; False otherwise or when data is stale

property state: State

State of the response

获取软急停状态的响应。

字段:

  • state (State): 操作状态

  • emergency (bool): 是否处于软急停状态(True 表示急停激活)

GetGuardianStateResponse

class GetGuardianStateResponse

Bases: object

property guardian: bool

True if Guardian obstacle-stop switch is enabled; False otherwise or when data is stale

property state: State

State of the response

获取停障开关状态的响应。

字段:

  • state (State): 操作状态

  • guardian (bool): 停障开关是否开启(True 表示开启)

GetRobotStatusResponse

class GetRobotStatusResponse

Bases: object

property battery: BatteryState

Complete battery state (sensor_msgs/BatteryState); check is_charging for charging status

property control_mode: ControlMode

JOY_MODE/NAV_MODE/UNKNOWN_MODE

Type:

Control mode (ControlMode enum)

property dock_state: DockState

IDLE/GOING_TO_DOCK/…/UNKNOWN_DOCK

Type:

Dock state (DockState enum)

property driver_state: DriverEnableState

UNKNOWN/ENABLED/ENABLING/ENABLE_FAILED/DISABLED

Type:

Driver enable state (DriverEnableState enum)

property emergency: bool

True if robot is in software emergency-stop state

property gait_type: GaitType

TROT/NORMAL_STAIR/…/UNKNOWN_GAIT

Type:

Gait type (GaitType enum)

property guardian: bool

True if Guardian obstacle-stop switch is enabled

property is_charging: bool

True if robot is currently charging

property lidar_state: LidarState

雷达整机健康状态(LidarState 枚举):UNKNOWN/NORMAL/HIGHFREQ/LOWFREQ/DISCONNECT

property loc_state: LocalizationState

NORMAL/LACKDATA/LOST/UNKNOWN_LOC

Type:

Localization state (LocalizationState enum)

property localization_mode: LocalizationMode

当前定位模式:MAP(0)/SLAM(1)/REFLECTOR(2)/UNKNOWN_LOC_MODE(99)

property robot_state: RobotState

LIE_DOWN/STANDING_UP/STAND_UP/UNKNOWN_STATE

Type:

Robot posture state (RobotState enum)

property state: State

State of the response

获取机器人聚合总状态的响应,一次性汇总所有关键状态字段。

字段:

  • state (State): 操作状态

  • robot_state (RobotState): 机器人姿态(站立/躺下等)

  • control_mode (ControlMode): 当前控制模式

  • gait_type (GaitType): 当前步态类型

  • dock_state (DockState): 充电座状态

  • battery (BatteryState): 电池信息

  • is_charging (bool): 是否正在充电

  • loc_state (LocalizationState): 定位状态

  • current_pose (Pose): 当前位姿(地图坐标系)

  • pose_valid (bool): 位姿数据是否有效

  • driver_state (DriverEnableState): 驱动器使能状态

  • emergency (bool): 是否处于软急停状态

  • guardian (bool): 停障开关是否开启

  • lidar_state (LidarState): 雷达整机健康状态

  • localization_mode (LocalizationMode): 当前定位模式(地图/SLAM/反光柱)

运动控制枚举类型

RobotState

class RobotState(value)

Bases: object

Robot state enumeration

Values:

LIE_DOWN (0): Robot is lying down STANDING_UP (1): Robot is in the process of standing up STAND_UP (2): Robot is standing ENABLE_FORCECONTROL (3): Force control mode STEPPING (4): Stepping in place SITTING_DOWN (5): Robot is sitting down FALL_DOWN (6): Robot has fallen down RL_STATE (16): Reinforcement learning state UNKNOWN_STATE (99): Unknown state

Members:

LIE_DOWN : Robot is lying down

STANDING_UP : Robot is in the process of standing up

STAND_UP : Robot is standing

ENABLE_FORCECONTROL : Force control mode

STEPPING : Stepping in place

SITTING_DOWN : Robot is sitting down

FALL_DOWN : Robot has fallen down

RL_STATE : Reinforcement learning state

UNKNOWN_STATE : Unknown state

Parameters:

value (int) –

ENABLE_FORCECONTROL: typing.ClassVar[RobotState]
FALL_DOWN: typing.ClassVar[RobotState]
LIE_DOWN: typing.ClassVar[RobotState]
RL_STATE: typing.ClassVar[RobotState]
SITTING_DOWN: typing.ClassVar[RobotState]
STANDING_UP: typing.ClassVar[RobotState]
STAND_UP: typing.ClassVar[RobotState]
STEPPING: typing.ClassVar[RobotState]
UNKNOWN_STATE: typing.ClassVar[RobotState]
property name: str
property value: int

机器人姿态状态枚举。

取值:

  • LIE_DOWN (0): 躺下状态

  • STANDING_UP (1): 正在站立(过渡状态)

  • STAND_UP (2): 站立状态

  • UNKNOWN_STATE (7): 未知状态(数据不可用或过期)

ControlMode

class ControlMode(value)

Bases: object

Control mode enumeration

Values:

JOY_MODE (0): Joystick/manual control mode NAV_MODE (1): Navigation/automatic control mode NULL_MODE (2): No state/null mode UWB_MODE (3): UWB positioning mode ASSIST_MODE (4): AI assist mode UNKNOWN_MODE (99): Unknown mode

Members:

JOY_MODE : Joystick/manual control mode

NAV_MODE : Navigation/automatic control mode

NULL_MODE : No state/null mode

UWB_MODE : UWB positioning mode

ASSIST_MODE : AI assist mode

UNKNOWN_MODE : Unknown mode

Parameters:

value (int) –

ASSIST_MODE: typing.ClassVar[ControlMode]
JOY_MODE: typing.ClassVar[ControlMode]
NAV_MODE: typing.ClassVar[ControlMode]
NULL_MODE: typing.ClassVar[ControlMode]
UNKNOWN_MODE: typing.ClassVar[ControlMode]
UWB_MODE: typing.ClassVar[ControlMode]
property name: str
property value: int

机器人控制模式枚举。

取值:

  • JOY_MODE (0): 手柄/手动控制模式

  • NAV_MODE (1): 导航/自动控制模式

  • UNKNOWN_MODE (99): 未知模式(数据不可用或过期)

GaitType

class GaitType(value)

Bases: object

Gait type enumeration

Values:

TROT (0): Trot gait (normal walking) NORMAL_STAIR (1): Normal stair climbing gait SLOPE (2): Slope/incline gait SENSE_STAIR (6): Sensing stair gait POSE_ADJUST (13): Pose adjustment/locked standing (MC) CAR_MODE (14): Crawling/car mode (MC) RL_TROT (0x20): RL walking gait RL_MOUNTAIN (0x21): RL mountain/terrain gait UNKNOWN_GAIT (99): Unknown gait

Members:

TROT : Trot gait (normal walking)

NORMAL_STAIR : Normal stair climbing gait

SLOPE : Slope/incline gait

SENSE_STAIR : Sensing stair gait

POSE_ADJUST : Pose adjustment/locked standing (MC)

CAR_MODE : Crawling/car mode (MC)

RL_TROT : RL walking gait

RL_MOUNTAIN : RL mountain/terrain gait

UNKNOWN_GAIT : Unknown gait

Parameters:

value (int) –

CAR_MODE: typing.ClassVar[GaitType]
NORMAL_STAIR: typing.ClassVar[GaitType]
POSE_ADJUST: typing.ClassVar[GaitType]
RL_MOUNTAIN: typing.ClassVar[GaitType]
RL_TROT: typing.ClassVar[GaitType]
SENSE_STAIR: typing.ClassVar[GaitType]
SLOPE: typing.ClassVar[GaitType]
TROT: typing.ClassVar[GaitType]
UNKNOWN_GAIT: typing.ClassVar[GaitType]
property name: str
property value: int

机器人步态类型枚举。

取值:

  • TROT (0): 小跑步态

  • NORMAL_STAIR (1): 普通楼梯步态

  • SLOPE (2): 斜坡步态

  • SENSE_STAIR (6): 感知楼梯步态

  • POSE_ADJUST (13): 姿态调整步态

  • CAR_MODE (14): 车模式步态

  • RL_TROT (0x20): 强化学习小跑步态

  • RL_Mountain (0x21): 强化学习山地步态

  • UNKNOWN_GAIT (99): 未知步态(数据不可用或过期)

DockState

class DockState(value)

Bases: object

Dock state enumeration

Values:

IDLE (0): Idle state GOING_TO_DOCK (1): Robot is going to the dock STAND_ABOVE_DOCK (2): Robot is standing above the dock ADJUST_POSE (3): Adjusting pose on dock LIE_ON_DOCKER (4): Robot is lying on the dock (charging) STANDING_AFTER_CHARGING (5): Standing up after charging LEAVING_DOCK (6): Robot is leaving the dock LEAVE_DOCK (7): Robot has left the dock UNKNOWN_DOCK (99): Unknown dock state

Members:

IDLE : Idle state

GOING_TO_DOCK : Robot is going to the dock

STAND_ABOVE_DOCK : Robot is standing above the dock

ADJUST_POSE : Adjusting pose on dock

LIE_ON_DOCKER : Robot is lying on the dock (charging)

STANDING_AFTER_CHARGING : Standing up after charging

LEAVING_DOCK : Robot is leaving the dock

LEAVE_DOCK : Robot has left the dock

UNKNOWN_DOCK : Unknown dock state

Parameters:

value (int) –

ADJUST_POSE: typing.ClassVar[DockState]
GOING_TO_DOCK: typing.ClassVar[DockState]
IDLE: typing.ClassVar[DockState]
LEAVE_DOCK: typing.ClassVar[DockState]
LEAVING_DOCK: typing.ClassVar[DockState]
LIE_ON_DOCKER: typing.ClassVar[DockState]
STANDING_AFTER_CHARGING: typing.ClassVar[DockState]
STAND_ABOVE_DOCK: typing.ClassVar[DockState]
UNKNOWN_DOCK: typing.ClassVar[DockState]
property name: str
property value: int

充电座状态枚举。

取值:

  • IDLE (0): 空闲

  • GOING_TO_DOCK (1): 正在前往充电座

  • STAND_ABOVE_DOCK (2): 站在充电座上方

  • ADJUST_POSE (3): 正在调整姿态

  • LIE_ON_DOCKER (4): 躺在充电座上

  • STANDING_AFTER_CHARGING (5): 充电后站立

  • LEAVING_DOCK (6): 正在离开充电座

  • LEAVE_DOCK (7): 已离开充电座

  • UNKNOWN_DOCK (99): 未知状态(数据不可用或过期)

DriverEnableState

class DriverEnableState(value)

Bases: object

Members:

UNKNOWN : 0: 未知

ENABLED : 1: 已使能

ENABLING : 2: 使能中

ENABLE_FAILED : 3: 使能失败

DISABLED : 4: 未使能

Parameters:

value (int) –

DISABLED: typing.ClassVar[DriverEnableState]
ENABLED: typing.ClassVar[DriverEnableState]
ENABLE_FAILED: typing.ClassVar[DriverEnableState]
ENABLING: typing.ClassVar[DriverEnableState]
UNKNOWN: typing.ClassVar[DriverEnableState]
property name: str
property value: int

驱动器使能状态枚举。

取值:

  • UNKNOWN (0): 未知状态

  • ENABLED (1): 已使能

  • ENABLING (2): 正在使能(过渡状态)

  • ENABLE_FAILED (3): 使能失败

  • DISABLED (4): 未使能(已下使能)

GetLidarStateResponse

class GetLidarStateResponse

Bases: object

property lidar_state: LidarState

雷达整机健康状态(LidarState 枚举):UNKNOWN/NORMAL/HIGHFREQ/LOWFREQ/DISCONNECT

property state: State

调用状态(State 对象,code/describe)

获取雷达状态的响应。

字段:

  • state (State): 操作状态

  • lidar_state (LidarState): 雷达整机健康状态枚举值

示例:

from daystar_api.lowlevel_skills import get_lidar_state, LidarState

response = get_lidar_state()
if response.lidar_state == LidarState.NORMAL:
    print("雷达正常")
elif response.lidar_state == LidarState.DISCONNECT:
    print("雷达断连")
elif response.lidar_state == LidarState.UNKNOWN:
    print("雷达状态未知(数据陈旧或尚未收到)")

LidarState

class LidarState(value)

Bases: object

Members:

UNKNOWN : 0: 未知(数据陈旧或尚未收到)

NORMAL : 1: 正常(约 10Hz)

HIGHFREQ : 2: 高频(≥15Hz)

LOWFREQ : 3: 低频(≤5Hz)

DISCONNECT : 4: 断连

Parameters:

value (int) –

DISCONNECT: typing.ClassVar[LidarState]
HIGHFREQ: typing.ClassVar[LidarState]
LOWFREQ: typing.ClassVar[LidarState]
NORMAL: typing.ClassVar[LidarState]
UNKNOWN: typing.ClassVar[LidarState]
property name: str
property value: int

雷达状态枚举,来源于 /nav/lidar_states 话题的 whole_lidar_state 字段。

取值:

  • UNKNOWN (0): 未知状态(数据陈旧或尚未收到)

  • NORMAL (1): 正常(约 10Hz)

  • HIGHFREQ (2): 高频(≥15Hz)

  • LOWFREQ (3): 低频(≤5Hz)

  • DISCONNECT (4): 断连

GetCurrentLocalizationModeResponse

class GetCurrentLocalizationModeResponse

Bases: object

property mode: LocalizationMode

当前定位模式:MAP(0)/SLAM(1)/REFLECTOR(2)/UNKNOWN_LOC_MODE(99)

property state: State

操作状态(code 0=成功)

获取当前定位模式的响应。

字段:

示例:

from daystar_api.lowlevel_skills import get_current_localization_mode, LocalizationMode

response = get_current_localization_mode()
if response.mode == LocalizationMode.MAP:
    print("地图定位")
elif response.mode == LocalizationMode.SLAM:
    print("SLAM 定位")
elif response.mode == LocalizationMode.REFLECTOR:
    print("反光柱定位")
elif response.mode == LocalizationMode.UNKNOWN_LOC_MODE:
    print("定位模式未知(数据陈旧或尚未收到)")

LocalizationMode

class LocalizationMode(value)

Bases: object

Members:

MAP : 0: 地图定位模式

SLAM : 1: SLAM 定位模式

REFLECTOR : 2: 反光柱定位模式

UNKNOWN_LOC_MODE : 99: 未知或数据陈旧

Parameters:

value (int) –

MAP: typing.ClassVar[LocalizationMode]
REFLECTOR: typing.ClassVar[LocalizationMode]
SLAM: typing.ClassVar[LocalizationMode]
UNKNOWN_LOC_MODE: typing.ClassVar[LocalizationMode]
property name: str
property value: int

当前定位模式枚举,来源于 /nav/current_localization_mode 话题(std_msgs/UInt8),读本地缓存、5 秒时效,过期或未收到返回 UNKNOWN_LOC_MODE

取值:

  • MAP (0): 地图定位

  • SLAM (1): SLAM 定位

  • REFLECTOR (2): 反光柱定位

  • UNKNOWN_LOC_MODE (99): 未知模式(数据陈旧或尚未收到)

客户自定义错误处理相关响应

RaiseWarnResponse

class RaiseWarnResponse

Bases: object

property response: SrvAPIRaiseWarn_Response

Service response

property state: State

State of the response

触发警告接口的响应。

字段:

示例:

response = raise_warn()
if response.response.success:
    print("触发警告成功!")

RaiseErrorResponse

class RaiseErrorResponse

Bases: object

property response: SrvAPIRaiseError_Response

Service response

property state: State

State of the response

触发警告接口的响应。

字段:

示例:

response = raise_error()
if response.response.success:
    print("触发错误提示成功!")

机械臂操作常量

ALL_JOINTS

ALL_JOINTS: list = []

Built-in mutable sequence.

If no argument is given, the constructor creates a new empty list. The argument must be an iterable if specified.

全部关节标记,等价于空列表 []。作为 move_joint()joint_names 默认值:不指定 joint_names``(或传 ``[] / ALL_JOINTS)即作用于机器人 全部关节(Umi /umi/move_joint 原生语义:joint_names 为空 = 所有关节)。

示例:

from daystar_api.lowlevel_skills import move_joint, ALL_JOINTS

# 以下三种写法等价,均作用于所有关节
move_joint(target_positions=[30, 30, 30, 10, 10, 10])
move_joint(joint_names=[], target_positions=[30, 30, 30, 10, 10, 10])
move_joint(joint_names=ALL_JOINTS, target_positions=[30, 30, 30, 10, 10, 10])

机械臂操作相关响应

机械臂操作接口统一遵循 state.code == 0 表示成功,具体 payload 位于 response 字段(类型为对应的 UmiXxxResponse,详见下文「机械臂操作服务响应」)。

MoveJointResponse

class MoveJointResponse

Bases: object

property response: UmiMoveJointResponse

原始 umi_msgs srv Response(含 payload)

property state: State

code==0 表示成功, describe 为 message

Type:

State

关节空间运动(move_joint())的响应。

字段:

示例:

resp = move_joint(joint_names=["joint1"], target_positions=[0.5])
if resp.state.code == 0:
    print("关节运动完成")

MoveToolResponse

class MoveToolResponse

Bases: object

property response: UmiMoveToolResponse

原始 umi_msgs srv Response(含 payload)

property state: State

code==0 表示成功, describe 为 message

Type:

State

笛卡尔空间末端运动(move_tool())的响应。

字段:

MoveToPoseResponse

class MoveToPoseResponse

Bases: object

property response: UmiMoveToPoseResponse

原始 umi_msgs srv Response(含 payload)

property state: State

code==0 表示成功, describe 为 message

Type:

State

运动到位姿库命名位姿(move_to_pose())的响应。

字段:

StopMotionResponse

class StopMotionResponse

Bases: object

property response: UmiStopMotionResponse

原始 umi_msgs srv Response(含 payload)

property state: State

code==0 表示成功, describe 为 message

Type:

State

停止运动(stop_motion())的响应。

字段:

ComputeFKResponse

class ComputeFKResponse

Bases: object

property response: UmiComputeFKResponse

原始 umi_msgs srv Response(含 payload)

property state: State

code==0 表示成功, describe 为 message

Type:

State

正运动学解算(compute_fk())的响应。

字段:

示例:

resp = compute_fk(joint_positions=[0.0, 0.5, -0.3])
if resp.state.code == 0:
    print(resp.response.left_target_pose.x)

ComputeIKResponse

class ComputeIKResponse

Bases: object

property response: UmiComputeIKResponse

原始 umi_msgs srv Response(含 payload)

property state: State

code==0 表示成功, describe 为 message

Type:

State

逆运动学解算(compute_ik())的响应。

字段:

  • state (State): 操作状态

  • response (UmiComputeIKResponse): 解算结果

    • joint_positions (list[float]): 解算出的关节角(角度,单位:度)

    • success (bool): 是否成功

PlanTrajectoryResponse

class PlanTrajectoryResponse

Bases: object

property response: UmiPlanTrajectoryResponse

原始 umi_msgs srv Response(含 payload)

property state: State

code==0 表示成功, describe 为 message

Type:

State

轨迹规划(plan_trajectory())的响应。

字段:

示例:

resp = plan_trajectory(left_target=target, cartesian=True)
if resp.state.code == 0:
    traj = resp.response.trajectory
    print(resp.response.fraction_achieved)

ExecutePathResponse

class ExecutePathResponse

Bases: object

property response: UmiExecutePathResponse

原始 umi_msgs srv Response(含 payload)

property state: State

code==0 表示成功, describe 为 message

Type:

State

路径执行(execute_path())的响应。

字段:

SavePoseResponse

class SavePoseResponse

Bases: object

property response: UmiSavePoseResponse

原始 umi_msgs srv Response(含 payload)

property state: State

code==0 表示成功, describe 为 message

Type:

State

保存位姿(save_pose())的响应。

字段:

RecordPoseResponse

class RecordPoseResponse

Bases: object

property response: UmiRecordPoseResponse

原始 umi_msgs srv Response(含 payload)

property state: State

code==0 表示成功, describe 为 message

Type:

State

记录当前末端位姿(record_pose())的响应。

字段:

GetPoseResponse

class GetPoseResponse

Bases: object

property response: UmiGetPoseResponse

原始 umi_msgs srv Response(含 payload)

property state: State

code==0 表示成功, describe 为 message

Type:

State

获取命名位姿(get_pose())的响应。

字段:

  • state (State): 操作状态

  • response (UmiGetPoseResponse): 位姿数据

    • joint_names (list[str]): 关节名称

    • joint_positions (list[float]): 关节角(角度,单位:度)

    • left_cartesian_target (CartesianTarget): 左臂笛卡尔目标

    • right_cartesian_target (CartesianTarget): 右臂笛卡尔目标

    • reference_frame (str): 参考坐标系

    • description (str): 位姿描述

    • success (bool): 是否成功

示例:

resp = get_pose(pose_name="home")
if resp.state.code == 0:
    print(resp.response.joint_positions)

ListPosesResponse

class ListPosesResponse

Bases: object

property response: UmiListPosesResponse

原始 umi_msgs srv Response(含 payload)

property state: State

code==0 表示成功, describe 为 message

Type:

State

位姿库列表(list_poses())的响应。

字段:

  • state (State): 操作状态

  • response (UmiListPosesResponse): 列表结果

    • pose_names (list[str]): 已保存位姿名称

    • success (bool): 是否成功

DeletePoseResponse

class DeletePoseResponse

Bases: object

property response: UmiDeletePoseResponse

原始 umi_msgs srv Response(含 payload)

property state: State

code==0 表示成功, describe 为 message

Type:

State

删除位姿(delete_pose())的响应。

字段:

StartRecordingResponse

class StartRecordingResponse

Bases: object

property response: UmiStartRecordingResponse

原始 umi_msgs srv Response(含 payload)

property state: State

code==0 表示成功, describe 为 message

Type:

State

开始轨迹录制(start_recording())的响应。

字段:

StopRecordingResponse

class StopRecordingResponse

Bases: object

property response: UmiStopRecordingResponse

原始 umi_msgs srv Response(含 payload)

property state: State

code==0 表示成功, describe 为 message

Type:

State

停止轨迹录制(stop_recording())的响应。

字段:

  • state (State): 操作状态

  • response (UmiStopRecordingResponse): 录制结果

    • num_points (int): 录制的轨迹点数

    • success (bool): 是否成功

ListTrajectoriesResponse

class ListTrajectoriesResponse

Bases: object

property response: UmiListTrajectoriesResponse

原始 umi_msgs srv Response(含 payload)

property state: State

code==0 表示成功, describe 为 message

Type:

State

轨迹库列表(list_trajectories())的响应。

字段:

  • state (State): 操作状态

  • response (UmiListTrajectoriesResponse): 列表结果

    • trajectory_names (list[str]): 已保存轨迹名称

    • success (bool): 是否成功

GetTrajectoryResponse

class GetTrajectoryResponse

Bases: object

property response: UmiGetTrajectoryResponse

原始 umi_msgs srv Response(含 payload)

property state: State

code==0 表示成功, describe 为 message

Type:

State

获取命名轨迹(get_trajectory())的响应。

字段:

DeleteTrajectoryResponse

class DeleteTrajectoryResponse

Bases: object

property response: UmiDeleteTrajectoryResponse

原始 umi_msgs srv Response(含 payload)

property state: State

code==0 表示成功, describe 为 message

Type:

State

删除轨迹(delete_trajectory())的响应。

字段:

PlayTrajectoryResponse

class PlayTrajectoryResponse

Bases: object

property response: UmiPlayTrajectoryResponse

原始 umi_msgs srv Response(含 payload)

property state: State

code==0 表示成功, describe 为 message

Type:

State

轨迹回放(play_trajectory())的响应。

字段:

ReadTcpPoseResponse

class ReadTcpPoseResponse

Bases: object

property response: UmiReadTcpPoseResponse

原始 umi_msgs srv Response(含 payload)

property state: State

code==0 表示成功, describe 为 message

Type:

State

读取 TCP 位姿(四元数,read_tcp_pose())的响应。

字段:

  • state (State): 操作状态

  • response (UmiReadTcpPoseResponse): 位姿数据

    • left_pose (Pose): 左臂末端位姿(position + orientation 四元数)

    • right_pose (Pose): 右臂末端位姿

    • success (bool): 是否成功

示例:

resp = read_tcp_pose()
if resp.state.code == 0:
    print(resp.response.left_pose.position.x)

ReadTcpRPYResponse

class ReadTcpRPYResponse

Bases: object

property response: UmiReadTcpRPYResponse

原始 umi_msgs srv Response(含 payload)

property state: State

code==0 表示成功, describe 为 message

Type:

State

读取 TCP 位姿(欧拉角 RPY,read_tcp_rpy())的响应。

字段:

GetCurrentJointsResponse

class GetCurrentJointsResponse

Bases: object

property response: UmiGetCurrentJointsResponse

原始 umi_msgs srv Response(含 payload)

property state: State

code==0 表示成功, describe 为 message

Type:

State

获取当前关节(get_current_joints())的响应。

字段:

  • state (State): 操作状态

  • response (UmiGetCurrentJointsResponse): 关节数据

    • joint_names (list[str]): 关节名称

    • joint_positions (list[float]): 关节角(角度,单位:度)

    • success (bool): 是否成功

RequestModeResponse

class RequestModeResponse

Bases: object

property response: UmiRequestModeResponse

原始 umi_msgs srv Response(含 payload)

property state: State

code==0 表示成功, describe 为 message

Type:

State

切换机械臂模式(request_mode())的响应。

字段:

  • state (State): 操作状态

  • response (UmiRequestModeResponse): 切换结果

    • current_mode (str): 切换后实际模式(IDLE / MOTION / SERVO)

    • current_detail (str): 子状态(SERVO 时为 CARTESIAN / JOINT)

    • reason (str): 失败原因,成功时为空

    • success (bool): 是否成功

示例:

resp = request_mode(mode="SERVO", detail="JOINT")
if resp.state.code == 0:
    print("当前模式:", resp.response.current_mode)

RaiseFaultResponse

class RaiseFaultResponse

Bases: object

property response: UmiRaiseFaultResponse

原始 umi_msgs srv Response(含 payload)

property state: State

code==0 表示成功, describe 为 message

Type:

State

主动进入 FAULT 模式(raise_fault())的响应。

字段:

  • state (State): 操作状态

  • response (UmiRaiseFaultResponse): 进入结果

    • current_mode (str): 当前模式,成功时恒为 FAULT

    • success (bool): 是否成功

ClearFaultResponse

class ClearFaultResponse

Bases: object

property response: Trigger_Response

原始 umi_msgs srv Response(含 payload)

property state: State

code==0 表示成功, describe 为 message

Type:

State

清除 FAULT、恢复 IDLE(clear_fault())的响应。

字段:

  • state (State): 操作状态

  • response (Trigger_Response): 清除结果(success / message)

示例:

resp = clear_fault()
if resp.state.code == 0:
    print("故障已清除")

SwitchLlmGroupResponse

class SwitchLlmGroupResponse

Bases: object

property active_group: str

切换后当前激活组(失败时为切换前的组)

property available_groups: list[str]

所有可用模型组名

property message: str

结果说明

property state: State

操作状态(code 0=成功)

property success: bool

是否切换成功

切换 agent LLM 模型组(switch_llm_group())的响应。

字段:

  • state (State): 操作状态

  • success (bool): 是否切换成功

  • message (str): 结果说明

  • active_group (str): 切换后当前激活组(失败时为切换前的组)

  • available_groups (list[str]): 所有可用模型组名

示例:

from daystar_api.lowlevel_skills import switch_llm_group

resp = switch_llm_group("local")
if resp.success:
    print("已切换到", resp.active_group, "可用组:", resp.available_groups)

AgentSwitchResponse

class AgentSwitchResponse

Bases: object

property message: str

结果说明

property state: State

操作状态(code 0=成功)

property success: bool

是否设置成功

agent 运行态开关(enable_voice_service() / enable_continuous_dialog() / enable_sound_orientation() / enable_safety_mode())的响应。

字段:

  • state (State): 操作状态

  • success (bool): 是否设置成功

  • message (str): 结果说明

示例:

from daystar_api.lowlevel_skills import enable_voice_service

resp = enable_voice_service(False)
if resp.success:
    print("语音服务已关闭")

ROS层服务响应类型

这些类型是底层 ROS 服务的响应结构,通常被包装在上述接口层响应类型的 response 字段中。

导航服务响应

SrvAPINavigationViaPoses_Response

class SrvAPINavigationViaPoses_Response

Bases: object

property message: str
property success: bool

多点导航的底层ROS服务响应。

字段:

  • success (bool): 是否成功

  • message (str): 状态消息

SrvAPINavigationViaLocations_Response

class SrvAPINavigationViaLocations_Response

Bases: object

property message: str
property success: bool

按已注册点位名序列做多点导航的底层 ROS 服务响应。字段语义与 SrvAPINavigationViaPoses_Response 相同——本类型只是为了与 api_msgs/srv/NavigationViaLocations 一一对应而独立绑定。

字段:

  • success (bool): 是否成功

  • message (str): 状态消息(任一 location yaml 加载失败时携带具体哪个 location 无法解析)

IntelligentNavigation_Result

class IntelligentNavigation_Result

Bases: object

property error_code: int
property error_msg: str
property result: bool

智能导航动作的结果。

字段:

  • result (int): 结果代码

  • error_code (int): 错误代码

  • error_msg (str): 错误消息

定位服务响应

SrvAPIGetCurrentPose_Response

class SrvAPIGetCurrentPose_Response

Bases: object

property location_pose: Pose
property success: bool

获取当前位姿的底层ROS服务响应。

字段:

  • success (bool): 是否成功

  • location_pose (PoseStamped): 当前位姿(带时间戳和坐标系)

示例:

# 通常在 GetCurrentPoseServiceResponse.response 中访问
response = get_current_pose()
if response.response.success:
    pose = response.response.location_pose
    print(f"X: {pose.position.x}, Y: {pose.position.y}")

SrvAPIGetLocalizationState_Response

class SrvAPIGetLocalizationState_Response

Bases: object

property loc_state: int

Localization state: - 0: NORMAL

  • 1: LACKDATA

  • 2: LOST

property success: bool

获取定位状态的底层ROS服务响应。

字段:

  • success (bool): 是否成功

  • loc_state (int): 定位状态

    • 0: NORMAL - 正常

    • 1: LACKDATA - 数据不足

    • 2: LOST - 丢失

示例:

response = get_localization_state()
if response.response.success:
    if response.response.loc_state == 0:
        print("定位正常")
    elif response.response.loc_state == 2:
        print("定位丢失")

云台服务响应

SrvSetPtzf_Response

class SrvSetPtzf_Response

Bases: object

property result: bool

设置云台位置的底层ROS服务响应。

字段:

  • result (bool): 是否成功

SrvAPIGetPtzf_Response

class SrvAPIGetPtzf_Response

Bases: object

property focus: int
property pan: float
property success: bool
property tilt: float
property zoom: float

获取云台位置的底层ROS服务响应。

字段:

  • success (bool): 是否成功

  • pan (float): 水平角度

  • tilt (float): 垂直角度

  • zoom (float): 变焦值

  • focus (int): 对焦值

相机服务响应

SrvAPICaptureImage_Response

class SrvAPICaptureImage_Response

Bases: object

property message: str
property success: bool

拍照的底层ROS服务响应。

字段:

  • success (bool): 是否成功

  • message (str): 状态消息

SrvAPIGetAvailableImages_Response

class SrvAPIGetAvailableImages_Response

Bases: object

property image_names: list[str]
property message: str
property success: bool

获取图像列表的底层ROS服务响应。

字段:

  • success (bool): 是否成功

  • message (str): 状态消息

  • image_names (list[str]): 图像文件名列表

SrvAPIGetAvailableVideos_Response

class SrvAPIGetAvailableVideos_Response

Bases: object

property message: str
property success: bool
property video_names: list[str]

获取视频列表的底层ROS服务响应。

字段:

  • success (bool): 是否成功

  • message (str): 状态消息

  • video_names (list[str]): 视频文件名列表

地图服务响应

SrvAPIGetAvailableMaps_Response

class SrvAPIGetAvailableMaps_Response

Bases: object

property map_names: list[str]
property maps: list[MapFileInfo]

各地图详细信息列表(含 FileInfo)

property message: str
property success: bool

获取地图列表的底层ROS服务响应。

字段:

  • success (bool): 是否成功

  • message (str): 状态消息

  • map_names (list[str]): 地图名称列表

SrvSetLocalizationMode_Response

class SrvSetLocalizationMode_Response

Bases: object

property result: bool

设置定位模式的底层ROS服务响应。

字段:

  • result (bool): 是否成功

SrvReloadMap_Response

class SrvReloadMap_Response

Bases: object

property result: bool

重新加载地图的底层ROS服务响应。

字段:

  • result (bool): 是否成功

SrvSaveMap_Response

class SrvSaveMap_Response

Bases: object

property result: bool

保存地图的底层ROS服务响应。

字段:

  • result (bool): 是否成功

SrvAPIStartMapping_Response

class SrvAPIStartMapping_Response

Bases: object

property message: str
property success: bool

开始建图的底层ROS服务响应。

字段:

  • success (bool): 是否成功

  • message (str): 状态消息

SrvAPIStopMapping_Response

class SrvAPIStopMapping_Response

Bases: object

property message: str
property success: bool

停止建图的底层ROS服务响应。

字段:

  • success (bool): 是否成功

  • message (str): 状态消息

SrvAPILoadMap_Response

class SrvAPILoadMap_Response

Bases: object

property message: str
property success: bool

加载地图的底层ROS服务响应。

字段:

  • success (bool): 是否成功

  • message (str): 状态消息

SrvAPISetLocalization_Response

class SrvAPISetLocalization_Response

Bases: object

property message: str
property success: bool

设置定位的底层ROS服务响应。

字段:

  • success (bool): 是否成功

  • message (str): 状态消息

SrvSetLocalization_Response

class SrvSetLocalization_Response

Bases: object

property result: bool
property result_pose: PoseWithCovarianceStamped

设置定位的底层ROS服务响应。

字段:

  • result (bool): 是否成功

  • result_pose (PoseStamped): 设置后的位姿

机械臂操作服务响应

以下 UmiXxxResponse 是机械臂操作底层 Umi ROS 服务的响应结构,被包装在对应 接口层响应(如 MoveJointResponse)的 response 字段中。除特别标注 payload 字段外,均统一含 success (bool) 与 message (str)。

UmiMoveJointResponse

class UmiMoveJointResponse

Bases: object

message: str
success: bool

关节运动底层服务响应。字段: success (bool)、message (str)。

UmiMoveToolResponse

class UmiMoveToolResponse

Bases: object

message: str
success: bool

末端运动底层服务响应。字段: success (bool)、message (str)。

UmiMoveToPoseResponse

class UmiMoveToPoseResponse

Bases: object

message: str
success: bool

运动到位姿底层服务响应。字段: success (bool)、message (str)。

UmiStopMotionResponse

class UmiStopMotionResponse

Bases: object

message: str
success: bool

停止运动底层服务响应。字段: success (bool)、message (str)。

UmiComputeFKResponse

class UmiComputeFKResponse

Bases: object

left_target_pose: CartesianTarget
message: str
right_target_pose: CartesianTarget
success: bool

正运动学底层服务响应。

字段:

UmiComputeIKResponse

class UmiComputeIKResponse

Bases: object

joint_positions: list[float]
message: str
success: bool

逆运动学底层服务响应。

字段:

  • joint_positions (list[float]): 解算关节角(角度,单位:度)

  • success (bool) / message (str)

UmiPlanTrajectoryResponse

class UmiPlanTrajectoryResponse

Bases: object

fraction_achieved: float
message: str
success: bool
trajectory: JointTrajectory

轨迹规划底层服务响应。

字段:

  • trajectory (JointTrajectory): 规划轨迹

  • fraction_achieved (float): 笛卡尔规划完成比例

  • success (bool) / message (str)

UmiExecutePathResponse

class UmiExecutePathResponse

Bases: object

message: str
success: bool

路径执行底层服务响应。字段: success (bool)、message (str)。

UmiSavePoseResponse

class UmiSavePoseResponse

Bases: object

message: str
success: bool

保存位姿底层服务响应。字段: success (bool)、message (str)。

UmiRecordPoseResponse

class UmiRecordPoseResponse

Bases: object

left_cartesian_target: CartesianTarget
message: str
right_cartesian_target: CartesianTarget
success: bool

记录位姿底层服务响应。

字段:

  • left_cartesian_target (CartesianTarget): 左臂末端位姿

  • right_cartesian_target (CartesianTarget): 右臂末端位姿

  • success (bool) / message (str)

UmiGetPoseResponse

class UmiGetPoseResponse

Bases: object

description: str
joint_names: list[str]
joint_positions: list[float]
left_cartesian_target: CartesianTarget
message: str
reference_frame: str
right_cartesian_target: CartesianTarget
success: bool

获取位姿底层服务响应。

字段:

  • joint_names (list[str]) / joint_positions (list[float])

  • left_cartesian_target / right_cartesian_target (CartesianTarget)

  • reference_frame (str) / description (str)

  • success (bool) / message (str)

UmiListPosesResponse

class UmiListPosesResponse

Bases: object

message: str
pose_names: list[str]
success: bool

位姿库列表底层服务响应。

字段: pose_names (list[str])、success (bool)、message (str)。

UmiDeletePoseResponse

class UmiDeletePoseResponse

Bases: object

message: str
success: bool

删除位姿底层服务响应。字段: success (bool)、message (str)。

UmiStartRecordingResponse

class UmiStartRecordingResponse

Bases: object

message: str
success: bool

开始录制底层服务响应。字段: success (bool)、message (str)。

UmiStopRecordingResponse

class UmiStopRecordingResponse

Bases: object

message: str
num_points: int
success: bool

停止录制底层服务响应。

字段: num_points (int)、success (bool)、message (str)。

UmiListTrajectoriesResponse

class UmiListTrajectoriesResponse

Bases: object

message: str
success: bool
trajectory_names: list[str]

轨迹库列表底层服务响应。

字段: trajectory_names (list[str])、success (bool)、message (str)。

UmiGetTrajectoryResponse

class UmiGetTrajectoryResponse

Bases: object

description: str
message: str
success: bool
trajectory: JointTrajectory

获取轨迹底层服务响应。

字段:

  • trajectory (JointTrajectory): 关节轨迹

  • description (str) / success (bool) / message (str)

UmiDeleteTrajectoryResponse

class UmiDeleteTrajectoryResponse

Bases: object

message: str
success: bool

删除轨迹底层服务响应。字段: success (bool)、message (str)。

UmiPlayTrajectoryResponse

class UmiPlayTrajectoryResponse

Bases: object

message: str
success: bool

轨迹回放底层服务响应。字段: success (bool)、message (str)。

UmiReadTcpPoseResponse

class UmiReadTcpPoseResponse

Bases: object

left_pose: Pose
message: str
right_pose: Pose
success: bool

读取 TCP 四元数位姿底层服务响应。

字段:

  • left_pose (Pose) / right_pose (Pose)

  • success (bool) / message (str)

UmiReadTcpRPYResponse

class UmiReadTcpRPYResponse

Bases: object

left_pose: CartesianTarget
message: str
right_pose: CartesianTarget
success: bool

读取 TCP 欧拉角位姿底层服务响应。

字段:

UmiGetCurrentJointsResponse

class UmiGetCurrentJointsResponse

Bases: object

joint_names: list[str]
joint_positions: list[float]
message: str
success: bool

获取当前关节底层服务响应。

字段:

  • joint_names (list[str]) / joint_positions (list[float])

  • success (bool) / message (str)

UmiRequestModeResponse

class UmiRequestModeResponse

Bases: object

current_detail: str
current_mode: str
reason: str
success: bool

模式切换底层服务响应。

字段:

  • current_mode (str) / current_detail (str) / reason (str)

  • success (bool)

UmiRaiseFaultResponse

class UmiRaiseFaultResponse

Bases: object

current_mode: str
success: bool

进入故障底层服务响应。字段: current_mode (str,恒为 FAULT)、success (bool)。

客户自定义错误处理响应

SrvAPIRaiseWarn_Response

class SrvAPIRaiseWarn_Response

Bases: object

property message: str
property success: bool

触发警告底层ROS服务响应。

字段:

  • success (bool): 是否成功

  • message (str): 状态消息

SrvAPIRaiseError_Response

class SrvAPIRaiseError_Response

Bases: object

property message: str
property success: bool

触发错误底层ROS服务响应。

字段:

  • success (bool): 是否成功

  • message (str): 状态消息

事件类型

类型转换和使用注意事项

Python 和 C++ 类型映射

Python 类型

C++ 类型

说明

str

std::string

字符串

int

int32_t

32 位整数

float

double

双精度浮点数

bool

bool

布尔值

list

std::vector

动态数组

dict

N/A

可用于构造 Pose 等对象

常见用法模式

1. 检查响应状态:

response = some_function()
if response.state.code == 0:
    # 成功
    process_result(response.response)
else:
    # 失败
    print(f"错误: {response.state.describe}")

2. 构造位姿:

# 方法 1:空构造 + setter(任何时候都可用)
pose = Pose()
pose.position.x = 1.0
pose.position.y = 2.0
pose.orientation.w = 1.0

# 方法 2:kwargs / 位置参数(推荐:orientation 默认 identity,无需手设 w=1)
pose = Pose(position=Point(1.0, 2.0, 0.0))
pose = Pose(Point(1.0, 2.0, 0.0))   # 等价

# 方法 3:使用字典(部分高层函数支持)
navigation_to_pose({"x": 1.0, "y": 2.0, "qw": 1.0})

3. 设置导航参数:

params = MsgTravelParams()
params.speed_mode = 2  # 低速
params.distance_tolerance = 0.3

navigation_to_location("target", travel_params=params)

4. 使用回调函数:

def on_complete(event):
    print("导航完成!")

def on_failed(event):
    print(f"导航失败: {event.error_msg}")

navigation_to_location(
    "destination",
    complete_callback=on_complete,
    failed_callback=on_failed
)

相关文档