Jetson Orin NX 开发指南(9): MAVROS 的安装与配置

一、前言

由于 Jetson 系列开发板常作为自主无人机的机载电脑,而无人机硬件平台如 PX4 和 ArduPilot 等通过 MAVLink 进行发布无人机状态和位姿等信息,要实现机载电脑与 MAVLink 的通信,必须借助 Mavros 功能包,因此,本文主要介绍 Mavros 功能包的安装、配置与使用,主要参考

GitHub - mavlink/mavros at master

https://github.com/mavlink/mavros/blob/master/mavros/README.md#installation

Ubuntu 安装并配置 mavros (USB 连接)_ubuntu安装mavros-CSDN博客

官方给出了直接安装和源码安装两种方法,由于一般 mavros 安装并配置完成后不会轻易改动,且十分常用,因此比较推荐直接安装方法,本文也只介绍直接安装方法

二、Mavros 的安装

由于 Jetson Orin NX 的 JetPack 5.1.2 对应的是 Ubuntu 20.04,因此我们选择安装 noetic 版本的 mavros 功能包,终端输入

sudo apt-get install ros-noetic-mavros ros-noetic-mavros-extras -y

此时可以查看 /usr/share/ 下多了一个 GeographicLib 文件夹,其内容是空的,需要我们自己添加进去

进入 ~/Documents/ 目录,下载脚本文件

wget https://raw.githubusercontent.com/mavlink/mavros/master/mavros/scripts/install_geographiclib_datasets.sh

然后给下载好的脚本文件添加可执行权限,

sudo chmod +x ./install_geographiclib_datasets.sh

运行该脚本下载所需文件

sudo ./install_geographiclib_datasets.sh

如果执行报错,就直接去GeographicLib 官网下载(可能要挂梯子。。。)对应的三个包,下载得到三个文件夹:

1.GeographicLib geoids egm96-5 官网下载链接:

Download egm96-5.tar.bz2 (GeographicLib)

2.GeographicLib gravity egm 96官网下载链接

Download egm96.zip (GeographicLib)

3.GeographicLib magnetic emm2015 官网下载链接:

Download emm2015.zip (GeographicLib)

在 /usr/share/GeographicLib/ 路径下,将上面下载的三个压缩包解压后放在这个文件夹内,如下所示

至此,mavros 就安装成功了!

三、Mavrso 的运行

由于 Jetson Orin NX 与飞控(飞行控制器)一般有两种通信连接方式,一种是通过 USB 连接,另一种是通过串口连接,本节主要介绍 USB 连接方式使得 Jetson Orin NX 通过 Mavros 实现与飞控的通信。

由于时下最新的 Pixhawk 系列飞控为 Pixhawk 6X,因此本文主要介绍 Jetson Orin NX 与 Pixhawk 6X 的通信,其他电脑与飞控的通信方式也是相同的!

运行 Mavros 之前需要现修改 launch 启动文件

打开 /opt/ros/noetic/share/mavros/launch/ 路径下的 px4.launch 文件

Jetson Orin NX 开发指南(9): MAVROS 的安装与配置_第1张图片

可以看到 fcu_url 默认为 /dev/ttyACM0:57600,其中 ttyACM0 表示 USB 连接,57600 表示波特率,这里我们不对这个文件进行修改,而是在当前目录下新建一个 px4_ACM0.launch 文件

终端输入

cd /opt/ros/noetic/share/mavros/launch/
sudo touch px4_ACM0.launch

打开 px4_ACM0.launch 文件,

sudo gedit px4_ACM0.launch

将其内容改为


	
	

	
	
	
	
	
	
	

	
		
		

		
		
		
		
		
		
		
	

至此,Mavros 的启动文件就配置完成了!

接下来将 Jetson Orin NX 与 Pixhawk 6X 通过 USB 连接,如下图所示

Jetson Orin NX 开发指南(9): MAVROS 的安装与配置_第2张图片

然后终端输入

roslaunch mavros px4_ACM0.launch

启动 mavros,发现报错

[FATAL] [1697177878.518260611]: FCU: DeviceError:serial:open: Permission denied

原因是 /dev/ttyACM0 没有可执行权限,需要先添加可执行权限,终端输入

sudo chmod 777 /dev/ttyACM0

然后再次启动 mavros

roslaunch mavros px4_ACM0.launch

结果显示

Jetson Orin NX 开发指南(9): MAVROS 的安装与配置_第3张图片

这表示 mavros 成功连接上了飞控!

此时可以查看 mavros 话题,终端输入

rostopic list

打印输出

