<!DOCTYPE module SYSTEM "module.dtd">

<module name="nps" dir="simulator">
  <doc>
    <description>
      New Paparazzi Simulator (NPS)

      Bindings between embedded autopilot code and a flight dynamic model (FDM).
      Possible FDM are: JSBSim or CRRCSIM, see corresponding modules.
      Can run Software In The Loop (SITL) or Hardware In The Loop (HITL) simulations.
    </description>
    <configure name="USE_HITL" value="0|1" description="run as SITL (0:default) or HITL (1) simulation"/>
  </doc>
  <header/>
  <makefile target="nps|hitl">
    <flag name="ARCHDIR" value="sim"/>
    <define name="SITL"/>
    <define name="USE_NPS"/>
    <raw>
      nps.LDFLAGS += -lm -livy $(shell pcre-config --libs) -lgsl -lgslcblas
      
      # detect system arch and include rt and pthread library only on linux
      UNAME_S := $(shell uname -s)
      ifeq ($(UNAME_S),Linux)
      nps.LDFLAGS += -lrt -pthread
      endif

      # sdl needed for joystick input
      nps.LDFLAGS += $(shell sdl-config --libs)

      # glib is still needed for some components (such as radio input)
      nps.CFLAGS  += $(shell pkg-config glib-2.0 --cflags)
      nps.LDFLAGS += $(shell pkg-config glib-2.0 --libs)

      #
      # add the simulator directory to the make searchpath
      #
      VPATH += $(PAPARAZZI_SRC)/sw/simulator
    </raw>
    <include name="$(SRC_FIRMWARE)"/>
    <include name="$(SRC_BOARD)"/>
    <include name="$(PAPARAZZI_SRC)/sw/simulator"/>
    <include name="$(PAPARAZZI_SRC)/sw/simulator/nps"/>
    <include name="$(PAPARAZZI_HOME)/conf/simulator/nps"/>
    <file name="nps_random.c" dir="nps"/>
    <file name="nps_sensors.c" dir="nps"/>
    <file name="nps_sensors_utils.c" dir="nps"/>
    <file name="nps_sensor_gyro.c" dir="nps"/>
    <file name="nps_sensor_accel.c" dir="nps"/>
    <file name="nps_sensor_mag.c" dir="nps"/>
    <file name="nps_sensor_baro.c" dir="nps"/>
    <file name="nps_sensor_sonar.c" dir="nps"/>
    <file name="nps_sensor_gps.c" dir="nps"/>
    <file name="nps_sensor_airspeed.c" dir="nps"/>
    <file name="nps_sensor_temperature.c" dir="nps"/>
    <file name="nps_sensor_aoa.c" dir="nps"/>
    <file name="nps_sensor_sideslip.c" dir="nps"/>
    <file name="nps_electrical.c" dir="nps"/>
    <file name="nps_atmosphere.c" dir="nps"/>
    <file name="nps_ivy.c" dir="nps"/>
    <file name="nps_flightgear.c" dir="nps"/>
    <file name="nps_radio_control.c" dir="nps"/>
    <file name="nps_radio_control_joystick.c" dir="nps"/>
    <file name="nps_radio_control_spektrum.c" dir="nps"/>
    <file name="nps_main_common.c" dir="nps"/>
    <file name="math/pprz_geodetic_wmm2015.c" dir="math"/>
  </makefile>

  <makefile target="nps">
    <flag name="MAKEFILE" value="nps"/>
    <file name="nps_main_sitl.c" dir="nps"/>
  </makefile>
  <makefile target="hitl">
    <flag name="MAKEFILE" value="hitl"/>
    <configure name="INS_DEV" default="/dev/ttyUSB1"/>
    <configure name="INS_BAUD" default="B921600"/>
    <configure name="AP_DEV" default="/dev/ttyUSB2"/>
    <configure name="AP_BAUD" default="B921600"/>
    <define name="INS_DEV" value="$(INS_DEV)" type="string"/>
    <define name="INS_BAUD" value="$(INS_BAUD)"/>
    <define name="AP_DEV" value="$(AP_DEV)" type="string"/>
    <define name="AP_BAUD" value="$(AP_BAUD)"/>
    <file name="nps_main_hitl.c" dir="nps"/>
    <file name="nps_ins_vectornav.c" dir="nps"/>
  </makefile>

  <makefile target="nps|hitl" firmware="fixedwing">
    <file name="nps_autopilot_fixedwing" dir="nps"/>
  </makefile>
  <makefile target="nps|hitl" firmware="rotorcraft">
    <file name="nps_autopilot_rotorcraft" dir="nps"/>
  </makefile>
</module>


