This folder contains some python scripts for controlling px4 in offboard mode in Gazebo simulation environment. It assumes you have properly installed mavros, gazebo7 and compiled px4 firmware detailed in the github front page.
To run the scripts:
roslaunch mavros px4.launch fcu_url:="udp://:[email protected]:14557"
cd ~/px4/Firmware
make posix_sitl_default gazebo
In this step, gazebo window will pop out and you will see a drone centered in the world origin. In another terminal, type:
rostopic echo /mavros/state
you should see "connected"
cd 1_px4_mavros_offboard_controller
python px4_python_mavros_mainloop.py
now you should see the drone gradually takes off to a predefined height.
use functions defined in commander.py to controll the drone. Or:
cd 1_px4_mavros_offboard_controller
python commander.py
you can use :
rostopic echo /mavros/state
to check the connection between PX4 and mavros.
此文件夹内包含一些基于 Python 以及 Gazebo 的脚本, 脚本可以用来控制基于 PX4 的无人机在 Offboard 模式下进行指点飞行。使用脚本需要你安装了 mavros, Gazebo7 并且编译了 PX4。
如果想使用脚本:
roslaunch mavros px4.launch fcu_url:="udp://:[email protected]:14557"
cd ~/px4/Firmware
make posix_sitl_default gazebo
Gazebo 窗口会弹出, 并且你会看到无人机在世界坐标系中心,在另外一个终端, 使用:
rostopic echo /mavros/state
你应该看到 「连接」字样。
cd 1_px4_mavros_offboard_controller
python px4_python_mavros_mainloop.py
此时你应该看到无人机逐渐起飞到预设高度
使用 commander.py 中的 api 来控制无人机。
你可以使用:
rostopic echo /mavros/state
来判断 mavros 以及 PX4 的连接状态, 请确保显示结果为 "connected"。