MAVROS2运行px4.launch文件终端mavros.odometry重复报错map和base_link_frd连接错误的解决方法
环境:
Ubuntu :20.04 LTS
ROS :ROS2 Foxy
PX4 :1.13.0
问题描述
在使用命令ros2 launch mavros px4.launch
命令启动MAVROS2与PX4之间的连接时,MAVROS2可以启动,但终端重复报错,这个重复报错好像不影响使用,报错信息如下。
[mavros_node-1] [ERROR] [1712544758.102953817] [mavros.odometry]: ODOM: Ex: Could not find a connection between 'map' and 'base_link_frd' because they are not part of the same tree.Tf has two or more unconnected trees.
解决方法
分析原因是可能与ros-foxy-mavros-extras软件包有关,卸载该包在一定程度上可以解决重复报错的问题
sudo apt-get purge ros-foxy-mavros-extras
如果没有效果的话也可以在mavros/mavros/launch文件夹中的px4_pluginlists.yaml文件中添加一行- odometry
禁用odometry模块,也可以解决重复报错的问题。
/**:
ros__parameters:
plugin_denylist:
# common
- odometry
# extras
- image_pub
- vibration
- distance_sensor
- rangefinder
- wheel_odometry
# plugin_allowlist:
# - 'sys_*'
安装并测试MAVROS2的方法
创建ROS2工作空间。
mkdir -p ~/mavros2_ws/src
cd ~/mavros2_ws
下载MAVLink和MAVROS2源码。
source /opt/ros/foxy/setup.bash
rosinstall_generator --format repos mavlink | tee /tmp/mavlink.repos
rosinstall_generator --format repos --upstream mavros | tee -a /tmp/mavros.repos
vcs import src < /tmp/mavlink.repos
vcs import src < /tmp/mavros.repos
rosdep install --from-paths src --ignore-src -y
安装依赖数据集。
sudo ./src/mavros/mavros/scripts/install_geographiclib_datasets.sh
从github官网下载MAVROS2的ros2分支的最新版本代码,替换mavros2_ws/src文件夹中的mavros文件夹。
编译工作空间。
source ~/mavros2_ws/install/setup.bash
colcon build
新建一个终端,测试MAVROS2能否正常启动。
source /opt/ros/foxy/setup.bash
source ~/mavros2_ws/install/setup.bash
ros2 launch mavros px4.launch
参考资料: