windows 11
pixhawk2.4.8
树莓派4B
QGroundControl 4.2.8
Mission Planner 1.3.80
ardupilot
ubuntu 20.04.2
ros noetic
(本人搭建所使用的软件硬件版本,仅供参考)
使用地面站软件(mission planner或QGC)烧录,可以在线安装,也支持离线安装
在windows 11使用apj后缀的固件(ardusub.apj),在mp上直接安装,根据提示即可,出错就反复安装
目前来说,ubuntu20会比较稳定,支持ros 1的版本noetic
操作系统当然得从官网下载啦
网上教程太多,略过
树莓派4B有40个引脚,其中的TXD,RXD是用于做串口通讯的,需要配置一下才能使用
在ubuntu系统中,使用命令可以找到名称为ttyAMA0的串口
ll /dev/
将ttyAMA0设置为硬件串口,参考大佬的教程
要出现
serial0 → ttyAMA0
serial1 → ttyS0
其中,ubuntu20安装raspi-config参考这
鱼香ros一键安装太香了
教程很多,这里使用二进制安装
sudo apt-get install ros-noetic-mavros ros-noetic-mavros-extras
官网推荐的GeographicLib依赖库安装由于网咯问题经常装不了,建议离线安装,从大佬的gitee上下载
将 geoids gravity magnetic 三个文件夹拷贝到 /usr/share/GeographicLib 文件夹下面
跳到mavros目录下
roscd mavros
启动mavros节点可以看到是否安装成功
roslanch mavros apm.launch
pixhawk上有多个串口,我使用telem 2 与树莓派通讯,为了避免 RTT too high for timesync的告警(波特率太低),需要设置串口固定波特率为921600
pixhawl与QGC进行usb连接,在设置里面把serial2 波特率改为921600
由于我使用的是ardusub固件,所以用apm.launch脚本启动节点
修改 /opt/ros/noetic/share/mavros/launch下的apm.launch文件
<arg name="fcu_url" default="/dev/ttyACM0:57600" />
把串口名称和波特率改为如下
<arg name="fcu_url" default="/dev/ttyAMA0:921600" />
需要sudo权限修改
pixhawk接telem 2和power口即可(测试需要)
telem 2的TX,RX,GND接出来
power口接电流计,电流计接电源单独供电(我使用pixhawk的usb口与树莓派相连时会断电重启,可能是电压不稳定,所以单独供电)
最后把telem 2的三根线与树莓派的引脚连接起来,参考大佬,建议使用杜邦线,我没有接5v,所以是3根线,树莓派和pixhawk都是单独供电
roslaunch mavros apm.launch
打印窗口可以看到窗口连接成功,初始化成功,监听到heartbeat,即可
使用命令可以查看到所有话题
rostopic list
/mavlink/from
/mavlink/gcs_ip
/mavlink/to
/mavros/adsb/send
/mavros/adsb/vehicle
/mavros/battery
/mavros/cam_imu_sync/cam_imu_stamp
/mavros/camera/image_captured
/mavros/cellular_status/status
/mavros/companion_process/status
/mavros/distance_sensor/rangefinder_pub
/mavros/distance_sensor/rangefinder_sub
/mavros/esc_info
/mavros/esc_status
/mavros/esc_telemetry
/mavros/estimator_status
/mavros/extended_state
/mavros/fake_gps/mocap/pose
/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/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/radio_status
/mavros/rallypoint/waypoints
/mavros/rangefinder/rangefinder
/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/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/wind_estimation
/move_base_simple/goal
查看话题信息
rostopic info 话题名称
查看话题发布频率
rostopic hz 话题名称
打印话题信息
rostopic echo 话题名称
rostopic echo /mavros/global_position/compass_hdg
rostopic echo /mavros/imu/data
如果打印没有输出,请参考大佬的做法
rosservice call /mavros/set_stream_rate 0 10 1
修改飞控的广播频率
安装依赖
sudo apt install ros-foxy-mavros ros-foxy-mavros-extras
再安装GeographicLib下的文件
ros2的launch文件应为py、xml、yaml文件,但是安装的launch文件(ros1运行使用的文件)
运行ros2 launch mavros apm.launch会报错"syntax error"
但是可以直接运行节点
ros2 run mavros mavros_node fcu_url:=/dev/ttyACM0:57600