Difference between revisions of "RT Paparazzi"

From PaparazziUAV
Jump to: navigation, search
m (added link to ICUAS2016 code)
(rt pprz edit)
Line 19: Line 19:
 
== Getting the sourcecode ==
 
== Getting the sourcecode ==
  
Most recent code is available under ''rt_paparazzi'' branch from Paparazzi Git repo [https://github.com/paparazzi/paparazzi], however you can check these two repositories too ([https://github.com/podhrmic/ChibiOS-RT] and [https://github.com/podhrmic/paparazzi])
+
First version of functional RT paparazzi code (which comes with other perks such as SD card logging) is already available in the ''[https://github.com/paparazzi/paparazzi master]'' branch, thanks to [https://github.com/gautierhattenberger gautierhattenberger]. The code is continually improving, so stay tuned.
  
  
 
== Debugging with an Eclipse IDE ==
 
== Debugging with an Eclipse IDE ==
 +
'''NOTE: As of June 2016 and ChibiOS 3.0+ SWD debugging with Black Magic Probe doesn't work under Eclipse (you get segmentation faults). The debugging works normally in terminal (arm-none-eabi-gdb), but I suspect there is some bug in how Eclipse is handling the debugging commands. Older versions of Eclipse (before Mars 2.0) and ChibiOS 2.6 work together perfectly.'''
  
 
Having a good development and debugging environment is a must for developing RT embedded system. The steps of setting up Eclipse IDE are described here [http://wiki.chibios.org/dokuwiki/doku.php?id=chibios:guides:eclipse1] and here [http://wiki.chibios.org/dokuwiki/doku.php?id=chibios:guides:eclipse2].
 
Having a good development and debugging environment is a must for developing RT embedded system. The steps of setting up Eclipse IDE are described here [http://wiki.chibios.org/dokuwiki/doku.php?id=chibios:guides:eclipse1] and here [http://wiki.chibios.org/dokuwiki/doku.php?id=chibios:guides:eclipse2].
Line 51: Line 52:
 
=== ChibiOS Eclipse plugin ===
 
=== ChibiOS Eclipse plugin ===
  
A nice and comprehensive guide about how to install ChibiOS plugins is [http://cxkg.net/chibios-board-generator/ here].  
+
ChibiStudio plugin is officially supported for Windows only (write to the [http://www.chibios.com/forum/ ChibiOS forum] if you would like Linux support too), but since it is in Java it works under Linux too. If you want to test it yourself, here is the HOWTO:
  
In case the page is not available, here is an older manual:
+
* Get the latest eclipse (Version: Mars.2 Release (4.5.2))
* to use ChibiOS/RT debug module for Eclipse, download ChibiStudio (it is for Windows only) from SourceForge [http://sourceforge.net/projects/chibios/files/ChibiStudio/], extract it and from ''ChibiStudio/eclipse/plugins'' copy
+
* Install C/C++ Hardware Debugging as described [[wiki.chibios.org/dokuwiki/doku.php?id=chibios:guides:eclipse1#eclipse|here]]
org.chibios.tools.eclipse.config_1.2.1.jar
+
* Make sure you have gcc-arm-none-eabi installed (v.4.9)
org.chibios.tools.eclipse.debug_1.0.8.jar
+
* Download latest ChibiStudi (preview 17) from [https://sourceforge.net/projects/chibios/files/ChibiStudio/ here] extract it and from ''ChibiStudio/eclipse/plugins'' Copy these libraries into your Eclipse/plugins directory:
to your ''eclipse/plugins'' directory. Restart Eclipse and in "Help->About Eclipe->Installation Details->Plugins" you should see both chibios plugins. Enable the plug-in while in the "Debug" view under: Window->Show View->Other...->ChibiOS/RT->ChibiOS/RT" (see [http://forum.chibios.org/phpbb/viewtopic.php?f=3&t=140] for details)
+
    org.chibios.chibistudio.branding_1.0.0.jar
 +
    org.chibios.tools.eclipse.config_1.9.1.201603121101.jar
 +
    org.chibios.tools.eclipse.debug.chibiosrt2_1.2.0.201603121101.jar
 +
    org.chibios.tools.eclipse.debug.chibiosrt3_1.0.1.201603121101.jar
 +
    org.chibios.tools.eclipse.debug.chibiosrt4_1.0.0.201603121101.jar
 +
* Restart Eclipse - now you will see the ChibiOs plugings under ''Help->Installation Details->Plugins''
 +
* Enable the plug-in while in the "Debug" view under: Window->Show View->Other...->ChibiOS/RT->ChibiOS/RT" (see [http://forum.chibios.org/phpbb/viewtopic.php?f=3&t=140] for details)
 +
 
 +
Now you can use ChibiStudio plugin to view your threads memory usage, available stack, trace buffer etc. depending on the debugging options you enabled.
  
 
=== ChibiOS Tutorials ===
 
=== ChibiOS Tutorials ===
 
Related videos about setting up Eclipse with ChibiOS plugins (called together ChibiStudio) are available [https://www.youtube.com/playlist?list=PLpDawCIUjDFFXjRFUT9tFcUuuvNb6iT1A here]
 
Related videos about setting up Eclipse with ChibiOS plugins (called together ChibiStudio) are available [https://www.youtube.com/playlist?list=PLpDawCIUjDFFXjRFUT9tFcUuuvNb6iT1A here]
  
== Compiling Paparazzi code in Eclipse ==
+
= Compiling Paparazzi code in Eclipse =
 
Typical process consists of compiling the autopilot code for given airframe in Paparazzi center, and then running the related debug configuration in Eclipse. The debugger will first recompile whole Paparazzi (e.g. running "make" in Paparazzi home directory), which is not really useful, but bearable.
 
Typical process consists of compiling the autopilot code for given airframe in Paparazzi center, and then running the related debug configuration in Eclipse. The debugger will first recompile whole Paparazzi (e.g. running "make" in Paparazzi home directory), which is not really useful, but bearable.
  
Line 80: Line 89:
  
 
That will compile ''Current_Aiframe'' with target ''ac''. Obviously, if you need a different target, for example ''test_telemetry'', you will have to change the last two steps to ''test_telemetry.compile'' and so on.
 
That will compile ''Current_Aiframe'' with target ''ac''. Obviously, if you need a different target, for example ''test_telemetry'', you will have to change the last two steps to ''test_telemetry.compile'' and so on.
 
= Paparazzi on Linux =
 
 
Taking the ARDrone 2 base install is a good example how Paparazzi could be used to run the core Autopilot executable
 
 
= RT Paparazzi at ENAC =
 
 
There is an internal project at ENAC of a RT Paparazzi
 

Revision as of 09:38, 15 June 2016

Real Time (RT) Paparazzi

ICUAS 2016 An Open-Source Real-Time UAS Flight Control Prototyping and Testing Platform with Fractional-Order Horizontal Controller Example

The code is available here

Introduction

the RT Paparazzi initiative is a step towards extended flexibility for the core autopilot. In a real time operating system (RTOS) [1] multiple threads are available, which are doing specific jobs e.g. a telemetry thread, a radio thread, a failsafe thread, at a defined rate. Unlike bare-metal application which uses interrupt driven timers for timing tasks, real time OS has a kernel which takes care of scheduling and running the threads. Having a kernel, it is possible to set priority of each thread, how much memory it takes etc.etc. which gives the developer more control over timing and resource managment.

Besides kernel, a typical RTOS also has a harware abstraction layer (HAL) which stands between user application and actual hardware, so the core autopilot developer doesn't have to worry to much about writing drivers for the sensor to use.

One of the strengths of Paparazzi is it's modularity - combining this with precise timing, scheduling and resource management a RTOS brings along, Paparazzi is now in a position to exceed even the leading commecial closed-source UAs autopilots.

Paparazzi with ChibiOS/RT

RT Paparazzi is based on ChibiOS/RT [2]. ChibiOS/RT supports basically all architectures that standard Paparazzi does (see [3]), which makes both systems compatible. Since RTOS makes handling multiple I/O easier, but comes with some extra overhead (context switching, kernel code), it gives most leverage to to STM32 F1xx and F4xx based autopilots (Apogee/v1.00,Lisa/M_v20, Lisa/S, STM32F4_Discovery, KroozSD...).

The development of RT Paparazzi with ChibeOS was started by the AggieAir team [4] at Utah State University.

Getting the sourcecode

First version of functional RT paparazzi code (which comes with other perks such as SD card logging) is already available in the master branch, thanks to gautierhattenberger. The code is continually improving, so stay tuned.


Debugging with an Eclipse IDE

NOTE: As of June 2016 and ChibiOS 3.0+ SWD debugging with Black Magic Probe doesn't work under Eclipse (you get segmentation faults). The debugging works normally in terminal (arm-none-eabi-gdb), but I suspect there is some bug in how Eclipse is handling the debugging commands. Older versions of Eclipse (before Mars 2.0) and ChibiOS 2.6 work together perfectly.

Having a good development and debugging environment is a must for developing RT embedded system. The steps of setting up Eclipse IDE are described here [5] and here [6].

An alternative guide is for example here [7]

Another great tutorial for setting up Eclipse is done by armstrap.
With blacmagic probe integration, without Eclipse Arm Plugin.

Just a few notes to the process:

  • it is preferred to switch-off compiler optimization for debugging (use -O0 in compiler settings in Makefile for given architecture)
  • install GCC Arm Embedded toolchain [8] (recommended anyway for Paparazzi since v 5.0)
  • get Black Magic probe from Blacksphere [9], it will make your life easier
  • in Creating a GDB Debug Configuration use the following commands for Black Magic Probe:
target extended-remote /dev/ttyACM0
monitor jtag_scan
attach 1
monitor vector_catch disable hard
set mem inaccessible-by-default off
monitor option erase
set print pretty

(for Lisa/Lia F4 board use swdp_scan instead of jtag_scan)

  • if you are using luftboot, don't forget to add image offset into the debug configuration:

Rt paparazzi eclipse setup 2.png

  • don't forget in "Eclipse->Window->Preferences->Run/Debug->Launching->Default Launchers->GDB Hardware Debugging" set preferred launcher to "Standard GDB" (otherwise the ChibiOS/RT plugin won't work, tested in Eclipse Kepler Service Release 1):

Rt paparazzi eclipse setup 1.png

ChibiOS Eclipse plugin

ChibiStudio plugin is officially supported for Windows only (write to the ChibiOS forum if you would like Linux support too), but since it is in Java it works under Linux too. If you want to test it yourself, here is the HOWTO:

  • Get the latest eclipse (Version: Mars.2 Release (4.5.2))
  • Install C/C++ Hardware Debugging as described here
  • Make sure you have gcc-arm-none-eabi installed (v.4.9)
  • Download latest ChibiStudi (preview 17) from here extract it and from ChibiStudio/eclipse/plugins Copy these libraries into your Eclipse/plugins directory:
   org.chibios.chibistudio.branding_1.0.0.jar
   org.chibios.tools.eclipse.config_1.9.1.201603121101.jar
   org.chibios.tools.eclipse.debug.chibiosrt2_1.2.0.201603121101.jar
   org.chibios.tools.eclipse.debug.chibiosrt3_1.0.1.201603121101.jar
   org.chibios.tools.eclipse.debug.chibiosrt4_1.0.0.201603121101.jar
  • Restart Eclipse - now you will see the ChibiOs plugings under Help->Installation Details->Plugins
  • Enable the plug-in while in the "Debug" view under: Window->Show View->Other...->ChibiOS/RT->ChibiOS/RT" (see [10] for details)

Now you can use ChibiStudio plugin to view your threads memory usage, available stack, trace buffer etc. depending on the debugging options you enabled.

ChibiOS Tutorials

Related videos about setting up Eclipse with ChibiOS plugins (called together ChibiStudio) are available here

Compiling Paparazzi code in Eclipse

Typical process consists of compiling the autopilot code for given airframe in Paparazzi center, and then running the related debug configuration in Eclipse. The debugger will first recompile whole Paparazzi (e.g. running "make" in Paparazzi home directory), which is not really useful, but bearable.

In case we want to work with a single aircraft and want Eclipse to also compile the autopilot code, we have to do the following:

  1. Import paparazzi into eclipse as normal
  2. in project->properties->c/c++->environment add three variables
    1. Current_Airframe: set to the name of the airframe you want to build
    2. PAPARAZZI_HOME: set to the root paparazzi directory
    3. PAPARAZZI_SRC: set to the root paparazzi directory
  3. in project->properties->c/c++
    1. in Builder Settings Tab
      1. Uncheck Use default build command
      2. in build command put: make -f Makefile.ac AIRCRAFT=${Current_Airframe}
    2. In Behavior Tab
      1. set the Build field to: ap.compile
      2. set the Clean field to:clean_ac

That will compile Current_Aiframe with target ac. Obviously, if you need a different target, for example test_telemetry, you will have to change the last two steps to test_telemetry.compile and so on.