Difference between revisions of "HITL"

From PaparazziUAV
Jump to navigation Jump to search
(simulation category)
Line 1: Line 1:
<categorytree style="float:right; clear:right; margin-left:1ex; border: 1px solid gray; padding: 0.7ex;" mode=pages>Simulation</categorytree>
__TOC__
=Hardware In The Loop Simulation=
=Hardware In The Loop Simulation=


Line 50: Line 53:
The port to use for the '''link''' agent is then <tt>/dev/ttyACM0</tt>
The port to use for the '''link''' agent is then <tt>/dev/ttyACM0</tt>


[[Category:Software]] [[Category:Hardware]] [[Category:Developer_Documentation]]
[[Category:Simulation]] [[Category:Software]] [[Category:Hardware]] [[Category:Developer_Documentation]]

Revision as of 08:18, 22 January 2013

Hardware In The Loop Simulation

Principle

While the Software In The Loop simulation (SITL) executes the airborne code on the ground host, HITL is a way to run the autopilot code on the actual hardware in an environment where sensors and actuators are simulated. Two processes are involved:

  • The real autopilot code on the control board;
  • A flight model combined with a model of the actuators and the sensors.

Commands computed by the autopilot are sent to the flight model which sends back simulated values of the sensors output (e.g infrared and GPS).

In Paparazzi, the link between the two processes is done through the telemetry/datalink:

  • Commands are sent through the standard COMMANDS telemetry message. Since the refresh rate must be high enough, a special telemetry file will be used (settings/hitl.xml)
  • Sensor values are sent through the HITL_UBX (GPS) and HITL_INFRARED datalink messages.

Configuration

The airborne code has to be compiled with a specific flag to use these HITL messages instead of the sensors. The following line must be added in the makefile section of the airframe file (here for a Tiny 1 board where the modem is plugged to the UART0):

ap.CFLAGS += -DHITL -UGPS_CONFIGURE -UUART0_BAUD -DUART0_BAUD=B57600

Note that a high baudrate (at least 57600) is required to allow the COMMANDS messages to be correctly transmitted.

The code has to be compiled (ap target) as usual and uploaded to the board. The HITL A/C entry provides an example of configuration for a Tiny 1 board (set UART1_BAUD for a Tiny 2).

<aircraft name="HITL" ac_id="7"
 airframe="airframes/tiny_hitl.xml"
 telemetry="telemetry/hitl.xml"
 ...
/>

The HITL session entry gives an example of the corresponding session involving the simhitl simulator agent, ran with the -ac HITL option (the name of the simulated aircraft), and the standard link, server and GCS. The link can be done with a serial cable (probably through USB) or with the installed modem.

<session name="HITL">
 <program name="Hardware in the Loop">
  <arg flag="-a" constant="HITL"/>
  <arg flag="-noground"/>
  <arg flag="-boot"/>
 </program>
 <program name="Data Link">
  <arg flag="-s" constant="57600"/>
 </program>
</session>

Datalink through the USB link

As explained in this page, the USB link (used to flash the board) can replace the serial link. It is probably the easiest way to run a HITL session since a single cable is required between the host and the board. Using a USB powered developement board (such as this one), HITL simulation becomes as easy as the SITL one.

The hitl_usb.xml airframe file contains a minimal configuration (it is worth noticing that the useless servos section has been removed in this file) of HITL with serial USB. The specific lines of the makefile section are:

ap.CFLAGS += -DDOWNLINK -DDOWNLINK_TRANSPORT=PprzTransport -DUSE_USB_SERIAL
ap.CFLAGS += -DDOWNLINK_FBW_DEVICE=UsbS -DDOWNLINK_AP_DEVICE=UsbS -DPPRZ_UART=UsbS -DDATALINK=PPRZ
ap.srcs += downlink.c $(SRC_ARCH)/uart_hw.c $(SRC_ARCH)/usb_ser_hw.c datalink.c pprz_transport.c
ap.srcs += $(SRC_ARCH)/lpcusb/usbhw_lpc.c $(SRC_ARCH)/lpcusb/usbcontrol.c
ap.srcs += $(SRC_ARCH)/lpcusb/usbstdreq.c $(SRC_ARCH)/lpcusb/usbinit.c
ap.CFLAGS += -DHITL

Compile it and flash it as usual.

The port to use for the link agent is then /dev/ttyACM0