Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added px4fmu_sim branch for software in the loop (SITL) development #44

Closed
wants to merge 5 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ Make.dep
*~
Images/*.bin
Images/*.px4
Images/*.exe
nuttx/Make.defs
nuttx/setenv.sh
nuttx/arch/arm/include/board
Expand Down Expand Up @@ -40,3 +41,5 @@ nsh_romfsimg.h
cscope.out
.configX-e
nuttx-export.zip
nuttx/arch/sim/include/board
nuttx/arch/sim/src/board
28 changes: 26 additions & 2 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@
# project to slim down and simply generate PX4 link kits via the NuttX
# 'make export' mechanism.
#
#

#
# Some useful paths.
Expand Down Expand Up @@ -42,14 +41,19 @@ endif
FIRMWARE_BUNDLE = $(IMAGE_DIR)/$(TARGET).px4
FIRMWARE_BINARY = $(IMAGE_DIR)/$(TARGET).bin
FIRMWARE_PROTOTYPE = $(IMAGE_DIR)/$(TARGET).prototype
FIRMWARE_EXEC = $(IMAGE_DIR)/$(TARGET).exe

#
# Debugging
#
MQUIET = --no-print-directory
#MQUIET = --print-directory

all: $(FIRMWARE_BUNDLE)
ifeq ($(TARGET),px4fmu_sim)
all: $(FIRMWARE_EXEC)
else
all: $(FIRMWARE_BUNDLE)
endif

#
# Generate a wrapped .px4 file from the built binary
Expand All @@ -68,6 +72,15 @@ $(FIRMWARE_BINARY): configure_$(TARGET) setup_$(TARGET)
@make -C $(NUTTX_SRC) -r $(MQUIET) all
@cp $(NUTTX_SRC)/nuttx.bin $@

#
# Build the firmware executable.
#
.PHONY: $(FIRMWARE_EXEC)
$(FIRMWARE_EXEC): configure_$(TARGET) setup_$(TARGET)
@echo Building $@
@make -C $(NUTTX_SRC) -r $(MQUIET) all
@cp $(NUTTX_SRC)/nuttx $@

#
# The 'configure' targets select one particular firmware configuration
# and makes it current.
Expand All @@ -86,6 +99,13 @@ endif
@cd $(NUTTX_SRC)/tools && /bin/sh configure.sh px4io/io
@echo px4io > $(CONFIGURED)

configure_px4fmu_sim:
ifneq ($(TARGET),px4fmu_sim)
@make -C $(PX4BASE) distclean
endif
@cd $(NUTTX_SRC)/tools && /bin/sh configure.sh px4fmu_sim/nsh
@echo px4fmu_sim > $(CONFIGURED)

#
# Per-configuration additional targets
#
Expand All @@ -96,6 +116,10 @@ setup_px4fmu:

setup_px4io:

setup_px4fmu_sim:
@echo Generating ROMFS
@make -C $(ROMFS_SRC) all

#
# Firmware uploading.
#
Expand Down
10 changes: 8 additions & 2 deletions ROMFS/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -10,12 +10,14 @@
#
SRCROOT ?= $(dir $(lastword $(MAKEFILE_LIST)))
BUILDROOT ?= $(SRCROOT)/img
ROMFS_HEADER ?= $(SRCROOT)/../nuttx/configs/px4fmu/include/nsh_romfsimg.h
ROMFS_HEADER ?= $(SRCROOT)/../nuttx/configs/px4fmu/include/nsh_romfsimg.h
ROMFS_SIM_HEADER ?= $(SRCROOT)/../nuttx/configs/px4fmu_sim/include/nsh_romfsimg.h

#
# List of files to install in the ROMFS, specified as <source>~<destination>
#
ROMFS_FSSPEC := $(SRCROOT)/scripts/rcS~init.d/rcS \
$(SRCROOT)/scripts/rc.sim~init.d/rc.sim \
$(SRCROOT)/scripts/rc.sensors~init.d/rc.sensors \
$(SRCROOT)/scripts/rc.logging~init.d/rc.logging \
$(SRCROOT)/scripts/rc.standalone~init.d/rc.standalone \
Expand Down Expand Up @@ -72,12 +74,16 @@ ROMFS_WORKDIR = $(BUILDROOT)/romfs
#
# Convenience target for rebuilding the ROMFS header
#
all: $(ROMFS_HEADER)
all: $(ROMFS_HEADER) $(ROMFS_SIM_HEADER)

$(ROMFS_HEADER): $(ROMFS_IMG) $(dir $(ROMFS_HEADER))
@echo Generating the ROMFS header...
@(cd $(dir $(ROMFS_IMG)) && xxd -i $(notdir $(ROMFS_IMG))) > $@

$(ROMFS_SIM_HEADER): $(ROMFS_HEADER)
@echo Generating the ROMFS sim header...
@cp $^ $@

$(ROMFS_IMG): $(ROMFS_WORKDIR)
@echo Generating the ROMFS image...
@genromfs -f $@ -d $(ROMFS_WORKDIR) -V "NSHInitVol"
Expand Down
40 changes: 40 additions & 0 deletions ROMFS/scripts/rc.sim
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
#!nsh
#
# Startup script for simulation configuration.
#

echo "[init] doing simulation startup..."

echo "[init] uORB"
uorb start

echo "[init] sensors"
#bma180 start
#l3gd20 start
#mpu6000 start
#hmc5883 start
#ms5611 start

sensors start

echo "[init] mavlink"
mavlink start -d /dev/ttyS1 -b 57600
usleep 5000

echo "[init] commander"
commander start

echo "[init] attitude control"
#attitude_estimator_ekf start
#multirotor_att_control start

#echo "[init] starting PWM output"
#fmu mode_pwm
#mixer load /dev/pwm_output /etc/mixers/FMU_quad_x.mix

echo "[init] simulation startup done"

echo "[init] uORB"
uorb test


18 changes: 18 additions & 0 deletions ROMFS/scripts/rcS
Original file line number Diff line number Diff line change
Expand Up @@ -112,6 +112,24 @@ else
echo "[init] PX4IO not detected"
fi

#
# Are we running a simulation?
#
uname SIM
echo $?
if uname SIM
then
set BOARD PX4FMU_SIM
if [ -f /etc/init.d/rc.sim ]
then
echo "[init] reading /etc/init.d/rc.sim"
usleep 500
sh /etc/init.d/rc.sim
fi
else
echo "[init] simulation not detected"
fi

#
# Looks like we are stand-alone
#
Expand Down
8 changes: 7 additions & 1 deletion apps/nshlib/nsh_consolemain.c
Original file line number Diff line number Diff line change
Expand Up @@ -122,7 +122,12 @@ int nsh_consolemain(int argc, char *argv[])
#endif

/* Then enter the command line parsing loop */