/diagnostics
/mavlink/from
/mavlink/gcs_ip
/mavlink/to
/mavros/actuator_control
/mavros/adsb/send
/mavros/adsb/vehicle
/mavros/altitude
/mavros/battery
/mavros/cam_imu_sync/cam_imu_stamp
/mavros/camera/image_captured
/mavros/cellular_status/status
/mavros/companion_process/status
/mavros/debug_value/debug
/mavros/debug_value/debug_float_array
/mavros/debug_value/debug_vector
/mavros/debug_value/named_value_float
/mavros/debug_value/named_value_int
/mavros/debug_value/send
/mavros/esc_info
/mavros/esc_status
/mavros/esc_telemetry
/mavros/estimator_status
/mavros/extended_state
/mavros/fake_gps/mocap/tf
/mavros/geofence/waypoints
/mavros/global_position/compass_hdg
/mavros/global_position/global
/mavros/global_position/gp_lp_offset
/mavros/global_position/gp_origin
/mavros/global_position/local
/mavros/global_position/raw/fix
/mavros/global_position/raw/gps_vel
/mavros/global_position/raw/satellites
/mavros/global_position/rel_alt
/mavros/global_position/set_gp_origin
/mavros/gps_input/gps_input
/mavros/gps_rtk/rtk_baseline
/mavros/gps_rtk/send_rtcm
/mavros/gpsstatus/gps1/raw
/mavros/gpsstatus/gps1/rtk
/mavros/gpsstatus/gps2/raw
/mavros/gpsstatus/gps2/rtk
/mavros/hil/actuator_controls
/mavros/hil/controls
/mavros/hil/gps
/mavros/hil/imu_ned
/mavros/hil/optical_flow
/mavros/hil/rc_inputs
/mavros/hil/state
/mavros/home_position/home
/mavros/home_position/set
/mavros/imu/data
/mavros/imu/data_raw
/mavros/imu/diff_pressure
/mavros/imu/mag
/mavros/imu/static_pressure
/mavros/imu/temperature_baro
/mavros/imu/temperature_imu
/mavros/landing_target/lt_marker
/mavros/landing_target/pose
/mavros/landing_target/pose_in
/mavros/local_position/accel
/mavros/local_position/odom
/mavros/local_position/pose
/mavros/local_position/pose_cov
/mavros/local_position/velocity_body
/mavros/local_position/velocity_body_cov
/mavros/local_position/velocity_local
/mavros/log_transfer/raw/log_data
/mavros/log_transfer/raw/log_entry
/mavros/mag_calibration/report
/mavros/mag_calibration/status
/mavros/manual_control/control
/mavros/manual_control/send
/mavros/mission/reached
/mavros/mission/waypoints
/mavros/mocap/pose
/mavros/mount_control/command
/mavros/mount_control/orientation
/mavros/mount_control/status
/mavros/nav_controller_output
/mavros/obstacle/send
/mavros/odometry/in
/mavros/odometry/out
/mavros/onboard_computer/status
/mavros/param/param_value
/mavros/play_tune
/mavros/px4flow/ground_distance
/mavros/px4flow/raw/optical_flow_rad
/mavros/px4flow/raw/send
/mavros/px4flow/temperature
/mavros/radio_status
/mavros/rallypoint/waypoints
/mavros/rc/in
/mavros/rc/out
/mavros/rc/override
/mavros/setpoint_accel/accel
/mavros/setpoint_attitude/cmd_vel
/mavros/setpoint_attitude/thrust
/mavros/setpoint_position/global
/mavros/setpoint_position/global_to_local
/mavros/setpoint_position/local
/mavros/setpoint_raw/attitude
/mavros/setpoint_raw/global
/mavros/setpoint_raw/local
/mavros/setpoint_raw/target_attitude
/mavros/setpoint_raw/target_global
/mavros/setpoint_raw/target_local
/mavros/setpoint_trajectory/desired
/mavros/setpoint_trajectory/local
/mavros/setpoint_velocity/cmd_vel
/mavros/setpoint_velocity/cmd_vel_unstamped
/mavros/state
/mavros/statustext/recv
/mavros/statustext/send
/mavros/target_actuator_control
/mavros/terrain/report
/mavros/time_reference
/mavros/timesync_status
/mavros/trajectory/desired
/mavros/trajectory/generated
/mavros/trajectory/path
/mavros/tunnel/in
/mavros/tunnel/out
/mavros/vfr_hud
/mavros/vision_pose/pose
/mavros/vision_pose/pose_cov
/mavros/vision_speed/speed_twist_cov
/mavros/wind_estimation
/move_base_simple/goal
/rosout
/rosout_agg
/tf
/tf_static

可以查看 IMU 频率,终端输入

rostopic hz /mavros/imu/data

结果显示

Jetson Orin NX 开发指南(9): MAVROS 的安装与配置_第4张图片

此时 IMU 话题频率为 200 左右,至此 Mavros 就安装完成了!

你可能感兴趣的:(Jetson,Orin,NX,ROS,Mavros,PX4)