Introduction of PX4
Presenter: SungTae Moon
안녕하세요.
저는 한국항공우주연구원 문성태 연구원입니다..
안녕하세요.
저는 한국항공우주연구원 문성태 연구원입니다..
Computer Science
Programming
Open Source
Aerospace Engineering
안녕하세요.
저는 한국항공우주연구원 문성태 연구원입니다..
그래서 사실은..
항공우주에 대해 잘 모릅니다.
(죄송합니다..)
오픈소스 PX4
IT 입장에서
그래서, 오늘은
에 대해 이야기 해볼까 합니다.
Introduction of PX4
Presenter: SungTae Moon
2021.02.26
TABLE OF
CONTENTS
Introduction
01
02
03
04
05
History of PX4
Overall Architecture
Practical Example
Future of PX4
Introduction
01
왜 PX4를 사용했는가
실내 군집 비행 시스템
AR.Drone
Swarm System based on Image
Limitation of Image System
Limitation of Image System
Swarm System based on Motion Capture
Limitation of private code
- The AR.Drone uses ultrasound data to measure its altitude
- However, when multiple quadrotors run in same area, the frequency interference happens because of
collision of same frequency
Limitation of private code
History of PX4
02
문제는 시스템
PX4
- Co-Founder of Auterion
- Ph.D. on drone software architecture from ETH Zurich
PX4
History
2020
Pixhawk
Industry Standard
Key Maintainers (Early Members)
Loren Meier Julian Oes
Paul Reiseborough
[EKF2]
James Goppert
[LPE]
Architecture
Control &
Estimation
Anton Babuskin
[position_estimation_inav]
[attitude_estimator_q]
[mc_att_control]
[mc_pos_control]
Contributors
DroneCode
- Setthe standards in the drone industry with open-source
- Start with PX4 and ArduPilot (2014)
- ArduPilot was no longer be associated with DroneCode (2016)
DroneCode
DroneCode Membership
2014 2020
# 오픈소스란 무엇인가
오픈소스란
- 오픈 소스는 소프트웨어 혹은 하드웨어 제작자의 권리를 지키면서
원시 코드를 누구나 열람할 수 있도록 한 소프트웨어 혹은 오픈 소스 라이선
스에 준하는 모든 통칭을 일컫는다.
오픈 소스(open source/OSS) – 위키백과
왜 사람들은 소스코드를 공개하기 시작했을까?
History (~1970)
- 하드웨어 판매 중심
- 소프트웨어는 공짜!
Dennis Ritchie (1941 ~ 2011)
History (1976)
컴퓨터 애호가들에게 보내는 공개 편지 “Open Letter to Hobbyists”
모든 코드를 비공개 형태로 만들어 버리게 되는 계기
소프트웨어 저작권에 대한 인지, 시작된 상업용 소프트웨어 시대
History (1980)
- 자유 소프트웨어 운동 주도
- 상용 소프트웨어에 대항한 자유로운 대안을 만들기 위한 의지
- GNU (GNU is Not a Unix) 프로젝트 시작
- Text editor(Emacs), Compiler(gcc), Debugger(gdb), make 개발
- Free Software 운동 시작 후 자유소프트웨어 재단(FSF) 설립
- 1989년 최초의 오픈소스 라이선스 GNU General Public License 배포
Richard Stallman (1953 ~)
라이센스
- GPL : General Public License. 저작권은 개발자에게 귀속되지만 소프트웨어의 복사, 수정 및 변경, 배포의 자유를 제3자에게 허용.
- LGPL : GNU Lesser General Public License. GPL을 변형해 더 허가된 형태로서, 소프트웨어 라이브러리를 염두에 둔 것.
- MPL : 모질라 공용 허가서(Mozilla Public License). 모질라 애플리케이션 스위트, 모질라 파이어폭스, 모질라 선더버드 및 그 외의 모질라 소프트웨어
들에 적용.
- BSD license : 유닉스(Unix) 의 양대 뿌리 중 하나인 버클리의 캘리포니아 대학에서 배포하는 공개 소프트웨어의 라이선스. GPL보다 훨씬 개방적인 4
개항의 간단한 문구로 되어 있음.
- Apache license : 아파치 소프트웨어 재단에서 자체적으로 만든 소프트웨어에 대한 라이선스 규정. 누구나 해당 소프트웨어에서 파생된 프로그램을
제작할 수 있으며 저작권을 양도, 전송할 수 있는 라이선스 규정을 의미.
History (1991)
Linux GNU
- 핀란드 헬싱키 대학의 대학원생인, 리누스 토발즈가 취미로 개발한 커널
 리눅스의 탄생
