Showing with 986 additions and 2,424 deletions.
  1. +1 −7 Makefile
  2. +1 −158 conf/Makefile.sim
  3. +2 −0 conf/airframes/examples/cube_orange.xml
  4. +2 −0 conf/airframes/tudelft/bebop_indi.xml
  5. +1 −0 conf/airframes/tudelft/nederdrone4.xml
  6. +4 −5 conf/airframes/tudelft/rot_wing_25kg.xml
  7. +1 −1 conf/conf_tests.xml
  8. +1 −1 conf/modules/actuators_nps.xml
  9. +3 −1 conf/modules/electrical.xml
  10. +19 −0 conf/modules/fdm_fixedwing_sim.xml
  11. +1 −1 conf/modules/firmwares/fixedwing.xml
  12. +1 −1 conf/modules/gps_nps.xml
  13. +1 −1 conf/modules/imu_common.xml
  14. +1 −1 conf/modules/imu_nps.xml
  15. +0 −3 conf/modules/ins_arduimu.xml
  16. +0 −3 conf/modules/ins_arduimu_basic.xml
  17. +2 −2 conf/modules/ins_nps.xml
  18. +1 −1 conf/modules/nav_hybrid.xml
  19. +33 −0 conf/modules/preflight_checks.xml
  20. +0 −1 conf/modules/system_core.xml
  21. +1 −1 conf/modules/targets/nps.xml
  22. +1 −1 conf/modules/targets/nps_common.xml
  23. +1 −18 conf/modules/targets/sim.xml
  24. +1 −1 conf/modules/telemetry_nps.xml
  25. +1 −1 conf/modules/udp.xml
  26. +2 −2 conf/userconf/tudelft/conf.xml
  27. +0 −20 sw/airborne/arch/sim/led_hw.c
  28. +0 −19 sw/airborne/arch/sim/led_hw.h
  29. +1 −29 sw/airborne/arch/sim/modules/radio_control/ppm_arch.c
  30. +0 −35 sw/airborne/arch/sim/modules/radio_control/rc_datalink.c
  31. +0 −34 sw/airborne/arch/sim/modules/radio_control/spektrum_arch.c
  32. +0 −19 sw/airborne/arch/sim/sim_adc_generic.c
  33. +0 −38 sw/airborne/arch/sim/sim_ahrs.c
  34. +0 −17 sw/airborne/arch/sim/sim_airspeed.c
  35. +0 −123 sw/airborne/arch/sim/sim_ap.c
  36. +0 −82 sw/airborne/arch/sim/sim_gps.c
  37. +0 −5 sw/airborne/arch/sim/sim_uart_hw.c
  38. +37 −3 sw/airborne/autopilot.c
  39. +18 −1 sw/airborne/autopilot.h
  40. +1 −1 sw/airborne/boards/ardrone/actuators.c
  41. +1 −1 sw/airborne/boards/bebop/actuators.c
  42. +0 −3 sw/airborne/firmwares/rotorcraft/autopilot_arming_common.h
  43. +5 −5 sw/airborne/firmwares/rotorcraft/autopilot_arming_switch.h
  44. +6 −6 sw/airborne/firmwares/rotorcraft/autopilot_arming_throttle.h
  45. +10 −9 sw/airborne/firmwares/rotorcraft/autopilot_arming_yaw.h
  46. +3 −8 sw/airborne/firmwares/rotorcraft/autopilot_generated.c
  47. +3 −14 sw/airborne/firmwares/rotorcraft/autopilot_static.c
  48. +0 −14 sw/airborne/firmwares/rotorcraft/autopilot_utils.c
  49. +0 −1 sw/airborne/firmwares/rotorcraft/autopilot_utils.h
  50. +2 −2 sw/airborne/firmwares/rotorcraft/navigation.h
  51. +7 −1 sw/airborne/firmwares/rotorcraft/stabilization/stabilization_indi.c
  52. +1 −1 sw/airborne/firmwares/rover/autopilot_generated.c
  53. +0 −15 sw/airborne/firmwares/rover/autopilot_utils.c
  54. +0 −1 sw/airborne/firmwares/rover/autopilot_utils.h
  55. +2 −2 sw/airborne/firmwares/rover/navigation.h
  56. +220 −0 sw/airborne/modules/checks/preflight_checks.c
  57. +54 −0 sw/airborne/modules/checks/preflight_checks.h
  58. +44 −20 sw/airborne/modules/energy/electrical.c
  59. +19 −0 sw/airborne/modules/gps/gps.c
  60. +40 −0 sw/airborne/modules/imu/imu.c
  61. +8 −0 sw/airborne/modules/imu/imu.h
  62. +18 −0 sw/airborne/modules/loggers/sdlog_chibios.c
  63. +1 −1 sw/airborne/modules/nav/nav_rotorcraft_hybrid.h
  64. +21 −0 sw/airborne/modules/sensors/airspeed_ms45xx_i2c.c
  65. +1 −0 sw/airborne/modules/sensors/airspeed_ms45xx_i2c.h
  66. +20 −1 sw/airborne/modules/sonar/agl_dist.c
  67. +19 −0 sw/airborne/state.c
  68. +2 −22 sw/simulator/Makefile
  69. +0 −73 sw/simulator/data.ml
  70. +0 −36 sw/simulator/data.mli
  71. +0 −138 sw/simulator/diffusion.ml
  72. +0 −57 sw/simulator/fg.c
  73. +0 −53 sw/simulator/fg_environment.xml
  74. +0 −280 sw/simulator/flightModel.ml
  75. +0 −53 sw/simulator/flightModel.mli
  76. +0 −81 sw/simulator/gps.ml
  77. +0 −36 sw/simulator/gps.mli
  78. 0 sw/simulator/{ → nps}/flight_gear.h
  79. +1 −1 sw/simulator/nps/nps_fdm.h
  80. +309 −0 sw/simulator/nps/nps_fdm_fixedwing_sim.c
  81. +1 −1 sw/simulator/nps/nps_flightgear.c
  82. +23 −56 sw/simulator/pprzsim-launch
  83. +0 −325 sw/simulator/sim.ml
  84. +0 −26 sw/simulator/sim.mli
  85. +0 −65 sw/simulator/simlib.ml
  86. +0 −37 sw/simulator/simlib.mli
  87. +0 −14 sw/simulator/simsitl.ml
  88. +0 −221 sw/simulator/sitl.ml
  89. +0 −6 sw/simulator/sitl.mli
  90. +6 −14 sw/supervision/python/session_widget.py
  91. +0 −87 tests/sim/01_Microjet.t
