赞
踩
转载自:https://blog.csdn.net/u013083665/article/details/104840286
1113249853 2020-04-01 13:35:04
收藏 21
版权声明:本文为博主原创文章,遵循 CC 4.0 BY-SA 版权协议,转载请附上原文出处链接和本声明。
本文链接:https://blog.csdn.net/u013083665/article/details/104840286
版权
cd到Firmware文件夹,执行以下代码
roslaunch px4 mavros_posix_sitl.launch
如果启动过程卡住或者很慢,下载该链接的压缩包https://bitbucket.org/osrf/gazebo_models/downloads/
解压到.gazebo/models文件夹下,该文件夹为隐藏文件夹,按ctrl+h使其显示。如果没有models文件夹,则自己新建一个
启动后输入
commander takeoff
测试其是否正常起飞
在{path_to_firmware}/launch文件夹中找到mavros_posix_sitl.launch
文件,打开
<?xml version="1.0"?>
<launch>
<!-- MAVROS posix SITL environment launch script -->
<!-- launches MAVROS, PX4 SITL, Gazebo environment, and spawns vehicle -->
<!-- vehicle pose -->
<arg name="x" default="0"/>
<arg name="y" default="0"/>
<arg name="z" default="0"/>
<arg name="R" default="0"/>
<arg name="P" default="0"/>
<arg name="Y" default="0"/>
<!-- vehicle model and world -->
<arg name="est" default="ekf2"/>
<arg name="vehicle" default="iris"/>
<arg name="my_model" default="iris_fpv_cam"/>
<arg name="world" default="$(find mavlink_sitl_gazebo)/worlds/empty.world"/>
<!-- <arg name="sdf" default="$(find mavlink_sitl_gazebo)/models/$(arg vehicle)/$(arg vehicle).sdf"/>-->
<arg name="sdf" default="$(find mavlink_sitl_gazebo)/models/$(arg my_model)/$(arg my_model).sdf"/>
<!-- gazebo configs -->
<arg name="gui" default="true"/>
<arg name="debug" default="false"/>
<arg name="verbose" default="false"/>
<arg name="paused" default="false"/>
<arg name="respawn_gazebo" default="false"/>
<!-- MAVROS configs -->
<arg name="fcu_url" default="udp://:14540@localhost:14557"/>
<arg name="respawn_mavros" default="false"/>
<!-- PX4 configs -->
<arg name="interactive" default="true"/>
<!-- PX4 SITL and Gazebo -->
<include file="$(find px4)/launch/posix_sitl.launch">
<arg name="x" value="$(arg x)"/>
<arg name="y" value="$(arg y)"/>
<arg name="z" value="$(arg z)"/>
<arg name="R" value="$(arg R)"/>
<arg name="P" value="$(arg P)"/>
<arg name="Y" value="$(arg Y)"/>
<arg name="world" value="$(arg world)"/>
<arg name="vehicle" value="$(arg vehicle)"/>
<arg name="sdf" value="$(arg sdf)"/>
<arg name="gui" value="$(arg gui)"/>
<arg name="interactive" value="$(arg interactive)"/>
<arg name="debug" value="$(arg debug)"/>
<arg name="verbose" value="$(arg verbose)"/>
<arg name="paused" value="$(arg paused)"/>
<arg name="respawn_gazebo" value="$(arg respawn_gazebo)"/>
</include>
<!-- MAVROS -->
<include file="$(find mavros)/launch/px4.launch">
<!-- GCS link is provided by SITL -->
<arg name="gcs_url" value=""/>
<arg name="fcu_url" value="$(arg fcu_url)"/>
<arg name="respawn_mavros" value="$(arg respawn_mavros)"/>
</include>
</launch>
做如下改动:
添加
<arg name="my_model" default="iris_fpv_cam"/>
修改
<arg name="sdf" default="$(find mavlink_sitl_gazebo)/models/$(arg vehicle)/$(arg vehicle).sdf"/>
为
<arg name="sdf" default="$(find mavlink_sitl_gazebo)/models/$(arg my_model)/$(arg my_model).sdf"/>
然后保存
打开{path_to_firmware}/Tools/sitl_gazebo/models/
iris_fpv_cam中的iris_fpv_cam.sdf文件
修改
<include>
<uri>model://fpv_cam</uri>
<pose>0 0 0 0 0 0</pose>
</include>
为
<include>
<uri>model://fpv_cam</uri>
<pose>0 0 0 0 1.57 0</pose>
</include>
其中<pose>0 0 0 0 0 0</pose>
为相机朝向参数意义为XYZ
,以及以XYZ
为顺序的欧拉角(幅度表示,逆时针为正)
如果想添加下置相机,修改pose为<pose>0 0 0 0 1.57 0</pose>
Copyright © 2003-2013 www.wpsshop.cn 版权所有,并保留所有权利。