环境描述:
MAVSDK C++
GAZEBO 9
树梅派计算机(假设IP地址:192.168.3.11)
笔记本计算机(假设IP地址:192.168.3.12)
1. 在PC或笔记本计算机的ubuntu linux机器上(假设:IP地址是192.168.3.12)安装PX4开发环境
参考px4官网文章:Building PX4 Software | PX4 User Guide
PC机或笔记本与树梅派之间用WIFI链接,如图:
2. 启动gazebo软件仿真(SITL)
在PX4安装目录PX4-Autopilot中,输入命令:
make px4_sitl gazebo
或者
make px4_sitl gazebo___baylands
注意:gazebo和baylands之间是3个下划线
3. 启动地面站(如果你不想看3D显示效果,这项可省略)
进入QGroundControl安装目录中,输入命令:
./QgroundControl.AppImage
4. 在ubuntu linux笔记本机器上(假设:IP地址是192.168.3.12)安装了mavlink-router
安装mavlink-router请参考官网文章:https://github.com/mavlink-router/mavlink-router
5. 在ubuntu linux笔记本机器上(假设:IP地址是192.168.3.12 )上启动mavlink-router
在mavlink-router目录中,输入命令:
./mavlink-routerd -e 192.168.3.11:14540 0.0.0.0:14540
或者
./mavlink-routerd -e 192.168.3.11:14540 127.0.0.1:14540
注:mavlink-router的作用是将192.168.3.12:14540与192.168.3.11:14540之间建立联系(udp信息的路由)
注:因为上述命令是采用命令行的方式指定地址,可能会出现“could not open config file..."这样的信息,忽略之。
6. 登录树梅派
在笔记本计算机端,执行命令
$>ssh xxxxxx@rpi,这里xxxxxx可改成你的宿主机的名字
提示:如何建立宿主机与树梅派之间的ssh连接(wifi),见后续文章
7. 编译MAVSDK的takeoff_and_land例子
$>cd MAVSDK & cd examples & cd takeoff_land
$>cmake -Bbuild -H.
$>cd build
$>make
提示:如何安装MAVSDK,见后续文章
8. 运行例子
$>cd MAVSDK & cd examples & cd takeoff_land/build
$>./takeoff_and_land udp://:14540