8 changes: 1 addition & 7 deletions Makefile
Expand Up @@ -343,14 +343,8 @@ test_all_confs: all opencv_bebop
test_math:
make -C tests/math

# super simple simulator test, needs X
# always uses conf/conf.xml, so that needs to contain the appropriate aircrafts
# (only Microjet right now)
test_sim: all
prove tests/sim

.PHONY: all print_build_version _print_building _save_build_version init dox ground_segment ground_segment.opt \
subdirs $(SUBDIRS) conf ext libpprz libpprzlink.update libpprzlink.install cockpit cockpit.opt tmtc tmtc.opt generators\
static sim_static opencv_bebop\
clean cleanspaces ab_clean dist_clean distclean dist_clean_irreversible \
test test_examples test_math test_sim test_all_confs
test test_examples test_math test_all_confs
159 changes: 1 addition & 158 deletions conf/Makefile.sim
@@ -1,158 +1 @@
# Hey Emacs, this is a -*- makefile -*-
#
# Copyright (C) 2006 Pascal Brisset, Antoine Drouin
#
# This file is part of paparazzi.
#
# paparazzi is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2, or (at your option)
# any later version.
#
# paparazzi is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with paparazzi; see the file COPYING. If not, write to
# the Free Software Foundation, 59 Temple Place - Suite 330,
# Boston, MA 02111-1307, USA.
#

#
# This is the common Makefile for the sim target.
#

