티스토리 친구하기

본문 바로가기

Robotics/Ardupilot

아두파일럿 픽스호크 개발 #2 / ardupilot 개발환경 설정

728x90

1. 검색창에서 ardupilot dev 검색

검색창: ardupilot dev

 

2. cygwin 설치

 - 리눅스 프로그램/유틸리티를 윈도우에서 사용할 수 있도록 하는 프로그램[2]

 

 - ardupilot dev에서 아래의 그림처럼 찾아 들어가거나, 또는 아래의 주소로 들어갑니다.

 

ardupilot.org/dev/docs/building-setup-windows.html

 

 - 아래의 그림에서 "1.Install cygwin as decribed here"을 클릭합니다.

 

 

방법 1

1. www.cygwin.com/install.html에 웹 브라우저를 열고 "setup-x86_64.exe"를 다운로드하세요. 

2. 윈도우+R 키를 누르고 cmd를 타이핑해서 DOS prompt에 들어갑니다. 그리고  "Run setup-x86_64.exe"를 다운로드한 폴더로 이동한 다음에 아래의 명령어들을 DOS prompt 복사 붙여 넣기 합니다.

 

setup-x86_64.exe -P autoconf,automake,ccache,gcc-g++,git,libtool,make,gawk,libexpat-devel,libxml2-devel,python36,python36-future,python36-lxml,python36-pip,libxslt-devel,python36-devel,procps-ng,zip,gdb,ddd,xterm

 

 

방법 2

* DOS prompt를 이용하는 방법이 익숙하지 않다면 아래의 순서에 따라 설치하시면 됩니다.

 

1. www.cygwin.com/install.html에 웹 브라우저를 열고 setup-x86_64.exe를 실행합니다. 

 

setup-x86_64.exe을 다운받아서 실행하면 오른쪽 그림과 같이 Cygwin Setup이 실행됩니다.

 

2. 패키지 선택 대화 상자(Select Packages)에 도달할 때까지 모든 프롬프트(기본 파일 위치 포함)를 수락합니다. 즉, 다음 버튼을 계속 누르시면 됩니다.

 

 

3. 위의 그림에서 다음과 같이 선택하세요

 - View --> Category 

 - Search에서 아래의 표에 있는 Package들 중 하나를 검색합니다.

 - All 왼쪽에 있는 + 버튼을 클릭해서 검색한 Package 이름과 똑같은 걸 찾아서 'Skip'이라고 쓰여 있는 것을 클릭하여 최신 버전 번호로 바꿉니다.

 

 

 - 위의 과정을 아래에 있는 모든 패키지에 대해 일일이 수행합니다. DOS prompt에서 복사하여 붙여 넣기 하여 한번에 진행했던 과정을 일일이 하는 것입니다.

 

automake Devel | automake: Wrapper scripts for automake and aclocal
ccache Devel | ccache: A C compiler cache for improving recompilation
gcc-g++ Devel | gcc-g++ GNU Compiler Collection (C++)
git Devel | git: Distributed version control system
libtool Devel | libtool: Generic library support script
make Devel | make: The GNU version of the ‘make’ utility
gawk Interpreters | gawk: GNU awk, a pattern scanning and processing language
libexpat-devel Libs | libexpat-devel: Expat XML parser library (development files)
libxml2-devel Libs | libxml2-devel: Gnome XML library (development)
libxslt-devel Libs | libxslt-devel: XML template library (development files)
python36 Python | python36: Python2 language interpreter
python36-devel Python | python36-devel: Python3 language interpreter
python36-future Python | python36-future: Clean single-source support for Python 3 and 2
python36-libxml2 Python | python36-lxml: Gnome XML Library (Python bindings)
python36-pip Python | python36-pip: Python package installation tool
procps-ng System | procps-ng: System and process monitoring utilities (required for pkill)
gdb Devel | gdb: The GNU Debugger
ddd Devel | ddd: DDD, the data display debugger
zip Archive | zip: Info-ZIP compression utility
xterm Shells, X11 | X11 terminal emulator

 

