跳转到内容

用速度指令飞导航无人机

需要:uBotAerial 0.1.x(含依赖 uBotCore),并启用引擎插件 EnhancedInput

用速度和偏航角速度指令控制导航无人机(uBot Simple Flight),并了解它的响应、刹车和倾斜怎样设置。

指令在航向坐标系里解释:X 沿当前航向向前,Y 向右,Z 向上,单位 m/s。角速度只用 Z 分量,即偏航角速度(rad/s,正值向右转):

连线:

  1. Find Multirotor Movement 的 Return Value,连到 Apply Velocity Command 的 Target
  2. Make Vector 的 Return Value,连到 Make UBot Velocity Command 的 Linear Velocity Meters Per Second
  3. Make Vector 的 Return Value,连到 Make UBot Velocity Command 的 Angular Velocity Radians Per Second
  4. Make UBot Velocity Command 的 UBot Velocity Command,连到 Apply Velocity Command 的 Command
以 2 m/s 前进,同时以 0.5 rad/s 向右偏航
  1. Actor 引脚接无人机;从 Pawn 蓝图内部调用时接 Get Self。

最新的一条指令一直有效,直到被新指令替换或调用 Stop Motion。超过 Velocity Limits 的部分被截断。

  1. 找到飞行模型

    用 Find Multirotor Movement 从无人机取得 Movement 组件;在无人机的蓝图内部,也可以直接拖出 Movement。

  2. 发指令

    对它调用 Apply Velocity Command,Command 用 Make UBot Velocity Command 组装。返回 false 表示指令被拒绝,例如含 NaN。

  3. 停下

    调用 Stop Motion。无人机换用刹车参数减速到静止;Is Braking 从 Stop Motion 起一直返回真,直到收到下一条速度指令,静止之后也是真。

用 uBotROS 的 uBot ROS Velocity Command 组件时,不用改任何东西就能驱动它,见 接收 cmd_vel。

飞行模型按一阶响应逼近目标速度,并有加速度和加加速度(Jerk)上限。选中 Movement 组件,属性在「Details」面板的 Simple Flight 类别下,分在 Tracking、Braking 和 Wind 子类别里:

属性 默认值 作用
Horizontal Time Constant Seconds 0.3 s 水平速度响应的时间常数
Vertical Time Constant Seconds 0.25 s 垂直速度响应的时间常数
Max Horizontal Acceleration Meters Per Second Squared 4 m/s² 水平加速度上限
Max Vertical Acceleration Meters Per Second Squared 3 m/s² 垂直加速度上限
Jerk Limit Meters Per Second Cubed 30 m/s³ 加速度变化率上限,0 表示关闭
Yaw Time Constant Seconds 0.15 s 偏航角速度响应的时间常数
Brake Time Constant Seconds 0.1 s Stop Motion 之后刹车的时间常数
Brake Horizontal Acceleration Meters Per Second Squared 6 m/s² 刹车时水平减速度上限
Tilt Mode Visual 什么随加速度倾斜
Max Tilt Degrees 25° 最大倾角,范围 0 到 60

导航无人机 Movement 组件的 Details 面板:Simple Flight 下有 Tilt Mode、Max Tilt Degrees 和 Visual Component,以及 Tracking、Braking、Wind 子类别

在蓝图编辑器里,Visual Component 显示为 None。这是 UE 的组件选择器对蓝图里添加的组件的显示限制:示例实际指向 VisualRoot,运行时生效,不用去改它。

Velocity Limits(在共有属性里)默认水平 10 m/s、爬升 3 m/s、下降 2 m/s、偏航 π/2 rad/s。其余属性见 uBot Simple Flight 和 uBot Multirotor Movement。

Get Multirotor State 返回无人机的真值状态,用 Break UBot Multirotor State 取出位置(m)、姿态、线速度(m/s)、角速度(rad/s)等:

连线:

  1. Event Tick 的 执行,连到 Print String 的 执行
  2. Find Multirotor Movement 的 Return Value,连到 Get Multirotor State 的 Target
  3. Get Multirotor State 的 Return Value,连到 Break UBot Multirotor State 的 UBot Multirotor State
  4. Break UBot Multirotor State 的 Linear Velocity Meters Per Second,连到 Vector Length 的 A
  5. Vector Length 的 Return Value,连到 To String (Float) 的 In Double
  6. To String (Float) 的 Return Value,连到 Print String 的 In String
每个 Tick 在屏幕上显示当前速度(m/s)
  • 倾斜不是动力学的结果:机体 Z 轴指向加速度减去重力的方向,倾角不超过 Max Tilt Degrees。Tilt Mode 决定哪一部分跟着倾斜:
    • None:都不倾斜,只偏航。
    • Visual(默认):只有 Visual Component 指向的外观倾斜,挂在根组件上的传感器保持水平。
    • Body:根组件倾斜,传感器看到真实多旋翼会有的姿态。
  • Get Tilted Attitude 在任何模式下都返回倾斜后的姿态。
  • 物理步频默认 500 Hz,Physics Rate Hz 可以调,范围 100 到 4000 Hz。它按 uBot 仿真时钟推进,暂停时不动;恒定指令下,不同帧率的结果相同,新指令从下一帧开始生效。
  • 导航无人机没有姿态、角速度和电机指令的接口,需要它们时用 物理无人机。