반응형

ArduPilot SW의 설치가 완료되고 컴파일이 정상적으로 진행되었다면 이제는 컴파일 환경을 꾸밀 차례이다.

아무래도 C++코드를 텍스트 에디터에서 수정하는것은 만만치 않은 일이다. 따라서 Eclipse같은 개발 환경에서 코드를 수정하는게 아무래도 편하다.

따라서 이번에는 Eclipse를 설치하고 환경을 설정하는 과정을 설명하도록 하겠다.


먼저 이 과정은 OS X Yosemite 버전 10.10.5가 설치된 Mac Mini 에서 진행되었다.


1. Eclipse 설치

Eclipse IDE는 https://eclipse.org/downloads/ 에서 다운로드 받을 수 있다.



 Download 64bit 를 클릭하여 package downloader를 다운받은 후 설치를 진행한다.

Java가 설치되어있지 않거나 버전이 다른경우 설치가 되지 않을 수 있는데 이때는 다음 링크로 이동하여 최신의 JDK를 설치하면 된다.

http://www.oracle.com/technetwork/java/javase/downloads/jdk8-downloads-2133151.html


Accept License Agreement를 선택하고 Mac OS X 용 JDK를 다운받아 설치한다.


최신 버전의 JDK(현재는 1.8)를 설치하면 Eclipse의 설치를 진행할 수 있다. 


2. Eclipse 관련 소프트웨어 설치

Eclipse 설치 후 나머지 과정은 다음 링크의 자료를 참조한다.

http://www.davidrojas.co.uk/stm32f3discovery-on-mac-os-x-using-eclipse-gcc-arm-and-openocd/

Eclipse의 HELP 메뉴에서 Install New Software를 선택

“Available software sites” 를 선택하여 그림과 같이 CDT 항목을 선택

이제 Available Software에서 CDT를 선택할 수 있다.

CDT Main Features 전체와 Optional Features에서 아래 항목을 선택한다.


설치가 완료되면 이제 GNU ARM Plugin 을 설치할 차례이다.

다시 Help > Install New Software 를 선택한 후 Add...을 눌러 아래와 같이 새로운 사이트를 등록한다. 

Name: CDT GNU ARM

Location: http://gnuarmeclipse.sourceforge.net/updates

다음 항목에서 “CDT GNU Cross Development Tools” 컴포넌트를 찾을 수 있다. 이것을 선택하고 설치한다.



이제 새로운 ARM Make 프로젝트를 불러올 수 있다.


3. ArduCopter 프로젝트 Import하기

이 과정은 Ardupilot프로젝트 위키에도 설명되어 있으므로 다음 링크를 참조한다. 

http://ardupilot.org/dev/docs/editing-the-code-with-eclipse.html


프로젝트 파일 변경하기

GIT 명령으로 다운로드 받은 폴더로 이동하면(/Firmware) 다음과 같은 파일들이 보일것이다.

 $ ls

CMakeLists.txt README.md mavlink

CONTRIBUTING.md ROMFS misc

CTestConfig.cmake Tools msg

Debug Vagrantfile nuttx-configs

Documentation circle.yml nuttx-patches

Firmware.sublime-project cmake package.xml

Images eclipse.cproject posix-configs

LICENSE.md eclipse.project src

Makefile integrationtests test_data

NuttX launch unittests


이 파일들은 이클립스에서 프로젝트 Import하기 위한 내용들을 담고 있는 파일인데 원래는 .project, .cproject 라는 시스템 파일로 되어있어야 한다.

파일명을 바꾸기 위해 터미널 창에서 다음을 입력한다.


$ mv .eclipse.cproject .cproject

$ mv .eclipse.project .project


이 파일은 ls -a 명령으로 확인할 수 있다.

 $ ls -a

. NuttX

.. README.md

.ackrc ROMFS

.clang-tidy Tools

.cproject Vagrantfile

.git circle.yml

.gitignore cmake

.gitmodules integrationtests

.project launch

.travis.yml mavlink

.ycm_extra_conf.py misc

CMakeLists.txt msg

CONTRIBUTING.md nuttx-configs

CTestConfig.cmake nuttx-patches

Debug package.xml

Documentation posix-configs

Firmware.sublime-project src

Images test_data

LICENSE.md unittests

Makefile



이제 Eclipse IDE를 재시작하고 "Import... "을 선택하여 프로젝트를 가져온다.

먼저 다음과 같은 화면에서 Makefile Project 를 선택한다.

"Existing Projects into Workspace" 를 선택한다.



다음으로 넘어가서 프로젝트가 설치된 디렉토리를 선택한다.


Project 창에 해당 프로젝트가 하이라이트가 되면 다음으로 진행할 수 있다.

 Finish 를 눌러 프로젝트 가져오기를 마친다.


이제 Project Explorer 에 PX4 프로젝트가 나타날 것이다.


4.  Build Target지정하기

프로젝트 빌드를 하기 위해서는 Target을 지정해야 한다. Target은 이전에 Make 옵션과 동일하다.

IDE우측의 Make Target 항목에서 New... 를 선택하여 타겟을 지정한다.


Pixhawk 용 Quadcopter FW를 개발한다면 Target Name 이 px4-v2가 된다.

5. Project 환경 설정

Project Explorer 에서 ArduCopter 의 Properies를 선택하여 빌드 환경을 설정한다.