- GNU GPL로 배포
…
Debian
Redhat
CentOS Ubuntu Linus Torvalds (1969 ~)
- 오픈소스 명칭 정의
- 넷스케이프 브라우저 코드에 대한 공개 형태를 결정하는 전략회의에서 붙여진 용어
- 넷스케이스 소스 코드 공개에 자극 받아, 오픈소스를 장려하기 위한 단체인 OSI(Open Source
Initiative) 설립
History (1998)
History (Current)
History (Current)
# 왜 소스를 오픈하는가
Why do you open your code?
48



*) 김형준, “오픈소스 프로젝트 따라 잡기”, SlideShare
 하지만, 기술 공유 보다는 기술 종속이 목적이 아닐까?
Android
Eco-System
Tizen
Eco-System
 좋은 회사에 취직/연봉인상 이 목적이 아닐까?
Overall Architecture
03
Architecture
APM/ArduPilot
Jordi Munoz
(2009)
Andrew Tridgell
(2011)
Architecture (ArduPilot)
Architecture
uORB
uORB
uORB
IMU
Sensors
Attitude
Estimator
Gyro,Accel,Mag
Roll,Pitch,Yaw
Subscribe
Publish
Example of topics (v1.8.2)
Position
Control
Attitude
Control
Position
Estimate
Attitude
Estimate
# 어떻게 공헌할까?
How to become contributor
Fork
코드 수정
Pull Request
검토 by
Travis CI
검토 by
committer
Project
Issue
발견/등록
Commit
Your code
Field Test
Testing in the lab (CI) (@PX4)
Testing in the field (@ DroneCode)
How to become contributor
How to become contributor
Practical Example
04
# 어떻게 설치할까
Download
- Download​
- Git clone https://github.com/PX4/PX4-Autopilot.git
- Git submodule update –init –recurisve
- Compile​
- make px4_fmu-v3_default​
Compile
- Compile​
- make px4_fmu-v3_default​
$ make px4_fmu-v3_default
board_model_label
- 동작 방식
- CMake를 통해 관리됨 (CMakeLists.txt)
Compile
Development Environment


그래서 왔습니다.!
Docker





Program #1
(using Library V1)
Program #2
(using Library V2)
Error
V1 V2
Docke



Install Docker
refer to https://dev.px4.io/v1.9.0/en/test_and_ci/docker.html
PX4 Docker List
How to use
docker pull [docker repository]


./Tools/docker_run.sh bash
Run docker
Demonstration
My computer (ubuntu)
Docker container
Source
Code
PX4
SITL
# 개발 환경은?
Linux





vscode
# 코드를 보자
Directory
Directory (ROMFS)
rcS (PX4-Autopilot/ROMFS/px4fmu_common/init.d/rcS)
- Run configuration script (rcS)
- Mounting file system
- Load parameters
- Run default tasks
- Run specific airframe tasks
- Ex. “4011_dji_f450”, “4052_holybro_qav250”
Ex1. 나만의 기체 모델 설정 파일을 만들고 싶다
Ex2. 자동 실행되는 task를 만들고 싶다
# 나만의 모듈을 개발해보자
Template Code
- replace the module name (Tip: use refactoring function of IDE tool)
CMakeLists.txt
- Checkpoint: cmake/px4_add_module.cmake
template_module.h(pp)
- checkpoint: platforms/common/include/px4_platform_common/module.
template_module.cpp
Method : instantiate
Method : run
Run for Test
$ make px4_sitl_default gazebo
- Run for Test
- Tip #1: HEADLESS=1 (for no gazebo client)
- Tip #2: pxh> help (to show possible commands)
- Tip #3: pxh> task_lists (to show tasks)
pxh> monitoring start
# 나만의 Topic을 만들어보자
msg
- checkpoint #1: ./msg
- checkpoint #2: ./msg/tools/px_generate_uorb_topic_helper.py
- checkpoint #3: build/px4_sitl_default/uORB/topics/sensor_combined.h
msg
user-defined topic
- should insert user-defined topic to msg/CMakeLists.txt
publish
- In monitoring.hpp
- In monitoring.cpp
show monitoring msg
- Tip #1: pxh> listener monitoring
# 나만의 파라미터를 만들어보자
Parameters
- PX4 uses the param subsystem
- a flat table of float and int32_t values
- PARAM_DEFINE_INT32
- PARAM_DEFINE_FLOAT
- Parameter names must be no more than 16 ASCII characters
Example of Parameter
- Parameter Definition (in case of C language)
Codes for Parameter
- monitoring_params.c
- monitoring.hpp
- monitoring.cpp
Test Result
# MavLink를 통해 GCS로..
외부와 통신은 어떻게?
비행제어컴퓨터
(Flight ControlComputer)
FCC
지상국 시스템
(Ground ControlSystem)
FHSS (Frequency Hopping Spread Spectrum)
2.4 GHz
WiFi, Zigbee, LTE, ..
2.4 Ghz, 5 GHz, …
임무 컴퓨터
(Mission Computer)
MC
MAVLink
“MAVLink is a very lightweight, header-only message
marshalling library for micro air vehicles.”
Target
FCC (Flight Control Computer)
mavlink
mavlink
monitoring Receiver
Custom MAVLink
- Get and fork mavlink from https://github.com/mavlink/mavlink.git
- Run “mavgenerate.py”
- define curstom mavlink protocol
Create custom mavlink message
- custom ID : 180 ~229 <= Space for custom messages in individual projectname_messages.xml files
Update submodule for mavlink
- Change url for custom mavlink
- git submoulde sync
- git submodule update --remote --merge mavlink/include/mavlink/v2.0
Code for the custom message
- in src/modules/mavlink/mavlink_messages.cpp
Code for the custom message
- in src/modules/mavlink/mavlink_messages.cpp
Code for the custom message
- in ROMFS/px4fmu_common/init.d-posix/rcS
# 나만의 GCS를 만들어보자
SITL simulation environment
How to get the example code
- get the example code from https://github.com/mavlink/mavlink.git
Result
# 나만의 시스템으로 설정하고 싶다
Project (Tag)
- Tag
$ make px4_sitl_default gazebo
$ make px4_sitl_kari gazebo
- Tip #1: 가능한 오픈소스 구조를 바꾸지 말자
# 데이터 분석은?
일단 날리고 보자
처음 날려보니..
- 처음 날려보니, 잘 안된다.
- 당연하다
- 메뉴얼 비행  자동 비행
- 로그 분석!!
Logger 동작 방법
Module#1
Module#2
Module#n
…
Logger
publish
publish
publish
subscribe
Logger 동작 방법
Module#1
Module#2
Module#n
…
Logger
publish
publish
publish
subscribe
New
Module
add_topic("TOPIC NAME");
- 새로운 모듈 topic을 추가한다면?
ULog
https://dev.px4.io/master/en/log/ulog_file_format.html
Flight Log AnalyzerTool
<정상적인 경우>
<비정상적인 경우>
Case #1
Flight Plot