# this should not be needed
SRC_ARCH = arch/sim

include $(PAPARAZZI_SRC)/sw/Makefile.ocaml

CC = gcc
SIMDIR = $(PAPARAZZI_SRC)/sw/simulator
CAMLINCLUDES = -I $(LIBPPRZDIR) -I $(SIMDIR) -I $(OBJDIR)
PKG = -package glibivy,pprz
LINKPKG = $(PKG) -linkpkg -dllpath-pkg pprz,pprzlink
SIMSITLML = $(OBJDIR)/simsitl.ml
SITLCMA = $(SIMDIR)/sitl.cma
OPT ?= 2

# Launch with "make Q=''" to get full command display
Q=@

#
# End of configuration part.
#

INCLUDES += -I $(shell $(OCAMLC) -where)

CFLAGS = -W -Wall
CFLAGS += $(INCLUDES)
CFLAGS += $($(TARGET).CFLAGS)
CFLAGS += $(USER_CFLAGS) $(BOARD_CFLAGS)
CFLAGS += -fPIC
CFLAGS += -O$(OPT)
CFLAGS += -g
CFLAGS += -std=gnu99
CFLAGS += $(shell pkg-config --cflags-only-I ivy-glib)
CFLAGS += -D_GNU_SOURCE
CFLAGS += -DPPRZLINK_UNALIGNED_ACCESS=1

LDFLAGS = -lm
LDFLAGS += $(BOARD_LDFLAGS)

LIBFLAGS = -shared

UNAME = $(shell uname -s)
ifeq ($(UNAME),Darwin)
LIBFLAGS = -dynamiclib -undefined suppress -flat_namespace
endif

# build sim in custom mode for ARM systems for now...
MNAME = $(shell uname -m)
ifneq (,$(findstring arm,$(MNAME)))
SIMSITLCUSTOM=TRUE
endif

ifdef SIMSITLCUSTOM
CAMLINCLUDES += $(shell ocamlfind query -r -i-format lablgtk2) $(shell ocamlfind query -r -i-format xml-light) $(shell ocamlfind query -r -i-format glibivy)
CAMLCMAS = unix.cma str.cma xml-light.cma glibivy-ocaml.cma lib-pprz.cma lablgtk.cma
endif


#
# General rules
#

$(TARGET).srcsnd = $(notdir $($(TARGET).srcs))
$(TARGET).objso = $($(TARGET).srcs:%.c=$(OBJDIR)/%.o)
$(TARGET).objs = $($(TARGET).objso:%.S=$(OBJDIR)/%.o)

all compile: $(OBJDIR) $(OBJDIR)/simsitl

$(OBJDIR):
@echo CREATING object dir $(OBJDIR)
@test -d $(OBJDIR) || mkdir -p $(OBJDIR)

# shared library of the C autopilot part
# Note: On darwin the file should actually have the .dylib ending but ocamlc
# only assumes that .so files are shared libraries, even though this is only
# correct on linux.
autopilot.so : $($(TARGET).objs)
@echo BUILD $@
$(Q)$(CC) $(LIBFLAGS) $^ -o $(OBJDIR)/$@

ifdef SIMSITLCUSTOM
$(OBJDIR)/simsitl : $($(TARGET).objs) $(SITLCMA) $(SIMSITLML)
@echo LD $@
$(Q)$(OCAMLC) -g -custom $(CAMLINCLUDES) -o $@ $(CAMLCMAS) $^
else
$(OBJDIR)/simsitl : autopilot.so $(SITLCMA) $(SIMSITLML)
@echo LD $@
$(Q)$(OCAMLC) -g $(CAMLINCLUDES) -o $@ $(LINKPKG) $^ -dllpath $(OBJDIR) -dllpath $(SIMDIR)
endif


# The id of the A/C is hardcoded in the code (to be improved with dynlink ?)
$(SIMSITLML) : $(SIMDIR)/simsitl.ml
@echo "Sim.ac_name := \"$(AIRCRAFT)\"" > $@
@cat $< >> $@