만약 빌드 환경을 제대로 설정하지 않고 빌드하게 되면 콘솔에 아래와 같은 오류가 뜨면서 빌드가 완료되지 않을 것이다.


make: arm-none-eabi-size: No such file or directory

make: *** [px4-v2] Error 1


이것은 ARM 컴파일을 하기 위한 플러그인의 위치를 지정하지 않아서 발생한다.

arm 컴파일 플러그인은 arm-none-eabi-**** 와 같은 이름의 파일인데 brew를 사용하여 설치하였다면 일반적으로 

루트 디렉토리의 /usr/local/bin 에 위치하게 된다.


아래와 같이 C/C++ Build 항목의 Tool Paths 에서 다음과 같이 설정한다.

OK 를 눌러 Path를 지정하면 정상적으로 빌드를 할 수 있다.


ArduCopter-v2.px4 가 생성된 것을 확인하면 빌드가 성공한 것이다.






반응형
반응형

Pixhawk 는 오픈소스 드론 프로젝트 중의 하나인  ardupilot 의 코드를 실행하기 위한 플랫폼이다.

Ardupilot  은 크게 Ardupilot version 1 과 Pixhawk 용 버전으로 나뉘고 

Pixhawk용 버전은 px4-v2 로 구분되어진다. px4-v1은 이전 버전인 PX4 용 코드이다.


다음은 Mac 환경에서 Pixhawk용 Ardupilot을 Build 하는 과정을 정리해보았다.


이 모든 과정은 OS X Yosemite 10.10.5가 설치된 Mac mini에서 수행되었다.


1. 먼저 http://brew.sh/ 에서  Max OS X 용 Homebrew를 설치한다. 

설치 방법은 다음과 같다.

터미널을 열고 아래 명령어를 복사하여 실행한다.


/usr/bin/ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"


필요한 경우 프로그램을 설치할 것이다.


설치가 완료되면 다음을 순서대로 실행한다.

brew tap PX4/homebrew-px4


brew update


brew install genromfs


brew install gcc-arm-none-eabi



2. brew 를 사용하여 최신의 awk 버전을 설치한다.

brew install gawk 



3. 다음 명령어를 실행하여 pip와 pyserial을 설치한다.

sudo easy_install pip 

  sudo pip install pyserial 


4. 새로운 디렉토리를 생성하고 모든 sw를 설치한다.

mkdir -p px4

cd px4

git clone https://github.com/ArduPilot/ardupilot.git

cd ardupilot

git submodule init

git submodule update


5. Arducopter 디렉토리로 이동하여 다음 명령어를 실행한다.

쿼드콥터용 Pixhawk2/Pixhawk 펌웨어 빌드: make px4-v2

핵사콥터용 Pixhawk펌웨어 빌드를 위해서는: make px-v2-hexa

그밖의 다른 프레임을 위해서는 hexa 대신 "octa", "tri" 또는 "heli"를 넣는다.


처음 make 하게 되면 아래와같은 메세지가 뜰 수 있다.

Skipping submodules. NUTTX_SRC is set to /Users/kyubot_macmini2/px4/ardupilot/modules/PX4Firmware/NuttX/nuttx/

Generating uORB topic headers

python import error:  No module named em


Required python packages not installed.


On a Debian/Ubuntu system please run:


  sudo apt-get install python-empy

  sudo pip install catkin_pkg


On MacOS please run:

  sudo pip install empy catkin_pkg


On Windows please run:

  easy_install empy catkin_pkg


make[1]: *** [generateuorbtopicheaders] Error 1

make: *** [px4-io-v2] Error 2

이 에러는 python 페키지가 없어서 발생하는것으로 추정되는데 이때는 설명대로 

pip 명령어로 catkin_pkg 를 설치한 후 다시 빌드해본다.

그러면 정상적으로 빌드가 되는것을 볼 수 있다.


주. catkin_pkg는 다시 검색해보니 ROS를 지원하기 위한 Python 라이브러리이다.


빌드가 완료되면 ArduCopter 디렉토리에 ArduCopter-v2.px4 라는 파일이 생성된다.


반응형
반응형

I have been struggling to setup Pixhawk on my Mantis280 drone.

The problem is the drone never get stabilized and motor speed keeps diverge right after increasing the throttle.

Changing the PID gain didn't work.

ESC calibration didn't work.

RC calibration didn't work.

My final guess is about the motor and ESC combination I am using is as follows.

Motor: FR1806-2300KV from RCTimer

ESC: K18A ESC(KISS ESC18A) 2-4S also from RCTimer

Theses motors and escs are for racing equipment and has higher KV to normal setup.

I found slight increase of throttle causes too much output, so I decided to find ways to make pixhawk not to increase the output too much.

The way I found it adjusting the parameter in MOT section.

Launch Mission Planner and go to <CONFIG/TUNING> tab, then Open <Full Parameter Tree>

Find MOT section as below picture.

MOT_THST_MAX was 0.9 which means pixhawk will use 90% of the throttle range of the motor.

I reduced this number to 0.4

MOT_THST_EXPO governs the slope of response and higher number means more steep response to the motor.

Default was around 0.65 and also decreased to 0.5.

 

With above adjustment, the drone finally get stabilized!!

No twitching at all. Of course I may lose some power but I don't need that much of power for my drone purpose at this time.

 

This guide first uploaded on 2016/6/12 by Kyubot

반응형

+ Recent posts