#ifdef CONFIG_ARCH_SIM
for (;;)
{
sleep(1);
}
#else
for (;;)
{
/* For the case of debugging the USB console... dump collected USB trace data */
Expand Down Expand Up @@ -159,6 +164,7 @@ int nsh_consolemain(int argc, char *argv[])
nsh_exit(&pstate->cn_vtbl, 1);
}
}
#endif

/* Clean up */

Expand Down
42 changes: 42 additions & 0 deletions apps/sim/drivers/Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
############################################################################
#
# Copyright (C) 2012 PX4 Development Team. All rights reserved.
#
# Redistribution and use in source and binary forms, with or without
# modification, are permitted provided that the following conditions
# are met:
#
# 1. Redistributions of source code must retain the above copyright
# notice, this list of conditions and the following disclaimer.
# 2. Redistributions in binary form must reproduce the above copyright
# notice, this list of conditions and the following disclaimer in
# the documentation and/or other materials provided with the
# distribution.
# 3. Neither the name PX4 nor the names of its contributors may be
# used to endorse or promote products derived from this software
# without specific prior written permission.
#
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
# FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
# COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
# INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
# BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
# OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
# AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
# LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
# ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
# POSSIBILITY OF SUCH DAMAGE.
#
############################################################################

#
# SIM driver support code
#
# Modules in this directory are compiled for all SIM targets.
#

INCLUDES = $(TOPDIR)/arch/sim/src $(TOPDIR)/arch/sim/include

include $(APPDIR)/mk/app.mk
Loading