%.s: %.c
$(CC) $(CFLAGS) -S -o $@ $<

%.s: %.cpp
$(CC) $(CFLAGS) -S -o $@ $<

$(OBJDIR)/%.s: %.c
@echo CC $@
$(Q)test -d $(dir $@) || mkdir -p $(dir $@)
$(CC) $(CFLAGS) -S -o $@ $<

$(OBJDIR)/%.s: %.cpp
@echo CC $@
$(Q)test -d $(dir $@) || mkdir -p $(dir $@)
$(CC) $(CFLAGS) -S -o $@ $<

$(OBJDIR)/%.o: %.c $(OBJDIR)/../Makefile.ac
@echo CC $@
$(Q)test -d $(dir $@) || mkdir -p $(dir $@)
$(Q)$(CC) -MMD $(CFLAGS) -c -o $@ $<

$(OBJDIR)/%.o: %.cpp $(OBJDIR)/../Makefile.ac
@echo CC $@
$(Q)test -d $(dir $@) || mkdir -p $(dir $@)
$(Q)$(CC) -MMD $(CFLAGS) -c -o $@ $<

.PHONY: all compile

#
# Dependencies
#

DEPS = $(addprefix $(OBJDIR)/,$($(TARGET).srcs:.c=.d))

ifneq ($(MAKECMDGOALS),clean)
-include $(DEPS)
endif
include $(PAPARAZZI_SRC)/conf/Makefile.nps
2 changes: 2 additions & 0 deletions conf/airframes/examples/cube_orange.xml
Expand Up @@ -73,6 +73,7 @@
<define name="RADIO_KILL_SWITCH" value="0"/>
</target>

<module name="preflight_checks"/>
<module name="telemetry" type="transparent">
<configure name="MODEM_BAUD" value="B115200"/>
<configure name="MODEM_PORT" value="usb_serial"/>
Expand All @@ -89,6 +90,7 @@
<module name="stabilization" type="indi_simple"/>
<module name="stabilization" type="rate_indi"/>
<module name="ins" type="ekf2"/>
<module name="nav" type="hybrid"/>

<module name="air_data"/>

Expand Down
2 changes: 2 additions & 0 deletions conf/airframes/tudelft/bebop_indi.xml
Expand Up @@ -41,6 +41,8 @@
<module name="logger_file">
<define name="LOGGER_FILE_PATH" value="/data/ftp/internal_000"/>
</module>

<module name="preflight_checks"/>
</firmware>


Expand Down
1 change: 1 addition & 0 deletions conf/airframes/tudelft/nederdrone4.xml
Expand Up @@ -82,6 +82,7 @@
<define name="INDI_SCHEDULING_TRIM_ELEVATOR" value="840"/>
<define name="INDI_SCHEDULING_PREF_FLAPS_FACTOR" value="1.0"/>
</module>
<module name="preflight_checks"/>

<!--module name="follow_me">
<define name="FOLLOW_ME_DISTANCE" value="60"/>
Expand Down
9 changes: 4 additions & 5 deletions conf/airframes/tudelft/rot_wing_25kg.xml
Expand Up @@ -24,6 +24,7 @@
<define name="RADIO_KILL_SWITCH" value="RADIO_AUX1"/>
<define name="RADIO_FMODE" value="RADIO_AUX2"/>
<define name="RADIO_FBW_MODE" value="RADIO_AUX3"/>
<define name="RADIO_CONTROL_THRUST_X" value="RADIO_AUX4"/>

<!-- EKF2 configure inputs -->
<define name="INS_EKF2_GYRO_ID" value="IMU_CUBE1_ID"/>
Expand Down Expand Up @@ -109,6 +110,8 @@
<module name="sys_id_doublet"/>
<module name="sys_id_auto_doublets"/>
<module name="ground_detect_sensor"/>
<module name="preflight_checks"/>

</firmware>


Expand Down Expand Up @@ -156,11 +159,6 @@
</commands>


<auto_rc_commands>
<set VALUE="@AUX4" COMMAND="THRUST_X"/>
</auto_rc_commands>


