'시뮬레이션'에 해당되는 글 2건

Dev/Drone

SITL(3) : 실행 및 파라미터


GUIDED 모드


이전 글에서 SITL 을 성공적으로 설치했다면 이번에는 시뮬레이터 속의 드론을 비행시켜 보자.

  • ardupilot/ArduCopter 으로 이동한 후에 아래 명령어를 입력한다. 
sim_vehicle.py -w --map --console

 




 위와 같은 화면 구성이 보일 것이다. 명령어를 실행시켰던 기존 콘솔에서 동작하는 프로세스가 MAVProxy 이다. MAVProxy 에 아래와 같이 명령어를 입력해 보자.

  • 모드를 GUIDED 로 설정한다.
mode GUIDED
  • 모터를 ARM 시킨다.
arm throttle

ARM 은 아두파일럿에서 '시동' 과 비슷한 의미라고 생각해 두면 좋다.

  • 이륙시켜 보자.
takeoff 100

console 에서 altitude 가 20 이 될 때까지 드론이 움직이는 모습을 볼 수 있다.

  • GUIDED 모드는 GCS 에서의 즉각적인 명령에 따르는 모드이다.  MAP 위에서 명령을 날려서 원하는 위치로 날려보자.




Auto 모드


ardupilot 의 mission 기반 자동 비행 기능으로, 'Autopilot'  이름값을 하는 모드이다. SITL 을 실행하고 MAVProxy 에 아래와 같은 명령어를 입력해 보자.

  • 미리 설정된 waypoint 들을 전송

    wp load ../Tools/autotest/copter_mission.txt
    




  • 위와 같이 map 에 waypoint 가 보일 것이다. 먼저 이륙을 시켜보자.

    mode guided 
    arm throttle 
    takeoff 20
    
  • 이륙 후에 모드를 Auto 로 변경하면, waypoint 를 따라서 비행이 시작된다.

    mode auto
    

sim_vehicle.py


sim_vehicle.py 는 아두파일럿의 빌드와 코드의 실행을 자동으로 Simulating & Testing 할 수 있는 스크립트이다.

아레는 sim_vehicle.py -h 을 실행했을 때 볼 수 있는 파라미터들에 대한 설명이다.

Options:
  -h, --help            show this help message and exit
  -v VEHICLE, --vehicle=VEHICLE
                        vehicle type (ArduPlane, ArduCopter or APMrover2)
  -f FRAME, --frame=FRAME
                        set aircraft frame type                      for
                        copters can choose +, X, quad or octa
                        for planes can choose elevon or vtail
  -C, --sim_vehicle_sh_compatible
                        be compatible with the way sim_vehicle.sh works; make
                        this the first option
  -H, --hil             start HIL

  Build options:
    -N, --no-rebuild    don't rebuild before starting ardupilot
    -D, --debug         build with debugging
    -c, --clean         do a make clean before building
    -j JOBS, --jobs=JOBS
                        number of processors to use during build (default for
                        waf : number of processor, for make : 1)
    -b BUILD_TARGET, --build-target=BUILD_TARGET
                        override SITL build target
    -s BUILD_SYSTEM, --build-system=BUILD_SYSTEM
                        build system to use
    --rebuild-on-failure
                        if build fails, do not clean and rebuild
    --waf-configure-arg=WAF_CONFIGURE_ARGS
                        extra arguments to pass to waf in its configure step
    --waf-build-arg=WAF_BUILD_ARGS
                        extra arguments to pass to waf in its build step

  Simulation options:
    -I INSTANCE, --instance=INSTANCE
                        instance of simulator
    -V, --valgrind      enable valgrind for memory access checking (very
                        slow!)
    -T, --tracker       start an antenna tracker instance
    -A SITL_INSTANCE_ARGS, --sitl-instance-args=SITL_INSTANCE_ARGS
                        pass arguments to SITL instance
    -G, --gdb           use gdb for debugging ardupilot
    -g, --gdb-stopped   use gdb for debugging ardupilot (no auto-start)
    -d DELAY_START, --delay-start=DELAY_START
                        delays the start of mavproxy by the number of seconds
    -B BREAKPOINT, --breakpoint=BREAKPOINT
                        add a breakpoint at given location in debugger
    -M, --mavlink-gimbal
                        enable MAVLink gimbal
    -L LOCATION, --location=LOCATION
                        select start location from
                        Tools/autotest/locations.txt
    -l CUSTOM_LOCATION, --custom-location=CUSTOM_LOCATION
                        set custom start location
    -S SPEEDUP, --speedup=SPEEDUP
                        set simulation speedup (1 for wall clock time)
    -t TRACKER_LOCATION, --tracker-location=TRACKER_LOCATION
                        set antenna tracker start location
    -w, --wipe-eeprom   wipe EEPROM and reload parameters
    -m MAVPROXY_ARGS, --mavproxy-args=MAVPROXY_ARGS
                        additional arguments to pass to mavproxy.py
    --strace            strace the ArduPilot binary
    --model=MODEL       Override simulation model to use

  Compatibility MAVProxy options (consider using --mavproxy-args instead):
    --out=OUT           create an additional mavlink output
    --map               load map module on startup
    --console           load console module on startup

