【ROS学习】配置rotors-simulator

发布时间 2023-06-03 23:24:42作者: cccopy

本文按照https://github.com/ethz-asl/rotors_simulator一步一步搭建并且踩坑记录。

  • 第一个坑:尽量不要在虚拟机上跑,因为你在catkin make的时候就会卡住。

  • 在原文中也提到了,第一次加载gazebo的时候会出现超时error,不要慌,关闭当前gazebo窗口再次输入用法的1命令。

  • 好像用不了他的其他地图。

  • 在ubuntu16环境下也需要将他自己的那个rotors_simulator放到src中。

  • 需要仔细端详他给的mavlink,可能版本对不上自己的linux系统。

  • 需要安装mavros,具体的方法好像是sudo apt get install ros-kinetic-mavros,有点忘了,网上有很多教程,不麻烦。

用法

  1. 开启gazebo命令roslaunch rotors_gazebo mav_hovering_example.launch mav_name:=firefly world_name:=basic

  2. 操作MAV

    • 方法一:使用gazebo界面和按压play button(world下面的property),这样好像不太聪明的样子。
    • 方法二:rosservice call gazebo/unpause_physics
  3. 发送direct motor commands

    rostopic pub /firefly/command/motor_speed mav_msgs/Actuators '{angular_velocities: [100, 100, 100, 100, 100, 100]}',需要注意的是,这里的angular_velocities的数组和你无人机的旋翼数目对应,在这个例子中为6旋翼的。

  4. create an attitude controller

package解读

  • 位于src/rotors_simulator/rotors_gazebo/launch中的firefly_swarm_hovering_example.launch文件运行多机盘旋。
  • 位于src/rotors_simulator/rotors_gazebo/launch中的fixed_wing.launch文件运行固定翼飞机。
  • 位于src/rotors_simulator/rotors_gazebo/launch中的firefly_swarm_hovering_example.launch文件运行多机盘旋。

代码解读

在这之前需要知道:

名词 解释
pitch 围绕X轴旋转,也叫做俯仰角
yaw 围绕Y轴旋转,也叫偏航角
roll 围绕Z轴旋转,也叫翻滚角
  • hil_controls_msg
名词 解释
pitch_elevator 自己体会
yaw_rudder 偏航角舵
roll_ailerons 翻滚角副翼
throttle 风门

多的不说,直接看rotors_gazebo/src/hovering_example.cpp

多机 :firefly_swam_hovering_example.launch,其中需要看waypoint_publisher_file.cpp,其中提到args[x,y,z,yaw,wait_time],按照的是launch文件中的顺序