<command_laws>
<let var="th_hold" value="Or(LessThan(RadioControlValues(RADIO_TH_HOLD), -4800), !autopilot_get_motors_on())"/>
<let VAR="servo_hold" VALUE="LessThan(RadioControlValues(RADIO_TH_HOLD), -4800)"/>
Expand Down Expand Up @@ -432,6 +430,7 @@
<define name="CRITIC_BAT_LEVEL" value="37.2" unit="V"/>
<define name="LOW_BAT_LEVEL" value="48.4" unit="V"/>
<define name="MAX_BAT_LEVEL" value="50.4" unit="V"/>
<define name="TAKEOFF_BAT_LEVEL" value="48.4" unit="V"/>
<define name="BAT_NB_CELLS" value="12"/>
</section>

Expand Down
2 changes: 1 addition & 1 deletion conf/conf_tests.xml
Expand Up @@ -7,7 +7,7 @@
telemetry="telemetry/highspeed_rotorcraft.xml"
flight_plan="flight_plans/rotorcraft_basic_geofence.xml"
settings="settings/rotorcraft_basic.xml"
settings_modules="modules/air_data.xml modules/airspeed_ms45xx_i2c.xml modules/electrical.xml modules/gps.xml modules/gps_ublox.xml modules/gps_ubx_ucenter.xml modules/guidance_indi_hybrid.xml modules/guidance_rotorcraft.xml modules/imu_common.xml modules/imu_heater.xml modules/ins_ekf2.xml modules/logger_sd_chibios.xml modules/nav_rotorcraft.xml modules/scheduling_indi_simple.xml modules/stabilization_indi_simple.xml"
settings_modules="modules/air_data.xml modules/airspeed_ms45xx_i2c.xml modules/electrical.xml modules/gps.xml modules/gps_ublox.xml modules/gps_ubx_ucenter.xml modules/guidance_indi_hybrid.xml modules/guidance_rotorcraft.xml modules/imu_common.xml modules/imu_heater.xml modules/ins_ekf2.xml modules/logger_sd_chibios.xml modules/nav_hybrid.xml modules/nav_rotorcraft.xml modules/scheduling_indi_simple.xml modules/stabilization_indi_simple.xml"
gui_color="blue"
/>
<aircraft
Expand Down
2 changes: 1 addition & 1 deletion conf/modules/actuators_nps.xml
Expand Up @@ -10,7 +10,7 @@
<depends>actuators</depends>
<provides>actuators</provides>
</dep>
<makefile target="nps">
<makefile target="sim|nps">
<file_arch name="actuators_pwm_arch.c"/>
</makefile>
</module>
Expand Down
4 changes: 3 additions & 1 deletion conf/modules/electrical.xml
Expand Up @@ -24,7 +24,9 @@
<periodic fun="electrical_periodic()" freq="10"/>
<makefile target="fbw|sim|nps" firmware="fixedwing">
<file name="electrical.c"/>
<test firmware="fixedwing"/>
<test firmware="fixedwing">
<define name="ELECTRICAL_PERIODIC_FREQ" value="10"/>
</test>
</makefile>
<makefile target="ap" firmware="fixedwing" cond="ifeq (,$(findstring $(SEPARATE_FBW),0 FALSE))">
<file name="electrical.c"/>
Expand Down
19 changes: 19 additions & 0 deletions conf/modules/fdm_fixedwing_sim.xml
@@ -0,0 +1,19 @@
<!DOCTYPE module SYSTEM "module.dtd">

<module name="fdm_fixedwing_sim" dir="fdm">
<doc>
<description>
Basic fixedwing FDM for NPS simulator

This flight dynamic model is the copy of the legacy simulator that was written in OCaml.
Its only purpose is to allow to test the flight plans with a very simple airplane model.
</description>
</doc>
<header/>
<makefile target="sim|nps|hitl">
<define name="NPS_BYPASS_AHRS" value="TRUE"/>
<define name="NPS_BYPASS_INS" value="TRUE"/>
<file name="nps_fdm_fixedwing_sim.c" dir="nps"/>
</makefile>
</module>