4. 위의 표에 있는 모든 패키지를 선택했다면, 다음 버튼을 눌러 패키지 설치를 시작합니다.

 

 

5. 다음 버튼을 눌러서 모든 과정을 진행했으면 마침 버튼을 선택하여 설치를 완료합니다.

 

안티바이러스 보호 소프트웨어가 실행 중이기 때문에 설치가 중단되는 경우가 있습니다. 
이런 경우 안티바이러스 보호를 포함하여 PC의 다른 모든 프로그램을 종료하고 다시 시도하세요.

 

 

3. Install the GCC compiler (GCC 컴파일러 설치)

- 이 과정은 ARM-based boards를 컴파일할 때에만 필요합니다. 우리는 추후에 Pixhawk 보드에 코드를 업로드할 것이기 때문에 GCC 컴파일러를 설치합니다.

 

1. 아래의 주소에서 gcc-arm-non-eabi compiler를 다운로드하여 설치합니다.

 

firmware.ardupilot.org/Tools/STM32-tools (quick link is here)

 

  • accept the license
  • install to the default location
  • accept the ssl certificate
  • check option to “Add path to environment variable”

위와 같은 가이드라인이 있는데, 그냥 설치 파일 실행하시고 다음 버튼을 계속 누르시면 됩니다. 그리고 아래의 그림처럼 마지막에 "Add path to environment variable"은 꼭 체크해주세요.

 

 

4. Install MAVProxy 

MAVProxy GCS는 SITL을 running 할 때만 필요합니다. 만약 SITL을 사용하지 않으면 skip 하세요.

(저는 사용하지 않아서 skip 했습니다.)

 

윈도우에 MAVProxy를 설치하려면 다음 문서를 참고하세요.

 

MAVProxy documentation.

 

 

5. Set up directories/paths and extra packages in Cygwin

1. 바탕 화면 또는 시작 메뉴 아이콘에서 "Cygwin64 Terminal" 응용 프로그램을 연 다음 닫습니다. 이렇게 하면 Cygwin 홈 디렉터리에서 사용자에 대한 초기화 파일이 생성됩니다.

 

2. 바탕 화면 또는 시작 메뉴 아이콘에서 "Cygwin64 Terminal" 응용 프로그램을 엽니다. 다음 명령을 입력하여 Python 3.6을 기본 Python으로 설정한 다음 추가 Python 패키지를 설치합니다.

 

ln -s /usr/bin/python3.6 /usr/bin/python
ln -s /usr/bin/pip3.6 /usr/bin/pip
pip install empy pyserial pymavlink

 

*에러 발생 시 해결방법

Cygwin terminal 상에서 추가 패키지를 설치하기 위해서 pip 명령어를 사용합니다.

python3.6을 default로 사용하기 위해 위에서 첫 번째 줄에 있는 "ln -s /usr/bin/python3.6 /usr/bin/python" 명령어를 사용합니다. 그런데 이때 /cygwin64/bin/ 폴더에 python이라는 이름의 파일이 이미 존재하여 링크가 안 되는 현상이 발생되어 아래와 같은 에러가 발생할 수 있습니다.

 

 

이 문제를 해결하기 위해서, 기존 python 이름을 다른 이름으로 바꾸고 위의 명령어를 다시 실행하면 됩니다.

폴더의 위치는 C드라이버/cygwin64/bin/이고, 아래와 같이 다른 이름으로 수정하고 위의 명령어를 다시 입력합니다.

 

 

 

6. Download ArduPilot Source

Ardupilot 오픈 소스코드를 다운로드하기 위해서 Cygwin terminal을 실행하고 아래의 명령어를 입력합니다. 

 

git clone https://github.com/ardupilot/ardupilot.git
cd ardupilot
git submodule update --init --recursive

 

최신 버전의 아두파일럿(ardupilot) 오픈소스가 다운로드되고 그 위치는 다음과 같습니다.

 

C:\cygwin64\home\Username

Username은 컴퓨터에 따라 다릅니다.

 

7. Build with Waf

마지막 단계입니다.

