Table of Contents
1 Mavlink Control
Companion(Onboard) PC와 FC연결. TELE2 사용
1.1 Mavlink Utils
고마워 mavproxy, 그런데 너는 Ardupilot 만… 되냐.
- pymavlink
- mavproxy
- dronekit
- mavros
pip install mavproxy
dronekit 최신버전으로 설치dronekit-install
git clone https://github.com/dronekit/dronekit-python.git (dronekit-install) cd ./dronekit-python sudo python setup.py build sudo python setup.py install
1.1.1 mavproxy
mavlink proxy server, collection of groundcontrol utility
relay 433mhz telemetry to local udp 14540 and udp:14560
python /usr/local/bin/mavproxy.py --master=/dev/ttyUSB0 --baudrate 57600 --out udp:127.0.0.1:14540 --out udp:127.0.0.1:14560
listen 14550 port, relay to 14540 14560
python /usr/local/bin/mavproxy.py --master=:14550 --out udp:127.0.0.1:14540 --out udp:127.0.0.1:14560
1.2 Mavlink Control Examples
비행 테스트는 시뮬레이터에서! 결과 확인은 QGroundControl에서!
- C code Mavlink UDP Server: Fake FCU https://gist.github.com/donghee/0aacac96f04cc6d56eb34e1ed837ebdf Mavlink UDP Client: Set RTL Mode https://gist.github.com/donghee/e8cea7c4117cb9b25009371d94d65fff
- Pymavlink
- Change flight mode
- Set param value
- Receive mavlink messages https://gist.github.com/donghee/07ca13d9064a5c19863f275f42d8edc3
- 해보기:
MAV_CMD_DO_SET_MODE
실행 후COMMAND_ACK
메시지 받기.
- Dronekit and Dronekit Onboard
simplemission https://gist.github.com/donghee/a41121eaa78e5a6e51462ade507dc9d7
takeoff_and_land
- QGroundControl Onboard mavproxy or mavros
- QGroundControl Dronekit Gazebo mavproxy with dronekit or mavros with dronekit
2 Odroid에 mavros offboard mode
$ sudo sh -c 'echo "deb http://packages.ros.org/ros/ubuntu `lsb_release -sc` main" > /etc/apt/sources.list.d/ros-latest.list' $ wget http://packages.ros.org/ros.key -O - | sudo apt-key add - $ sudo apt-get update -y $ sudo apt-get install upgrade -y $ sudo apt-get install ros-kinetic-mavros ros-kinetic-mavros-extras $ sudo apt-get install python-wstool python-rosinstall-generator python-catkin-tools $ mkdir -p ~/catkin_ws/src $ cd ~/catkin_ws $ catkin init $ wstool init ~/catkin_ws/src # 1. get source (upstream - released) $ rosinstall_generator --upstream mavros | tee /tmp/mavros.rosinstall # alternative: latest source $ rosinstall_generator --upstream-development mavros | tee /tmp/mavros.rosinstall # 2. get latest released mavlink package # you may run from this line to update ros-*-mavlink package $ rosinstall_generator mavlink | tee -a /tmp/mavros.rosinstall # 3. Setup workspace & install deps $ wstool merge -t src /tmp/mavros.rosinstall $ wstool update -t src #$ rosdep install --from-paths src --ignore-src --rosdistro indigo -y $ rosdep install --from-paths src --ignore-src --rosdistro kinetic -y --os=ubuntu:xenial $ sudo apt-get install python-future # finally - build $ catkin build
3 Gazebo로 mavros offboard mode
3.1 설치
…
3.2 실행
roscore 실행 (서버)
$ cd catkin_ws; source devel/setup.bash
$ roscore
modudculab_ros
패키지의 pub_setpoints
노드 실행
ctrl_pos_gazebo.launch
파일 수정 필요.
$ cd catkin_ws; source devel/setup.bash
$ cd ~/catkin_ws/src
$ git clone https://github.com/Jaeyoung-Lim/modudculab_ros.git
$ catkin build modudculab_ros
$ roslaunch modudculab_ros ctrl_pos_gazebo.launch
SITL Gazebo 실행
$ mkdir src; cd src
$ git clone https://github.com/PX4/Firmware.git
$ cd Firmware
$ git submodule update --init --recursive
$ make posix_sitl_default gazebo
mavros노드에 명령어 내리기
$ cd catkin_ws; source devel/setup.bash
$ rosrun mavros mavsys mode -c OFFBOARD
$ rosrun mavros mavsafety arm
$ rosrun mavros mavsys mode -c AUTO.RTL
$ rosrun mavros mavsetp local -p 1 0 0 0
rosrun mavros mavros_node _fcu_url:="udp://:14540@192.168.1.3:14557"
rosrun mavros mavcmd takeoffcur 0 0 2
https://github.com/mavlink/mavros/blob/master/mavros/scripts/mavcmd
해보기
- odroid에서
pub_setpoints
노드를 PC(노트북)의 Gazebo와 연결하기 - odroid에서
pub_setpoints
노드를 FCU(ttyUSB0:921600)와 연결하기
참고
4 Offboard mode: pymavros
4.1 mavros node 실행
# gazebo rosrun mavros mavros_node _fcu_url:="udp://:14540@192.168.1.3:14557" # qgroundcontrol rosrun mavros gcs_bridge _gcs_url:='udp://@192.168.1.3'
4.2 SITL Gazebo 실행
$ make posix_sitl_default gazebo
4.3 Setpoint_Position
(MAVROS PYTHON)
다음 코드를 odroid에서 실행.
<script src="https://gist.github.com/donghee/7367afb515a6f761cc18c38313a548ff.js"></script>
4.4 참고
- https://github.com/mikeclement/autopilot_bridge
- mavlink jupyter notebook http://localhost:8888/notebooks/mavlink.ipynb