mavros踩坑记录

mavros添加发布 tfmini 距离传感器数据

有关px4连接tfmini并配置的部分请自行到 Px4 使用手册 查找相关说明,配置成功后打开QGroundControl, 找到Mavlink Inspector, 选择 DISTANCE_SENSOR可以看到发布的高度传感器的id和数据
laser
首先说明下MAVROS px4在启动时调用 roslaunch mavros px4.launch <args> ,打开($ find mavros)/mavros/launch/px4.launch

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
<launch>
<!-- vim: set ft=xml noet : -->
<!-- example launch script for PX4 based FCU's -->

<arg name="fcu_url" default="/dev/ttyACM0:57600" />
<arg name="gcs_url" default="" />
<arg name="tgt_system" default="1" />
<arg name="tgt_component" default="1" />
<arg name="log_output" default="screen" />
<arg name="fcu_protocol" default="v2.0" />
<arg name="respawn_mavros" default="false" />

<include file="$(find mavros)/launch/node.launch">
<arg name="pluginlists_yaml" value="$(find mavros)/launch/px4_pluginlists.yaml" />
<arg name="config_yaml" value="$(find mavros)/launch/px4_config.yaml" />

<arg name="fcu_url" value="$(arg fcu_url)" />
<arg name="gcs_url" value="$(arg gcs_url)" />
<arg name="tgt_system" value="$(arg tgt_system)" />
<arg name="tgt_component" value="$(arg tgt_component)" />
<arg name="log_output" value="$(arg log_output)" />
<arg name="fcu_protocol" value="$(arg fcu_protocol)" />
<arg name="respawn_mavros" default="$(arg respawn_mavros)" />
</include>
</launch>

然后定位到 node.launch

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
<launch>
<!-- vim: set ft=xml noet : -->
<!-- base node launch file-->

<arg name="fcu_url" />
<arg name="gcs_url" />
<arg name="tgt_system" />
<arg name="tgt_component" />
<arg name="pluginlists_yaml" />
<arg name="config_yaml" />
<arg name="log_output" default="screen" />
<arg name="fcu_protocol" default="v2.0" />
<arg name="respawn_mavros" default="false" />

<node pkg="mavros" type="mavros_node" name="mavros" required="$(eval not respawn_mavros)" clear_params="true" output="$(arg log_output)" respawn="$(arg respawn_mavros)">
<param name="fcu_url" value="$(arg fcu_url)" />
<param name="gcs_url" value="$(arg gcs_url)" />
<param name="target_system_id" value="$(arg tgt_system)" />
<param name="target_component_id" value="$(arg tgt_component)" />
<param name="fcu_protocol" value="$(arg fcu_protocol)" />

<!-- load blacklist, config -->
<rosparam command="load" file="$(arg pluginlists_yaml)" />
<rosparam command="load" file="$(arg config_yaml)" />
</node>
</launch>

可以看出node.launch是主节点,调用了配置文件 px4_config.yaml 和插件配置文件 px4_pluginlists.yaml。 px4_config文件主要是定义了发布和订阅的节点,有关distance sensor的部分如下:
px4_config

可以看出config 文件中定义了有关distance sensor的部分,但是直接运行mavros的显示信息以及rostopic list的结果如下,可以看出是没有发布distance sensor相关的topic的:
mavros_nodist
list_nodist

原因是px4_pluginlists文件中定义了调用的插件的黑白名单,内容如下:
px4_plug
因此可以看出distance sensor被添加到了黑名单中,将其注释掉:
plugin after

再次运行mavros,rostopic list结果如下:
mavros_dist1
list_dist1

可以看到config中定义的distance sensor都被发布出来了,此时,由于我们只使用到了tfmini,从QGround中看出其id为0,因此对config文件做如下修改,只保留tfmini的topic:
config_after
此时再次运行mavros,rostopic list结果为:
mavros_tf
mavros_list
同时我们对话题进行 echo:
tf echo

enjoy!

#

Comments

Your browser is out-of-date!

Update your browser to view this website correctly. Update my browser now

×