환경설치도 다 했고 오픈소스코드도 다운로드하였으니, 이제 pixhawk 보드에 소스코드를 업로드하기 위해 build를 해야 합니다. build는 waf를 이용합니다. 

다운로드한 ardupilot 소스코드에서 Build.md 파일을 열어보거나 아래 링크의 깃허브로 들어가서 build.md 파일을 확인하세요.

 

BUILD.md

 

Build ArduCopter

빌드를 하기 위해서 1. 보드를 선택하고, 2.build 할 소스코드를 선택해야 합니다.

아래는 Pixhawk2/Cube 보드에 대해서 ArduCopter를 build 하는 명령어 예제입니다.

 

./waf configure --board CubeBlack
./waf copter

 

만약, Pixhawk2/Orange에 rover 소스코드를 빌드하고 싶으면 아래와 같이 해야 합니다.

 

./waf configure --board CubeOrange
./waf rover

 

"./waf configure --board CubeBlack" 명령어는 보드는 바꿀 때만 실행하면 되고, "./waf copter"는 소스코드를 수정할 때마다 실행해서 소스코드를 build 해야 합니다.

build를 완료하면 아래와 같은 화면이 나타납니다. 

 

 

 

아래에는 여러 가지 보드의 종류를 나열한 것입니다.

 

./waf configure --board bebop --static # Bebop or Bebop2
./waf configure --board edge           # emlid edge
./waf configure --board fmuv3          # 3DR Pixhawk 2 boards
./waf configure --board navio2         # emlid navio2
./waf configure --board Pixhawk1       # Pixhawk1
./waf configure --board CubeBlack      # Hex/ProfiCNC Cube Black (formerly known as Pixhawk 2.1)
./waf configure --board Pixracer       # Pixracer
./waf configure --board skyviper-v2450 # SkyRocket's SkyViper GPS drone using ChibiOS
./waf configure --board sitl           # software-in-the-loop simulator
./waf configure --board sitl --debug   # software-in-the-loop simulator with debug symbols

 

 

아래에는 Ardupilot에서 제공하는 vehicle들의 소스코드입니다. 

 

./waf copter                            # All multirotor types
./waf heli                              # Helicopter types
./waf plane                             # Fixed wing airplanes including VTOL
./waf rover                             # Ground-based rovers and surface boats
./waf sub                               # ROV and other submarines
./waf antennatracker                    # Antenna trackers

 

Upload or install

build를 했으면 이제 Pixhawk에 업로드할 차례입니다.

빌드 명령에는 연결된 보드에 빌드된 이진 파일을 업로드하기 위한 --upload 옵션이 있습니다. 이 옵션은 Pixhawk 및 Linux 기반 보드에서 지원됩니다.

아래 명령어처럼 --targets 옵션을 사용해서 build 한 소스코드를 pixhawk 보드에 업로드합니다.

 

./waf --targets bin/arducopter --upload

 

위의 명령어를 실행하면 아래와 같이 보드를 연결하라는 말이 나옵니다. 보드는 USB로 컴퓨터와 이미 연결했으면 뺐다가 다시 연결하시면 됩니다. 저는 연결하지 않고 있다가 아래의 "If the board~" 문구가 나오면 그때 연결합니다. 업로드가 잘 안될 때에는 USB 선을 뺐다 연결했다를 반복 하다 보면 업로드가 됩니다.

 

 

업로드가 완료되면 아래와 같은 화면을 볼 수 있습니다.

 

 

업로드가 완료되었습니다. 수고하셨습니다.

 

다음 포스팅에서는 내가 원하는 데로 로봇을 컨트롤하기 위해서 오픈소스를 수정해보도록 하겠습니다. 

 

 

[1] ardupilot.org/dev/

[2] mwultong.blogspot.com/2006/07/cygwin-cygwin.html

[3] www.cygwin.com/install.html

[4] firmware.ardupilot.org/Tools/STM32-tools

[5] gcc-arm-none-eabi-6-2017-q2-update-win32-sha2.exe

[6] github.com/ArduPilot/ardupilot/blob/master/BUILD.md

 

 

반응형