8. 车辆抽象与 Stage
本文描述 autonomy/vehicle 车辆抽象层及 Stage 2D 仿真配置占位。
8.1 Vehicle 模块架构
VehicleServer
│
▼
Vehicle (VehicleInterface 默认实现)
│
├─ Initialize(model) # 加载 VehicleModel
├─ ApplyCommand(cmd) # 发送控制(待接仿真/硬件)
└─ GetVehicleInfo(info) # 查询状态
│
▼
KinematicsControl::ApplyLimits(cmd) # 速度/加速度限幅
8.2 VehicleInterface
文件:autonomy/vehicle/common/vehicle_inteface.hpp
方法 |
说明 |
|---|---|
|
加载尺寸、动力学约束 |
|
返回速度、加速度等状态 |
|
下发 |
设计意图:ApplyCommand 未来可对接:
Gazebo 差速插件
真实底盘驱动
nav_test积分器
8.3 Vehicle 当前实现
// vehicle.hpp 注释摘要
// ApplyCommand():暂时只缓存最近一次控制指令,
// 实际硬件/仿真下发逻辑留作 TODO。
状态字段缓存在 VehicleInfo 中,供上层查询期望值。
8.4 KinematicsControl
职责:基于 VehicleModel 对 Twist 限幅:
约束 |
字段 |
|---|---|
最大线速度 |
|
最大倒车速度 |
|
最大角速度 |
|
线/角加速度 |
|
数学:见 03_math.md §3.6。
统一处理差速、全向、Ackermann 的 \(v_x, v_y, \omega_z\) 限幅。
8.5 VehicleModel(Proto)
autonomy/vehicle/proto/vehicle_options.proto 定义:
机器人尺寸(长、宽、高)
运动学类型(diff_drive / holonomic / ackermann)
速度、加速度、转向角上限
8.6 Stage 仿真配置
8.6.1 simulation.lua
AUTONOMY_SIMULATION = {
stage = {
world_file = "configuration_files/simulation/world/willow-erratic.world",
map_file = "configuration_files/simulation/map/willow-erratic.yaml",
},
pedsim = { },
}
仓库内实际存在
config/simulation/world/cave.world,与 lua 中willow-erratic路径不一致。
8.6.2 cave.world 内容
元素 |
说明 |
|---|---|
|
机器人实例 |
|
270° 2D 激光 |
|
RGB-D 相机 |
|
16×16 m 洞穴地图( |
Player/Stage 格式,可独立用 Stage 运行,无本仓库 C++ 客户端。
8.6.3 Pedsim 占位
pedsim = {} 预留行人仿真,未实现。
8.7 统一仿真后端(规划)
class StageSimulator : public VehicleInterface {
bool ApplyCommand(const KinematicsControlCommand& cmd) override {
// 转发至 Stage position2d 接口
}
};
class GazeboSimulator : public VehicleInterface {
// 经 ROS topic 发布 cmd_vel
};
SimulationServer 根据 simulation.lua 选择后端实例化。