티스토리 뷰

PX4 Gazebo시뮬레이션 환경 구성

 

알고리즘 테스트할때마다 밖에 나가서하기 귀찮기도하고 마다할 이유가 없어서 구성하고 알고리즘 테스트용으로 사용하시면 좋을듯 합니다. 

 

저도 검색하면서 자료찾아가며 테스트를 진행했는데요. 옛날 펌웨어기준으로 작성된 자료들이 많았습니다. 

Jetson이나 임베디드 보드 환경에서는 어떻게 될지 잘 모르겠습니다만(Jetson으로 최신버전 구버전 다 테스트해보았지만 결국 막혔습니다.) desktop or laptop 환경에서는 잘 되었습니다. 결국 아키텍쳐 호환문제가 아닐까 생각이드네요.

 

ros_melodic으로 진행을 했고 설치가 되었다는 가정하에 쓰겠습니다.

 

PX4 시뮬레이션 통신환경

1.mavros 설치

sudo apt-get update
sudo apt-get install ros-melodic-mavros ros-melodic-mavros-extras

2.px4 설치

https://docs.px4.io/master/en/dev_setup/building_px4.html

 

Building PX4 Software | PX4 User Guide

Building PX4 Software PX4 can be built on the console or in an IDE, for both simulated and hardware targets. Note Before following these instructions you must first install the Developer Toolchain for your host operating system and target hardware. Downloa

docs.px4.io

git clone https://github.com/PX4/PX4-Autopilot.git --recursive
cd PX4-Autopilot
git submodule update --recursive
make distclean

이후 PX4 폴더에서 

roslaunch mavros px4.launch fcu_url:="udp://:14540@127.0.0.1:14557" #14557:ROS, 14540:OFFBOARD(mavros)
make px4_sitl_default gazebo #시뮬레이션 환경 실행

이 과정에서 생기는 웬만한 오류내용들은 위 문서에 담겨있습니다.

Package 관련 오류시 

bash ./Tools/setup/ubuntu.sh (px4폴더내에서 실행 필요한 파일들 설치)
pip3 install --user pyserial empy toml numpy pandas jinja2 pyyaml pyros-genmsg packaging
sudo apt upgrade libignition-math2

Error in REST request --> (Gazebo)

sudo find -name .ignition 을통해 나온 경로로 들어가서 

vim fuel/config.yaml

url: https://api.ignitionfuel.org --> url: https://api.ignitionrobotics.org 로 변경후 저장 

 

MAVROS로 비행 테스트

cd ~/catkin_ws/src
git clone https://github.com/Jaeyoung-Lim/modudculab_ros.git
cd ..
catkin_make
roscore
-----------------------------
make px4_sitl_default gazebo
-----------------------------
roslaunch modudculab_ros ctrl_pos_gazebo.launch
----------------------------------------------- 각각 다른 터미널창 혹은 탭에서 실행
rosrun mavros mavsafety arm
rosrun mavros mavsys mode -c OFFBOARD

간단한 위치제어 알고리즘을 테스트해보고 싶다면 modudculab/src/pub_setpoints_pos.cpp 파일을 수정하면 된다.

 

 

QGroundContorl로 비행 테스트

QgroundControl 우선 설치해주고 (홈페이지 메뉴얼 참조)

https://docs.qgroundcontrol.com/master/en/releases/daily_builds.html

 

Daily Builds · QGroundControl User Guide

No results matching ""

docs.qgroundcontrol.com

기본세팅대로 연다음에 왼쪽 상단에 옵션창 열고 Application Settings 버튼 눌러준다.

 

Comm link 메뉴 선택후 Add PX4 manual 에서는 UDP 14550 포트를 사용한다 했으므로 UDP 눌러주면 그대로 포트가 14550으로 설정된것을 볼 수 있다. 

이름 입력해주고 OK누르고 mavros 실행 후 연결해주고 시뮬레이션 켜주면 no datalink 메시지도 안뜨고 정상적으로 이륙도 된다.

 

이전 버전에서는 no datalink가 떠도 이륙된것 같은데 이에 대해서 문제제기하는 사람들이 있는 것으로 보아 최신버전에서 패치되고 이륙이 안됐던것이고 정상적으로 QGC하고 연결이되면 이륙이 가능하다.

 

댓글
공지사항
최근에 올라온 글
최근에 달린 댓글
Total
Today
Yesterday
링크
«   2024/05   »
1 2 3 4
5 6 7 8 9 10 11
12 13 14 15 16 17 18
19 20 21 22 23 24 25
26 27 28 29 30 31