ubuntu18.04安装mavros并读取pixhawk飞控数据

该教程详细介绍了如何在ROS中源码安装mavros,并成功启动px4.launch。通过rosrun命令,可以将/mavros/imu/data_raw的频率提升至100Hz,调整参数能进一步提升频率。此外,还提供了增加飞控计算后IMU数据频率的方法。
摘要由CSDN通过智能技术生成

Mavros源码安装

最新mavros详细安装教程(亲测可行)

启动mavros

上述步骤完成后,启动px4.launch

roslaunch mavros px4.launch

此时rostopic list可以看到许多topic

提高IMU频率

首先启动

roslaunch mavros px4.launch

新开一个终端,输入

rosrun mavros mavcmd long 511 105 10000 0 0 0 0 0

/mavros/imu/data_raw 的频率被提高到了100Hz,如果想要提到更高的频率只需要减小10000这个参数,这个就是设置时间间隔的现在间隔为10000us所以是100hz。

对于飞控计算过后的IMU数据/mavros/imu/data类似的,不过命令不太一样。

rosrun mavros mavcmd long 511 31 10000 0 0 0 0 0
  • 1
    点赞
  • 9
    收藏
    觉得还不错? 一键收藏
  • 1
    评论
### 回答1: Ubuntu 18.04 安装 mavros 的步骤如下: 1. 安装 ROS: ``` sudo sh -c 'echo "deb http://packages.ros.org/ros/ubuntu $(lsb_release -sc) main" > /etc/apt/sources.list.d/ros-latest.list' sudo apt-key adv --keyserver 'hkp://keyserver.ubuntu.com:80' --recv-key C1CF6E31E6BADE8868B172B4F42ED6FBAB17C654 sudo apt update sudo apt install ros-melodic-desktop-full sudo rosdep init rosdep update echo "source /opt/ros/melodic/setup.bash" >> ~/.bashrc source ~/.bashrc ``` 2. 安装 MAVROS: ``` sudo apt install ros-melodic-mavros ros-melodic-mavros-extras ``` 3. 初始化 MAVROS: ``` sudo cp /usr/share/mavros/launch/mavros_empty_world.launch /etc/ros/melodic/ sudo chmod +x /etc/ros/melodic/mavros_empty_world.launch ``` 然后你就可以启动 mavros 了,试试运行 `roslaunch mavros mavros_empty_world.launch`。 ### 回答2: 在Ubuntu 18.04中安装mavros是一项重要的任务,因为它可以用来连接无人机和其他设备或计算机。它可以使用ROS(机器人操作系统)以及ROS版无人机(如Ardupilot)。 以下是在Ubuntu 18.04中安装mavros的步骤: 1.首先,您需要安装ROS,您可以按照官方的教程进行安装,可以用Desktop-Full版本或者桌面版本。http://wiki.ros.org/melodic/Installation/Ubuntu 2.确认您已经将ROS设置为您的环境变量。在每一次开启新的终端时需要执行: ```echo "source /opt/ros/melodic/setup.bash" >> ~/.bashrc``` ```source ~/.bashrc``` 3.接下来,在终端中运行以下命令以安装mavros: ```sudo apt-get install ros-melodic-mavros ros-melodic-mavros-extras``` 4.在终端中运行以下命令使mavros能够更好的工作: ```sudo apt-get install ros-melodic-libmavconn ros-melodic-lcm_ros``` 5.下一步,下载和编译mavros源代码。这可以通过以下命令完成: ``` sudo apt-get install python-catkin-tools mkdir -p ~/catkin_ws/src cd ~/catkin_ws/src git clone https://github.com/mavlink/mavros.git cd mavros git checkout tags/v0.29.2 #最新版本可能已经不是这个版本号了 cd .. rosdep install --from-paths mavros --ignore-src -y cd ~/catkin_ws catkin build ``` 这将会花费一些时间,编译时间与机器配置有很大关系。 6.在完成编译之后,请确保将以下内容添加到您的环境变量文件中(~/.bashrc): ```source ~/catkin_ws/devel/setup.bash``` 7.最后的步骤是在终端中启动mavros: ```export GAZEBO_MODEL_PATH=~/catkin_ws/src/mavros/mavros/extras/simulation/models``` ```roslaunch mavros px4.launch fcu_url:="/dev/ttyACM0:921600"``` 其中fcu_url参数根据您使用的飞控设备与机器配置可以有所不同。www.ros.org 上的其他教程也许可以帮助您选择正确的参数。 至此,您已经成功安装mavros并可以与无人机进行通讯。它是ROS生态系统中一个重要的组件,也是许多ROS版本无人机使用的必要条件。 ### 回答3: 在安装mavros之前,我们需要确保已经安装好ROS(Robot Operating System)和MAVLink。如果没有,可以通过下面的命令来安装: ```sh sudo apt-get install ros-melodic-desktop-full sudo apt-get install ros-melodic-mavlink ``` MAVROS是ROS的一个功能包,它允许我们通过ROS与无人机通信,并且可以使用ROS中的不同工具和库进行自主控制或高层规划。 以下是安装mavros的步骤: 1. 添加mavros的ROS软件源: ```sh sudo apt-get update sudo apt-get install ros-melodic-mavros ros-melodic-mavros-extras ``` 2. 安装依赖项: ```sh sudo apt-get install ros-melodic-control-toolbox ros-melodic-message-filters ros-melodic-cmake-modules qtbase5-dev libopencv-dev \ python3-pip python3-yaml python3-dev python3-numpy python3-setuptools libxml2-dev libzmq3-dev \ libeigen3-dev libgeographic-dev geographiclib-tools protobuf-compiler libgoogle-glog-dev ros-melodic-tf2-eigen \ ros-melodic-octomap-msgs ros-melodic-nodelet ros-melodic-octomap-ros ros-melodic-ddynamic-reconfigure \ ros-melodic-geodesy ros-melodic-pcl-ros ros-melodic-octomap-server ros-melodic-mavlink ``` 3. 安装MAVLink: ```sh sudo apt-get install python3-pip pip3 install pymavlink ``` 4. 编译Mavros: ```sh catkin build mavros ``` 这个步骤可能需要数分钟或数小时,具体取决于您的电脑性能。 5. 设置自启: ```sh echo "source ~/catkin_ws/devel/setup.bash" >> ~/.bashrc ``` 其中`catkin_ws`是您建立的ROS工作空间,可以更换成自己的路径。 6. 重启终端,以确保环境变量已更新。 7. 验证安装是否成功: ```sh rospack find mavros ``` 如果没有出错信息,则说明mavros安装成功。 至此,您已经成功安装了mavros,可以开始使用ROS与无人机进行通信和控制了。
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值