지자기 센서 로그를 확인해 보니
- 지자기 센서의 기울기에 대해서는 고려가 되지 않았다!!
if (_ext_hdg_mode == 0 || !_ext_hdg_good) {
// Magnetometer correction
// Project mag field vector to global frame and extract XY component
Vector<3> mag_earth = _q.conjugate(_mag);
float mag_err = _wrap_pi(atan2f(mag_earth(1), mag_earth(0)) - _mag_decl);
// Project magnetometer correction to body frame
corr += _q.conjugate_inversed(Vector<3>(0.0f, 0.0f, -mag_err)) * _w_mag;
}
원인 분석
해결
하지만,





Case #2
PX4Tool





PX4Tool

PX4Tool

PX4Tool

PX4Tool

Future of PX4
05
Roadmap (2013)
PX4-ROS
Roadmap (2019)
PX4-ROS(2)
- PX4 supports native communication with ROS2 via FastRTPS.
- This enables integration of a companion computer using industry-standard middleware with safety-critical
implementations available. ROS nodes can communicate today natively with PX4 without the need for a
translation layer like MAVROS.
ROS1 vs ROS2
PX4-ROS2
Refer to PX4DevSummit
PX4-ROS2
• Real Time Publish Subscribe protocol, a Data Distribution Service (DDS) protocol for computer systems
• eprosima Fast RTPS is a C++ implementation of the RTPS (Real Time Publish Subscribe) protocol
• provides publisher-subscriber communications over unreliable transports such as UDP, as defined and maintained
by the Object Management Group (OMG) consortium
Refer to PX4DevSummit
DDS
DDS uses the concept of Global Data Space. In this Space we define topics of data, and the publishers publish samples of
these topics. DDS distributes these samples to all the subscribers of those topics. Any node can be a publisher or a
subscriber.
Refer to PX4DevSummit
Fast DDS: Default Middleware for ROS2
Refer to PX4DevSummit
Why bring DDS to PX4
Refer to PX4DevSummit
Problem with PX4-ROS2
- System Maturity
- Dependency of eProsima RTPS
- Most code is developed by eProsima RTPS
- However, eProsima RTPS is not enough to apply to commercial system
PX4 Standard H/W
Refer to https://px4.io/autopilots/
FMUv5X
- Targeting industrial applications: Compact build size, hardened electronics, industrial buses (Ethernet and CAN)
- Retains backwards-compatibility (PWM and I2C)
- Provides standardized Autopilot-on-Module architecture (AoM)
SkyNode
- Combining the latest Pixhawk flight controller (FMUv5x standard), mission computer, and wireless
networking (LTE, WiFi)
- Pre-installed with the Auterion Enterprise PX4 operating system (not open source)
THANKS

오픈소스 기반 비행제어컴퓨터 PX4 소개