대부분 default 로 놓아도 문제가 없지만, 중요한 파라미터는 다음과 같다.

  • --out : MAVProxy 에게 적용되는 파라미터로써, SITL 상에서 존재하는 드론과 연결할 GCS 혹은 다른 Application 의 Address 가 오면 된다.
  • --map : Vehicle 의 위치에 대한(GPS 좌표 기반) 지도를 표시한다. 이 화면을 이용하여 GUIDED 모드의 기능을 테스트하고 Vehicle 의 행동을 그래픽으로 대강이나마 관찰할 수 있다.
  • --console : Vehicle 에 대한 정보를 볼 수 있는 콘솔을 추가로 연다. 그렇지 않으면 기존 터미널에 출력된다.
  • -G --gdb : 디버깅 옵션을 추가한다.
  • -w --wipe-eeprom : eeprom (드론의 보조 기억장치) 를 지우고 시작한다. 사전에 설정된 Mission 등등이 삭제된다.

참고문헌



http://ardupilot.org/dev/docs/copter-sitl-mavproxy-tutorial.html

Dev/Drone

SITL(2) : 설치




환경


필자는 다음과 같은 환경에서 테스트 하였다.

  • Ubuntu 14.04 (Windows 10 에서 VM ware 를 이용)

설치

  • 아두파일럿 다운로드
sudo apt-get install git # git 이 설치되어 있지 않을 경우 
git clone git://github.com/ArduPilot/ardupilot.git
cd ardupilot
git submodule update --init --recursive
  • 필수 패키지 설치
sudo apt-get update 
sudo apt-get install python-matplotlib python-serial python-wxgtk2.8 python-wxtools python-lxml
sudo apt-get install python-scipy python-opencv ccache gawk git python-pip python-pexpect
sudo pip install future pymavlink MAVProxy
  • 환경변수 추가
export PATH=$PATH:$HOME/jsbsim/src
export PATH=$PATH:$HOME/ardupilot/Tools/autotest
export PATH=/usr/lib/ccache:$PATH

위의 코드를 ~/.bashrc 의 맨 밑줄에 추가해 준 후, 터미널을 껏다 켜거나 다음 명령어를 입력한다.

 . ~/.bashrc

실행


ardupilot 을 다운로드 받은 디렉터리로 이동한 후, 다음 디렉터리로 이동한다.

 cd ardupilot/ArduCopter 
 sim_vehicle.py -w --map --console

몇 분간의 빌드를 마치면 아래와 같이 아두파일럿 SITL 이 실행된다.



참고문헌



http://ardupilot.org/dev/docs/setting-up-sitl-on-linux.html

1
블로그 이미지

IT & Computer Science

빨간호랑이