功能包简介

mav_control_rw 功能包是ETHZ ASL的利用mpc控制实现了旋翼式无人机的轨迹追踪算法。

mpc是模型预测控制的简称,全称是Model-based Predictive Control

mpc利用一个已有的模型、系统当前的状态和未来的控制量,来预测系统未来的输出,然后与我们期望的系统输出做比较,得到代价函数,通过优化的方法,优化出未来控制量,使得代价函数最小。优化出来的控制量即算法的输出。

MPC 优点

  • 善于处理多输入多输出系统(MIMO)
  • 可以处理约束,如安全性约束,上下阈值
  • 是一种向前考虑未来时间步的有限时域优化方法(一定的预测能力)


传统的无人机多采用PID控制器, PID控制器不具有“前瞻性”,参与计算的各个量,有当前的 ,上个控制周期的 ,以及之前所有的 累计和,没有未来的 。PID属于无模型控制。PID仅仅通过目标和当前状态的差距,以及三个控制参数,就输出控制量。

github地址:https://github.com/ethz-asl/mav_control_rw

相关论文:

  • Model Predictive Control for Trajectory Tracking of Unmanned Aerial Vehicles Using Robot Operating System. Mina Kamel, Thomas Stastny, Kostas Alexis and Roland Siegwart. Robot Operating System (ROS) The Complete Reference Volume 2. Springer 2017 (to appear)

  • Linear vs Nonlinear MPC for Trajectory Tracking Applied to Rotary Wing Micro Aerial Vehicles. Mina Kamel, Michael Burri and Roland Siegwart. arXiv:1611.09240

功能包中包含了多种控制器来实现对旋翼无人机的控制,当前包含的控制器有:

  • mav_linear_mpc:线性MPC轨迹跟踪控制器
  • mav_nonlinear_mpc:非线性MPC轨迹跟踪控制器
  • PID_attitude_control:PID姿态控制器

安装

ubuntu系统:20.04
ROS系统:noetic

 $ git clone https://github.com/ethz-asl/rotors_simulator.git
 $ git clone https://github.com/ethz-asl/mav_comm.git
 $ git clone https://github.com/ethz-asl/eigen_catkin.git
 $ git clone https://github.com/catkin/catkin_simple.git
 $ git clone https://github.com/ethz-asl/mav_control_rw.git

catkin_make

编译报错:

In file included from /home/jk-jone/jone_ws/src/mav_control_rw/mav_nonlinear_mpc/src/nonlinear_mpc.cc:33:
/home/jk-jone/jone_ws/src/mav_control_rw/mav_nonlinear_mpc/include/mav_nonlinear_mpc/nonlinear_mpc.h:44:10: fatal error: lapacke.h: 没有那个文件或目录
44 | #include
| ^~~
compilation terminated.

解决办法:

  $ sudo apt-get install liblapacke-dev

再次编译
卡在这里了半天

等了好长时间,终于编译过了

gazebo仿真测试

启动gazebo并加载无人机模型

$ roslaunch rotors_gazebo mav.launch mav_name:=firefly

启动 linear mpc 控制器

$ roslaunch mav_linear_mpc mav_linear_mpc_sim.launch mav_name:=firefly

launch启动的节点如下:

<launch>
  <arg name="mav_name" default="firefly" />
  <arg name="namespace" default="$(arg mav_name)"/>
  <group ns="$(arg namespace)">
    <node name="mav_linear_mpc" pkg="mav_linear_mpc" type="mav_linear_mpc_node" respawn="true" clear_params="true" output="screen">
      <remap from="odometry" to="ground_truth/odometry" />
      <rosparam file="$(find mav_linear_mpc)/resources/linear_mpc_$(arg mav_name).yaml" />
      <rosparam file="$(find mav_disturbance_observer)/resources/disturbance_observer_$(arg mav_name).yaml"/>
      <param name="verbose" value="true" />
      <param name="use_rc_teleop" value="false" />
      <param name="reference_frame" value="world" />
    </node>

    <node name="PID_attitude_controller" pkg="mav_lowlevel_attitude_controller" type="mav_pid_attitude_controller_node" respawn="true" clear_params="true" output="screen">
      <remap from="odometry" to="ground_truth/odometry" />
      <rosparam file="$(find mav_lowlevel_attitude_controller)/resources/PID_attitude_$(arg mav_name).yaml" />
    </node>
  </group>
</launch>



启动 rqt
打开Plugins菜单中visualization里的Message Publisher,
在topic的下拉菜单中选择/firefly/command/pose
发布的话题名称为/firefly/command/pose即可实现定点控制拉

更改position 的 x y z 的值,就是给无人机发的位置控制指令


然后勾选那个方框把topic发送出去

无人机运动到了目标位置处

整体的运行效果很理想。

支持的飞行平台

上面的是在gazebo中进行的仿真测试
该功能包还可以应用与不同的飞行平台

  • Asctec
    AscTec 是 德国Ascending Technologies公司的缩写。有几款经典的机型:AscTec Hummingbird、AscTec Pelican、AscTec Firefly
    是很早的无人机了,实物张下面这个样子:

    在早年间雷锋网上说:AscTec 与大疆、Parrot、3D Robotics成为最大的四家四轴飞行器品牌。

  • Pixhawk
    需要对PX4的固件进行修改,以支持航向角速度的输入。
    修改好的固件可从https://github.com/ethz-asl/ethzasl_mav_px4这里获取
    Pixhawk是世界上最出名的开源飞控硬件厂商3DR推出的开源飞控。Pixhawk作为开源硬件且具有强大的功能,可靠的性能等到了广大用户的青睐。其硬件的开源使不少的硬件厂商加入了制造pixhawk的行列,cuav作为国内知名的开源飞控的厂商,其按照pixhawk原版的设计,采用相同的硬件设计及全进口芯片,使其生产出来的pixhawk具有相当高的稳定性。

  • DJI
    可以通过dji 的ros接口,控制部分 dji无人机。

发布和订阅的topic

线性mpc控制器和非线性mpc控制器发布和订阅的话题如下:

发布topic

  • command/roll_pitch_yawrate_thrust
    消息类型为mav_msgs/RollPitchYawrateThrust ,下层控制器的控制指令。角度的单位为弧度、推力的单位为N.

  • command/current_reference
    消息类型为trajectory_msgs/MultiDOFJointTrajectory ,当前参考值

  • state_machine/state_info
    消息类型为std_msgs/String,mav_control_interface的当前状态

  • predicted_state
    消息类型为visualization_msgs/Marker,可以在rviz中可视化的预测无人机的位置

  • reference_trajectory
    消息类型为visualization_msgs/Marker,可以在rviz中可视化的无人机参考轨迹

  • KF_observer/observer_state
    消息类型为mav_disturbance_observer/ObserverState,用于调试的外部扰动观测器,包含了外部力和扭矩的估计

订阅topic

  • command/pose
    消息类型为geometry_msgs/PoseStamped,位置指令,在本地坐系下的

  • command/trajectory
    消息类型为trajectory_msgs/MultiDOFJointTrajectory,期望的运动轨迹,包含期望的速度和加速度

  • rc
    消息类型为sensor_msgs/Joy,遥控器的指令

  • odometry
    消息类型为nav_msgs/Odometry,无人机当前状态,包含位置和速度信息