... logging to /home/.ros/log/6a1b2330-2eb3-11e9-a39c-9cb6d0e498fb/roslaunch-gishr-XPS-15-9560-4452.log
Checking log directory for disk usage. This may take awhile.
Press Ctrl-C to interrupt
Done checking log file disk usage. Usage is <1GB.
started roslaunch server http://XPS-15:44361/
ros_comm version 1.12.14
SUMMARY
========
PARAMETERS
* /rosdistro: kinetic
* /rosversion: 1.12.14
NODES
auto-starting new master
process[master]: started with pid [4463]
ROS_MASTER_URI=http://XPS-15:11311/
setting /run_id to 6a1b2330-2eb3-11e9-a39c-*********
process[rosout-1]: started with pid [4476]
started core service [/rosout
# Use your favorite editor, we will be using gedit
# NOTE: you will need to use ROOT to edit bashrc
sudo gedit ~/.bashrc
# 在bashrc中,拷贝以下内容到bashrc尾端
source ~/catkin_ws/devel/setup.bash # 如果通过第一种方式安装了MAVROS,忽略此步。
source ~/catkin_ws/src/Firmware/Tools/setup_gazebo.bash ~/catkin_ws/src/Firmware/ ~/catkin_ws/src/Firmware/build/posix_sitl_default
export ROS_PACKAGE_PATH=$ROS_PACKAGE_PATH:~/catkin_ws/src/Firmware
export ROS_PACKAGE_PATH=$ROS_PACKAGE_PATH:~/catkin_ws/src/Firmware/Tools/sitl_gazebo
# 如果你使用的是Docker
cd /root/gi/GAAS/demo/tutorial_1/1_px4_mavros_offboard_controller
python px4_mavros_run.py
# 如果你使用第一种安装方法
cd (GAAS_PATH)/demo/tutorial_1/1_px4_mavros_offboard_controller
python px4_mavros_run.py
你可以看到一个无人机逐渐起飞到3米高并悬停在此。在另外一个终端中:
python commander.py
你可以看到无人机按照下面的顺序飞行:
向右飞一米;
逆时针旋转90度;
降落。
或者你可以打开一个新的终端,使用提供的API来控制无人机:
# in folder '1_px4_mavros_offboard_controller'
python
# import packages
from commander import Commander
import time
# create Commander instance
con = Commander()
# control the drone to move 1 meter to the right
con.move(1,0,0)
# wait for 2 seconds
time.sleep(2)
# control the drone to move 1 meter to the front
con.move(0,1,0)
# wait for 2 seconds
time.sleep(2)
# control the drone to move 1 meter to the left
con.move(-1,0,0)
# wait for 2 seconds
time.sleep(2)
# control the drone to move 1 meter to the back
con.move(0,-1,0)
# wait for 2 seconds
time.sleep(2)
# control the drone to move 1 meter above
con.move(0,0,1)
# wait for 2 seconds
# land
con.land()