1. 개요
2. 개발환경
- Ubuntu 22.04
- PX4-Autopilot v1.16.0(Firmware )
- MAVSDK python 3.6.0
3. 설치
1) PX4
cd
git clone https://github.com/PX4/PX4-Autopilot.git --recursive
bash ./PX4-Autopilot/Tools/setup/ubuntu.sh
2) Gazebo
sudo wget https://packages.osrfoundation.org/gazebo.gpg -O /usr/share/keyrings/pkgs-osrf-archive-keyring.gpg
echo "deb [arch=$(dpkg --print-architecture) signed-by=/usr/share/keyrings/pkgs-osrf-archive-keyring.gpg] http://packages.osrfoundation.org/gazebo/ubuntu-stable $(lsb_release -cs) main" | sudo tee /etc/apt/sources.list.d/gazebo-stable.list > /dev/null
sudo apt-get update
sudo apt-get install gz-garden
3) MAVSDK python
#MAVSDK-Python Git 저장소 복제
cd ~
git clone https://github.com/mavlink/MAVSDK-Python --recursive
cd MAVSDK-Python
#필수 구성 요소 설치
cd proto/pb_plugins
pip3 install -r requirements.txt
cd ../..
pip3 install -r requirements.txt -r requirements-dev.txt
#코드 생성
./other/tools/run_protoc.sh
#Jetson이나 Raspberry Pi 같은 ARM 임베디드 컴퓨터인 경우 아래 환경변수 설정
#<ARM embedded architecture> : armv6l, armv7l및 aarch64. 32bit OS는 armv7l, 64비트 배포판을 사용하는 경우는 aarch64 입니다.
export MAVSDK_SERVER_ARCH=aarch64 #일반 PC는 안해도 됨
python3 setup.py build
pip3 install -e .
#MAVSDK-Python 설치 확인
pip3 show mavsdk
3. 실행
1) PX4
cd ~/PX4-Autopilot
make px4_sitl gz_x500
wift@swift:~/workspace/PX4-Autopilot$ make px4_sitl gz_x500
[0/1] cd /home/swift/workspace/PX4-Aut...topilot/build/px4_sitl_default/bin/px4
______ __ __ ___
| ___ \ \ \ / / / |
| |_/ / \ V / / /| |
| __/ / \ / /_| |
| | / /^\ \ \___ |
\_| \/ \/ |_/
px4 starting.
INFO [px4] startup script: /bin/sh etc/init.d-posix/rcS 0
INFO [init] found model autostart file as SYS_AUTOSTART=4001
INFO [param] selected parameter default file parameters.bson
INFO [param] importing from 'parameters.bson'
INFO [parameters] BSON document size 354 bytes, decoded 354 bytes (INT32:15, FLOAT:3)
INFO [param] selected parameter backup file parameters_backup.bson
INFO [dataman] data manager file './dataman' size is 1208528 bytes
INFO [init] Gazebo simulator 8.9.0
INFO [init] Starting gazebo with world: /home/swift/workspace/PX4-Autopilot/Tools/simulation/gz/worlds/default.sdf
INFO [init] Starting gz gui
INFO [init] Waiting for Gazebo world...
INFO [init] Gazebo world is ready
INFO [init] Spawning Gazebo model
INFO [gz_bridge] world: default, model: x500_0
INFO [lockstep_scheduler] setting initial absolute time to 4024000 us
INFO [commander] LED: open /dev/led0 failed (22)
WARN [health_and_arming_checks] Preflight Fail: ekf2 missing data
WARN [health_and_arming_checks] Preflight Fail: system power unavailable
WARN [health_and_arming_checks] Preflight Fail: No connection to the ground control station
INFO [uxrce_dds_client] init UDP agent IP:127.0.0.1, port:8888
INFO [tone_alarm] home set
INFO [mavlink] mode: Normal, data rate: 4000000 B/s on udp port 18570 remote port 14550
INFO [mavlink] mode: Onboard, data rate: 4000000 B/s on udp port 14580 remote port 14540
INFO [mavlink] mode: Onboard, data rate: 4000 B/s on udp port 14280 remote port 14030
INFO [mavlink] mode: Gimbal, data rate: 400000 B/s on udp port 13030 remote port 13280
INFO [logger] logger started (mode=all)
INFO [logger] Start file log (type: full)
INFO [logger] [logger] ./log/2025-07-12/01_21_29.ulg
INFO [logger] Opened full log file: ./log/2025-07-12/01_21_29.ulg
INFO [mavlink] MAVLink only on localhost (set param MAV_{i}_BROADCAST = 1 to enable network)
INFO [mavlink] MAVLink only on localhost (set param MAV_{i}_BROADCAST = 1 to enable network)
INFO [px4] Startup script returned successfully
pxh> WARN [health_and_arming_checks] Preflight Fail: No connection to the ground control station
WARN [health_and_arming_checks] Preflight Fail: No connection to the ground control station
2) MAVSDK
$ python3 takeoff_and_land.py
INFO [commander] GCS connection regained
INFO [commander] Armed by external command
INFO [tone_alarm] arming warning
INFO [logger] Start file log (type: full)
INFO [logger] [logger] ./log/2025-07-12/01_29_11.ulg
INFO [logger] Opened full log file: ./log/2025-07-12/01_29_11.ulg
INFO [navigator] Using default takeoff altitude: 2.5 m
INFO [commander] Takeoff detected
INFO [commander] Landing at current position
INFO [commander] Landing detected
INFO [commander] Disarmed by landing
INFO [tone_alarm] notify neutral
INFO [logger] closed logfile, bytes written: 5494396
INFO [commander] Connection to ground station lost
WARN [health_and_arming_checks] Preflight Fail: No connection to the ground control station
728x90
'엔지니어링 > 드론' 카테고리의 다른 글
[ PX4 ] SITL(Software-in-the-loop) with MATLAB Simulink (3) | 2024.10.20 |
---|---|
[ PX4 ] HITL ( Hardware In-The Loop Simulation ) (2) | 2024.10.10 |
[ PX4 ] Matlab UAVToolkit PX4 패키지를 이용한 개발 환경설정 (0) | 2024.09.28 |
SwiftF4 FC 개발 프로젝트 (1) - 프로젝트 생성 및 디버그 환경 설정 (0) | 2024.03.16 |
[STM32] VSCode에서 CrazyFlie 펌웨어 디버깅하기 (2) | 2023.12.31 |
댓글