2 changes: 1 addition & 1 deletion conf/modules/firmwares/fixedwing.xml
Expand Up @@ -28,7 +28,7 @@
<makefile target="!fbw">
<file name="main_ap.c" dir="."/>
</makefile>
<makefile target="nps">
<makefile target="sim|nps">
<define name="AP"/>
<file name="nps_autopilot_fixedwing.c" dir="nps"/>
</makefile>
Expand Down
2 changes: 1 addition & 1 deletion conf/modules/gps_nps.xml
Expand Up @@ -17,7 +17,7 @@
</header>
<init fun="gps_nps_init()"/>
<periodic fun="gps_nps_periodic_check()" freq="1." autorun="TRUE"/>
<makefile target="nps">
<makefile target="sim|nps">
<file name="gps_sim_nps.c"/>
<define name="GPS_TYPE_H" value="modules/gps/gps_sim_nps.h" type="string"/>
<test>
Expand Down
2 changes: 1 addition & 1 deletion conf/modules/imu_common.xml
Expand Up @@ -40,7 +40,7 @@
</header>
<init fun="imu_init()"/>

<makefile target="!sim|fbw">
<makefile target="!fbw">
<define name="USE_IMU"/>
<file name="imu.c"/>
<test/>
Expand Down
2 changes: 1 addition & 1 deletion conf/modules/imu_nps.xml
Expand Up @@ -16,7 +16,7 @@
<init fun="imu_nps_init()"/>
<event fun="imu_nps_event()"/>

<makefile target="nps">
<makefile target="sim|nps">
<file name="imu_nps.c"/>
</makefile>
</module>
3 changes: 0 additions & 3 deletions conf/modules/ins_arduimu.xml
Expand Up @@ -17,8 +17,5 @@
<makefile target="ap">
<file name="ins_arduimu.c"/>
</makefile>
<makefile target="sim">
<file_arch name="ins_arduimu.c"/>
</makefile>
</module>

3 changes: 0 additions & 3 deletions conf/modules/ins_arduimu_basic.xml
Expand Up @@ -29,8 +29,5 @@
<makefile target="ap">
<file name="ins_arduimu_basic.c"/>
</makefile>
<makefile target="sim">
<file_arch name="ins_arduimu_basic.c"/>
</makefile>
</module>

4 changes: 2 additions & 2 deletions conf/modules/ins_nps.xml
Expand Up @@ -14,7 +14,7 @@
<file name="ins_gps_passthrough.h"/>
</header>
<init fun="ins_gps_passthrough_init()"/>
<makefile target="nps">
<makefile target="sim|nps">
<file name="imu.c" dir="modules/imu"/>
<file name="imu_nps.c" dir="modules/imu"/>
<define name="USE_IMU"/>
Expand All @@ -34,7 +34,7 @@
<file name="ins.c"/>
<file name="ins_gps_passthrough.c"/>
</makefile>
<makefile target="nps" firmware="fixedwing">
<makefile target="sim|nps" firmware="fixedwing">
<define name="INS_TYPE_H" value="modules/ins/ins_gps_passthrough.h" type="string"/>
<file name="ins.c"/>
<file name="ins_gps_passthrough_utm.c"/>
Expand Down
2 changes: 1 addition & 1 deletion conf/modules/nav_hybrid.xml
Expand Up @@ -20,7 +20,7 @@
<dl_settings>
<dl_settings NAME="nav_hybrid">
<dl_setting var="nav_max_speed" min="1.0" step="1.0" max="50.0"/>
<dl_setting var="nav_hover_speed" min="0.1" step="0.1" max="10.0"/>
<dl_setting var="nav_goto_speed" min="0.1" step="0.1" max="10.0"/>
<dl_setting var="nav_max_deceleration_sp" min="0.5" step="0.1" max="10.0" shortname="max_deceleration" param="NAV_HYBRID_MAX_DECELERATION"/>
</dl_settings>
</dl_settings>
Expand Down