Skip to content

Commit

Permalink
First shot towards a separate HITL target (#2062)
Browse files Browse the repository at this point in the history
* First shot towards a separate HITL target

* Changes in HITL - still doesn't compile

* Added makefile selection

* HITL target works for fixedwing and rotorcraft - still needs cleanup and TLC

* Removed info messages from compilation process
  • Loading branch information
podhrmic committed Jun 13, 2017
1 parent 9d1e71b commit 74f8b74
Show file tree
Hide file tree
Showing 43 changed files with 163 additions and 137 deletions.
4 changes: 4 additions & 0 deletions conf/Makefile.hitl
@@ -0,0 +1,4 @@
$(TARGET).CFLAGS += $(nps.CFLAGS)
$(TARGET).srcs += $(nps.srcs)
$(TARGET).LDFLAGS += $(nps.LDFLAGS)
include $(PAPARAZZI_SRC)/conf/Makefile.nps
1 change: 0 additions & 1 deletion conf/Makefile.nps
Expand Up @@ -23,7 +23,6 @@
#
# This is the common Makefile for the nps target.
#

SRC_ARCH = arch/sim

OPT ?= 2
Expand Down
11 changes: 8 additions & 3 deletions conf/airframes/AGGIEAIR/aggieair_ark_hexa_1-8.xml
Expand Up @@ -24,7 +24,12 @@ Aggie Air ARK
<target name="nps" board="pc">
<module name="fdm" type="jsbsim"/>
<module name="radio_control" type="spektrum"/>
<!--configure name="USE_HITL" value="1"/-->
</target>

<target name="hitl" board="pc">
<module name="fdm" type="jsbsim"/>
<module name="imu" type="nps"/>
<module name="radio_control" type="spektrum"/>
<configure name="INS_DEV" value="/dev/ttyUSB1"/>
<configure name="INS_BAUD" value="B921600"/>
<configure name="AP_DEV" value="/dev/ttyUSB2"/>
Expand Down Expand Up @@ -61,13 +66,13 @@ Aggie Air ARK
<module name="lidar_sf11">
<configure name="LIDAR_SF11_I2C_DEV" value="i2c2"/>
</module>
<module name="battery_monitor.xml">
<!--module name="battery_monitor.xml">
<define name="BATMON_REV4" value="0"/>
<define name="BATMON_CURRENT_OFFSET" value="-120"/>
<define name="BATMON_CURRENT_SENSITIVITY" value="25.6"/>
<define name="BATMON_TEMP_OFFSET" value="250"/>
<define name="BATMON_TEMP_SENSITIVITY" value="10"/>
</module>
</module-->
</modules>

<!--These values are set for the Castle Creations HV Lite 60A ESCs-->
Expand Down
6 changes: 3 additions & 3 deletions conf/airframes/AGGIEAIR/aggieair_conf.xml
Expand Up @@ -3,11 +3,11 @@
name="Ark_Hexa_1.8"
ac_id="4"
airframe="airframes/AGGIEAIR/aggieair_ark_hexa_1-8.xml"
radio="radios/AGGIEAIR/aggieair_taranis.xml"
radio="radios/AGGIEAIR/aggieair_sbus_fakerator.xml"
telemetry="telemetry/AGGIEAIR/aggieair_rotorcraft.xml"
flight_plan="flight_plans/rotorcraft_basic_geofence.xml"
settings="settings/rotorcraft_basic.xml settings/nps.xml"
settings_modules="modules/battery_monitor.xml modules/lidar_sf11.xml modules/gps.xml modules/stabilization_float_euler.xml modules/nav_basic_rotorcraft.xml modules/guidance_rotorcraft.xml"
settings_modules="modules/lidar_sf11.xml modules/gps.xml modules/stabilization_float_euler.xml modules/nav_basic_rotorcraft.xml modules/guidance_rotorcraft.xml modules/imu_common.xml"
gui_color="#ffff954c0000"
/>
<aircraft
Expand Down Expand Up @@ -58,7 +58,7 @@
name="Minion_RP3"
ac_id="1"
airframe="airframes/AGGIEAIR/aggieair_minion_rp3_lia.xml"
radio="radios/AGGIEAIR/aggieair_taranis.xml"
radio="radios/AGGIEAIR/aggieair_sbus_fakerator.xml"
telemetry="telemetry/AGGIEAIR/aggieair_fixedwing.xml"
flight_plan="flight_plans/AGGIEAIR/BasicTuning_Launcher.xml"
settings="settings/fixedwing_basic.xml settings/nps.xml"
Expand Down
2 changes: 2 additions & 0 deletions conf/airframes/AGGIEAIR/aggieair_control_panel.xml
Expand Up @@ -189,6 +189,7 @@
<arg flag="-f" constant="127.0.0.1"/>
<arg flag="-b" constant="127.255.255.255"/>
<arg flag="--fg_fdm" constant=""/>
<arg flag="-t" constant="hitl"/>
</program>
<program name="Sbus Fakerator">
<arg flag="-p" constant="/dev/ttyUSB3"/>
Expand All @@ -210,6 +211,7 @@
<arg flag="-f" constant="127.0.0.1"/>
<arg flag="-b" constant="127.255.255.255"/>
<arg flag="--fg_fdm" constant=""/>
<arg flag="-t" constant="hitl"/>
</program>
<program name="Sbus Fakerator">
<arg flag="-p" constant="/dev/ttyUSB3"/>
Expand Down
6 changes: 5 additions & 1 deletion conf/airframes/AGGIEAIR/aggieair_minion_rp3_lia.xml
Expand Up @@ -25,7 +25,11 @@ AggieAir RP3 Minion
<target name="nps" board="pc">
<module name="fdm" type="jsbsim"/>
<module name="radio_control" type="spektrum"/>
<configure name="USE_HITL" value="1"/>
</target>

<target name="hitl" board="pc">
<module name="fdm" type="jsbsim"/>
<module name="radio_control" type="spektrum"/>
<configure name="INS_DEV" value="/dev/ttyUSB1"/>
<configure name="INS_BAUD" value="B921600"/>
<configure name="AP_DEV" value="/dev/ttyUSB2"/>
Expand Down
8 changes: 6 additions & 2 deletions conf/firmwares/rotorcraft.makefile
Expand Up @@ -218,6 +218,10 @@ fbw.srcs += $(ns_srcs)
##
## include firmware independent nps makefile and add rotorcraft specifics
##
include $(CFG_SHARED)/nps.makefile
nps.srcs += nps/nps_autopilot_rotorcraft.c
ifneq ($(TARGET), hitl)
include $(CFG_SHARED)/nps.makefile
else
include $(CFG_SHARED)/hitl.makefile
endif

nps.srcs += nps/nps_autopilot_rotorcraft.c
6 changes: 5 additions & 1 deletion conf/firmwares/subsystems/fixedwing/autopilot.makefile
Expand Up @@ -247,7 +247,11 @@ ap.srcs += $(ap_srcs) $(ns_srcs)
##
## include firmware independent nps makefile and add fixedwing specifics
##
include $(CFG_SHARED)/nps.makefile
ifneq ($(TARGET), hitl)
include $(CFG_SHARED)/nps.makefile
else
include $(CFG_SHARED)/hitl.makefile
endif
nps.srcs += nps/nps_autopilot_fixedwing.c

# add normal ap and fbw sources
Expand Down
6 changes: 5 additions & 1 deletion conf/firmwares/subsystems/shared/baro_board.makefile
Expand Up @@ -281,11 +281,15 @@ endif
ap.CFLAGS += $(BARO_BOARD_CFLAGS)
ap.srcs += $(BARO_BOARD_SRCS)

# don't use for NPS
# don't use for NPS or HITL
ifeq ($(TARGET),nps)
$(TARGET).CFLAGS += -DUSE_BARO_BOARD=FALSE
endif

ifeq ($(TARGET),hitl)
$(TARGET).CFLAGS += -DUSE_BARO_BOARD=FALSE
endif

else # USE_BARO_BOARD is not TRUE, was explicitly disabled

ap.CFLAGS += -DUSE_BARO_BOARD=FALSE
Expand Down
Expand Up @@ -5,17 +5,17 @@
#
# HITL specific makefile
#
# include Makefile.nps instead of Makefile.sim
hitl.MAKEFILE = hitl

include $(CFG_SHARED)/nps_common.makefile

nps.srcs += $(NPSDIR)/nps_main_hitl.c

# TODO: have this in ins_vectornav.xml
# will hopefully work better once nps and HITL are separate targets
nps.srcs += $(NPSDIR)/nps_ins_vectornav.c

# 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)

INS_DEV ?= \"/dev/ttyUSB1\"
INS_BAUD ?= B921600

Expand All @@ -26,3 +26,4 @@ nps.CFLAGS += -DAP_DEV=\"$(AP_DEV)\"
nps.CFLAGS += -DAP_BAUD=$(AP_BAUD)
nps.CFLAGS += -DINS_DEV=\"$(INS_DEV)\"
nps.CFLAGS += -DINS_BAUD=$(INS_BAUD)

68 changes: 4 additions & 64 deletions conf/firmwares/subsystems/shared/nps.makefile
@@ -1,71 +1,11 @@
# Hey Emacs, this is a -*- makefile -*-

#
# NPS Simulator
# NPS SITL Simulator
#
# Common makefile for both SITL/HITL simulation
# SITL specific makefile
#
# still needs a FDM backend to be specified, e.g.
# <subsystem name="fdm" type="jsbsim"/>
#

USE_HITL ?= 0

nps.ARCHDIR = sim

# include Makefile.nps instead of Makefile.sim
nps.MAKEFILE = nps

nps.CFLAGS += -DSITL -DUSE_NPS
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

nps.CFLAGS += -I$(SRC_FIRMWARE) -I$(SRC_BOARD) -I$(PAPARAZZI_SRC)/sw/simulator -I$(PAPARAZZI_SRC)/sw/simulator/nps -I$(PAPARAZZI_HOME)/conf/simulator/nps

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


#
# add the simulator directory to the make searchpath
#
VPATH += $(PAPARAZZI_SRC)/sw/simulator

NPSDIR = nps
nps.srcs += \
$(NPSDIR)/nps_random.c \
$(NPSDIR)/nps_sensors.c \
$(NPSDIR)/nps_sensors_utils.c \
$(NPSDIR)/nps_sensor_gyro.c \
$(NPSDIR)/nps_sensor_accel.c \
$(NPSDIR)/nps_sensor_mag.c \
$(NPSDIR)/nps_sensor_baro.c \
$(NPSDIR)/nps_sensor_sonar.c \
$(NPSDIR)/nps_sensor_gps.c \
$(NPSDIR)/nps_sensor_airspeed.c \
$(NPSDIR)/nps_sensor_temperature.c \
$(NPSDIR)/nps_sensor_aoa.c \
$(NPSDIR)/nps_sensor_sideslip.c \
$(NPSDIR)/nps_electrical.c \
$(NPSDIR)/nps_atmosphere.c \
$(NPSDIR)/nps_ivy.c \
$(NPSDIR)/nps_flightgear.c \
$(NPSDIR)/nps_radio_control.c \
$(NPSDIR)/nps_radio_control_joystick.c \
$(NPSDIR)/nps_radio_control_spektrum.c \
$(NPSDIR)/nps_main_common.c

ifeq ($(USE_HITL),1)
include $(CFG_SHARED)/nps_hitl.makefile
else
include $(CFG_SHARED)/nps_sitl.makefile
endif

# for geo mag calculation
nps.srcs += math/pprz_geodetic_wmm2015.c

include $(CFG_SHARED)/nps_common.makefile
nps.srcs += $(NPSDIR)/nps_main_sitl.c
63 changes: 63 additions & 0 deletions conf/firmwares/subsystems/shared/nps_common.makefile
@@ -0,0 +1,63 @@
# Hey Emacs, this is a -*- makefile -*-

#
# NPS Simulator
#
# Common makefile for both SITL/HITL simulation
#
# still needs a FDM backend to be specified, e.g.
# <subsystem name="fdm" type="jsbsim"/>
#

nps.ARCHDIR = sim

nps.CFLAGS += -DSITL -DUSE_NPS
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

nps.CFLAGS += -I$(SRC_FIRMWARE) -I$(SRC_BOARD) -I$(PAPARAZZI_SRC)/sw/simulator -I$(PAPARAZZI_SRC)/sw/simulator/nps -I$(PAPARAZZI_HOME)/conf/simulator/nps

# 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

NPSDIR = nps
nps.srcs += \
$(NPSDIR)/nps_random.c \
$(NPSDIR)/nps_sensors.c \
$(NPSDIR)/nps_sensors_utils.c \
$(NPSDIR)/nps_sensor_gyro.c \
$(NPSDIR)/nps_sensor_accel.c \
$(NPSDIR)/nps_sensor_mag.c \
$(NPSDIR)/nps_sensor_baro.c \
$(NPSDIR)/nps_sensor_sonar.c \
$(NPSDIR)/nps_sensor_gps.c \
$(NPSDIR)/nps_sensor_airspeed.c \
$(NPSDIR)/nps_sensor_temperature.c \
$(NPSDIR)/nps_sensor_aoa.c \
$(NPSDIR)/nps_sensor_sideslip.c \
$(NPSDIR)/nps_electrical.c \
$(NPSDIR)/nps_atmosphere.c \
$(NPSDIR)/nps_ivy.c \
$(NPSDIR)/nps_flightgear.c \
$(NPSDIR)/nps_radio_control.c \
$(NPSDIR)/nps_radio_control_joystick.c \
$(NPSDIR)/nps_radio_control_spektrum.c \
$(NPSDIR)/nps_main_common.c

# for geo mag calculation
nps.srcs += math/pprz_geodetic_wmm2015.c

13 changes: 0 additions & 13 deletions conf/firmwares/subsystems/shared/nps_sitl.makefile

This file was deleted.

4 changes: 4 additions & 0 deletions conf/firmwares/subsystems/shared/uart.makefile
Expand Up @@ -12,6 +12,10 @@ ifeq ($(TARGET), nps)
UART_CFLAGS += -Iarch/linux
UART_SRCS += arch/linux/serial_port.c
endif
ifeq ($(TARGET), hitl)
UART_CFLAGS += -Iarch/linux
UART_SRCS += arch/linux/serial_port.c
endif
ifeq ($(TARGET), sim)
UART_CFLAGS += -Iarch/linux
UART_SRCS += arch/linux/serial_port.c
Expand Down
4 changes: 4 additions & 0 deletions conf/firmwares/subsystems/shared/udp.makefile
Expand Up @@ -13,6 +13,10 @@ ifeq ($(TARGET), nps)
UDP_CFLAGS += -Iarch/linux
UDP_SRCS += arch/linux/udp_socket.c
endif
ifeq ($(TARGET), hitl)
UDP_CFLAGS += -Iarch/linux
UDP_SRCS += arch/linux/udp_socket.c
endif

$(TARGET).CFLAGS += $(UDP_CFLAGS)
$(TARGET).srcs += $(UDP_SRCS)
Expand Down
2 changes: 1 addition & 1 deletion conf/modules/fdm_jsbsim.xml
Expand Up @@ -14,7 +14,7 @@
<configure name="JSBSIM_ROOT" value="/opt/jsbsim" description="set root directory for JSBSim library when auto-detection (see FIND_JSBSIM_VIA_PKG_CONFIG) is not used (default path: /opt/jsbsim)"/>
</doc>
<header/>
<makefile target="nps">
<makefile target="nps|hitl">
<configure name="JSBSIM_ROOT" default="/opt/jsbsim"/>
<configure name="JSBSIM_INC" value="$(JSBSIM_ROOT)/include/JSBSim"/>
<configure name="JSBSIM_LIB" value="$(JSBSIM_ROOT)/lib"/>
Expand Down
2 changes: 1 addition & 1 deletion conf/modules/gps_nps.xml
Expand Up @@ -14,7 +14,7 @@
</header>
<init fun="gps_nps_init()"/>
<periodic fun="gps_nps_periodic_check()" freq="1." autorun="TRUE"/>
<makefile target="nps">
<makefile target="nps|hitl">
<file name="gps_sim_nps.c" dir="subsystems/gps"/>
<define name="GPS_TYPE_H" value="subsystems/gps/gps_sim_nps.h" type="string"/>
</makefile>
Expand Down
2 changes: 1 addition & 1 deletion conf/modules/guidance_basic_fw.xml
Expand Up @@ -50,7 +50,7 @@
<file name="guidance_h.h"/>
</header>
<init fun="v_ctl_init()"/>
<makefile target="ap|sim|nps" firmware="fixedwing">
<makefile target="ap|sim|nps|hitl" firmware="fixedwing">
<file name="guidance_v.c" dir="$(SRC_FIRMWARE)/guidance"/>
<file name="guidance_h.c" dir="$(SRC_FIRMWARE)/guidance"/>
<define name="CTRL_TYPE_H" value="firmwares/fixedwing/guidance/guidance_v.h" type="string"/>
Expand Down
2 changes: 1 addition & 1 deletion conf/modules/guidance_rotorcraft.xml
Expand Up @@ -56,7 +56,7 @@
</header>
<init fun="guidance_h_init()"/>
<init fun="guidance_v_init()"/>
<makefile target="ap|nps" firmware="rotorcraft">
<makefile target="ap|nps|hitl" firmware="rotorcraft">
<file name="guidance_h.c" dir="$(SRC_FIRMWARE)/guidance"/>
<file name="guidance_h_ref.c" dir="$(SRC_FIRMWARE)/guidance"/>
<file name="guidance_v.c" dir="$(SRC_FIRMWARE)/guidance"/>
Expand Down
2 changes: 1 addition & 1 deletion conf/modules/imu_aspirin_v2.2.xml
Expand Up @@ -11,7 +11,7 @@
</description>
</doc>
<autoload name="imu_aspirin_v2_common"/>
<makefile target="!sim|nps|fbw">
<makefile target="!sim|nps|fbw|hitl">
<!-- SLAVE3 is on PC13, which is the baro CS -->
<define name="DUSE_SPI_SLAVE3"/>
</makefile>
Expand Down
2 changes: 1 addition & 1 deletion conf/modules/imu_aspirin_v2_common.xml
Expand Up @@ -28,7 +28,7 @@
<init fun="imu_aspirin2_init()"/>
<periodic fun="imu_aspirin2_periodic()"/>
<event fun="imu_aspirin2_event()"/>
<makefile target="!sim|nps|fbw">
<makefile target="!sim|nps|fbw|hitl">
<!-- default for stm32, do we want to provide i2c0,spi1,SPI_SLAVE0 defaults for lpc again?-->
<configure name="ASPIRIN_2_SPI_DEV" default="spi2" case="lower|upper"/>
<configure name="ASPIRIN_2_SPI_SLAVE_IDX" default="SPI_SLAVE2"/>
Expand Down

0 comments on commit 74f8b74

Please sign in to comment.