mirror of
https://bitbucket.org/librepilot/librepilot.git
synced 2025-01-29 14:52:12 +01:00
UAVObjects: Allow Generation and Initialisation of individual UAVObjects
per target as defined in Makefile (and/or Make include file) For OpenPilot this is flight/OpenPilot/UAVObjects.inc For sim_posix and sim_win32 needs rebuild of uavobjectgenerator and uavobjects! git-svn-id: svn://svn.openpilot.org/OpenPilot/trunk@2736 ebee16cc-31ac-478f-84a7-5cbb03baadba
This commit is contained in:
parent
250e154067
commit
afdaf88d4a
@ -170,7 +170,8 @@ endif
|
||||
|
||||
## UAVOBJECTS
|
||||
ifndef TESTAPP
|
||||
include $(UAVOBJSYNTHDIR)/Makefile.inc
|
||||
#include $(UAVOBJSYNTHDIR)/Makefile.inc
|
||||
include ./UAVObjects.inc
|
||||
SRC += $(UAVOBJSRC)
|
||||
endif
|
||||
|
||||
|
@ -154,8 +154,10 @@ endif
|
||||
|
||||
## UAVOBJECTS
|
||||
ifndef TESTAPP
|
||||
include $(UAVOBJSYNTHDIR)/Makefile.inc
|
||||
#include $(UAVOBJSYNTHDIR)/Makefile.inc
|
||||
include ./UAVObjects.inc
|
||||
SRC += $(UAVOBJSRC)
|
||||
CFLAGS_UAVOBJECTS = $(UAVOBJDEFINE)
|
||||
endif
|
||||
|
||||
## PIOS Hardware (posix)
|
||||
@ -298,6 +300,7 @@ ifeq ($(DEBUG),YES)
|
||||
CFLAGS = -g$(DEBUGF) -DDEBUG
|
||||
endif
|
||||
|
||||
CFLAGS += $(CFLAGS_UAVOBJECTS)
|
||||
CFLAGS += -DARCH_POSIX
|
||||
CFLAGS += -O$(OPT)
|
||||
CFLAGS += -mtune=$(MCU)
|
||||
|
@ -151,8 +151,10 @@ endif
|
||||
|
||||
## UAVOBJECTS
|
||||
ifndef TESTAPP
|
||||
include $(UAVOBJSYNTHDIR)/Makefile.inc
|
||||
#include $(UAVOBJSYNTHDIR)/Makefile.inc
|
||||
include ./UAVObjects.inc
|
||||
SRC += $(UAVOBJSRC)
|
||||
CFLAGS_UAVOBJECTS = $(UAVOBJDEFINE)
|
||||
endif
|
||||
|
||||
## PIOS Hardware (win32)
|
||||
@ -288,6 +290,7 @@ ifeq ($(DEBUG),YES)
|
||||
CFLAGS = -g
|
||||
endif
|
||||
|
||||
CFLAGS += $(CFLAGS_UAVOBJECTS)
|
||||
CFLAGS += -DARCH_WIN32
|
||||
CFLAGS += -O$(OPT)
|
||||
CFLAGS += -mtune=$(MCU)
|
||||
|
73
flight/OpenPilot/UAVObjects.inc
Normal file
73
flight/OpenPilot/UAVObjects.inc
Normal file
@ -0,0 +1,73 @@
|
||||
#####
|
||||
# Project: OpenPilot
|
||||
#
|
||||
# Makefile for OpenPilot UAVObject code
|
||||
#
|
||||
# The OpenPilot Team, http://www.openpilot.org, Copyright (C) 2011.
|
||||
#
|
||||
# This program 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 3 of the License, or
|
||||
# (at your option) any later version.
|
||||
#
|
||||
# This program 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 this program; if not, write to the Free Software Foundation, Inc.,
|
||||
# 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
#####
|
||||
|
||||
# These are the UAVObjects supposed to be build as part of the OpenPilot target
|
||||
# (all architectures)
|
||||
|
||||
UAVOBJSRCFILENAMES =
|
||||
UAVOBJSRCFILENAMES += actuatorcommand
|
||||
UAVOBJSRCFILENAMES += actuatordesired
|
||||
UAVOBJSRCFILENAMES += actuatorsettings
|
||||
UAVOBJSRCFILENAMES += ahrscalibration
|
||||
UAVOBJSRCFILENAMES += ahrssettings
|
||||
UAVOBJSRCFILENAMES += ahrsstatus
|
||||
UAVOBJSRCFILENAMES += attitudeactual
|
||||
UAVOBJSRCFILENAMES += attitudedesired
|
||||
UAVOBJSRCFILENAMES += attituderaw
|
||||
# UAVOBJSRCFILENAMES += attitudesettings CC only
|
||||
UAVOBJSRCFILENAMES += baroaltitude
|
||||
UAVOBJSRCFILENAMES += batterysettings
|
||||
UAVOBJSRCFILENAMES += firmwareiapobj
|
||||
UAVOBJSRCFILENAMES += flightbatterystate
|
||||
UAVOBJSRCFILENAMES += flightplancontrol
|
||||
UAVOBJSRCFILENAMES += flightplansettings
|
||||
UAVOBJSRCFILENAMES += flightplanstatus
|
||||
UAVOBJSRCFILENAMES += flighttelemetrystats
|
||||
UAVOBJSRCFILENAMES += gcstelemetrystats
|
||||
UAVOBJSRCFILENAMES += gpsposition
|
||||
UAVOBJSRCFILENAMES += gpssatellites
|
||||
UAVOBJSRCFILENAMES += gpstime
|
||||
UAVOBJSRCFILENAMES += guidancesettings
|
||||
UAVOBJSRCFILENAMES += homelocation
|
||||
UAVOBJSRCFILENAMES += i2cstats
|
||||
UAVOBJSRCFILENAMES += manualcontrolcommand
|
||||
UAVOBJSRCFILENAMES += manualcontrolsettings
|
||||
UAVOBJSRCFILENAMES += mixersettings
|
||||
UAVOBJSRCFILENAMES += mixerstatus
|
||||
UAVOBJSRCFILENAMES += nedaccel
|
||||
UAVOBJSRCFILENAMES += objectpersistence
|
||||
UAVOBJSRCFILENAMES += positionactual
|
||||
UAVOBJSRCFILENAMES += positiondesired
|
||||
UAVOBJSRCFILENAMES += ratedesired
|
||||
UAVOBJSRCFILENAMES += sonaraltitude
|
||||
UAVOBJSRCFILENAMES += stabilizationsettings
|
||||
UAVOBJSRCFILENAMES += systemalarms
|
||||
UAVOBJSRCFILENAMES += systemsettings
|
||||
UAVOBJSRCFILENAMES += systemstats
|
||||
UAVOBJSRCFILENAMES += taskinfo
|
||||
UAVOBJSRCFILENAMES += telemetrysettings
|
||||
UAVOBJSRCFILENAMES += velocityactual
|
||||
UAVOBJSRCFILENAMES += velocitydesired
|
||||
UAVOBJSRCFILENAMES += watchdogstatus
|
||||
|
||||
UAVOBJSRC = $(foreach UAVOBJSRCFILE,$(UAVOBJSRCFILENAMES),$(UAVOBJSYNTHDIR)/$(UAVOBJSRCFILE).c )
|
||||
UAVOBJDEFINE = $(foreach UAVOBJSRCFILE,$(UAVOBJSRCFILENAMES),-DUAVOBJ_INIT_$(UAVOBJSRCFILE) )
|
@ -38,4 +38,4 @@
|
||||
UAVOBJSRCFILENAMES = $(UAVOBJFILENAMES)
|
||||
|
||||
UAVOBJSRC = $(foreach UAVOBJSRCFILE,$(UAVOBJSRCFILENAMES),$(UAVOBJSYNTHDIR)/$(UAVOBJSRCFILE).c )
|
||||
|
||||
UAVOBJDEFINE = $(foreach UAVOBJSRCFILE,$(UAVOBJSRCFILENAMES),-DUAVOBJ_INIT_$(UAVOBJSRCFILE) )
|
||||
|
@ -51,8 +51,10 @@ bool UAVObjectGeneratorFlight::generate(UAVObjectParser* parser,QString template
|
||||
for (int objidx = 0; objidx < parser->getNumObjects(); ++objidx) {
|
||||
ObjectInfo* info=parser->getObjectByIndex(objidx);
|
||||
process_object(info);
|
||||
flightObjInit.append(" " + info->name + "Initialize();\n");
|
||||
objInc.append("#include \"" + info->namelc + ".h\"\n");
|
||||
flightObjInit.append("#ifdef UAVOBJ_INIT_" + info->namelc +"\r\n");
|
||||
flightObjInit.append(" " + info->name + "Initialize();\r\n");
|
||||
flightObjInit.append("#endif\r\n");
|
||||
objInc.append("#include \"" + info->namelc + ".h\"\r\n");
|
||||
objFileNames.append(" " + info->namelc);
|
||||
objNames.append(" " + info->name);
|
||||
}
|
||||
@ -107,12 +109,12 @@ bool UAVObjectGeneratorFlight::process_object(ObjectInfo* info)
|
||||
// Append field
|
||||
if ( info->fields[n]->numElements > 1 )
|
||||
{
|
||||
fields.append( QString(" %1 %2[%3];\n").arg(type)
|
||||
fields.append( QString(" %1 %2[%3];\r\n").arg(type)
|
||||
.arg(info->fields[n]->name).arg(info->fields[n]->numElements) );
|
||||
}
|
||||
else
|
||||
{
|
||||
fields.append( QString(" %1 %2;\n").arg(type).arg(info->fields[n]->name) );
|
||||
fields.append( QString(" %1 %2;\r\n").arg(type).arg(info->fields[n]->name) );
|
||||
}
|
||||
}
|
||||
outInclude.replace(QString("$(DATAFIELDS)"), fields);
|
||||
@ -121,11 +123,11 @@ bool UAVObjectGeneratorFlight::process_object(ObjectInfo* info)
|
||||
QString enums;
|
||||
for (int n = 0; n < info->fields.length(); ++n)
|
||||
{
|
||||
enums.append(QString("// Field %1 information\n").arg(info->fields[n]->name));
|
||||
enums.append(QString("// Field %1 information\r\n").arg(info->fields[n]->name));
|
||||
// Only for enum types
|
||||
if (info->fields[n]->type == FIELDTYPE_ENUM)
|
||||
{
|
||||
enums.append(QString("/* Enumeration options for field %1 */\n").arg(info->fields[n]->name));
|
||||
enums.append(QString("/* Enumeration options for field %1 */\r\n").arg(info->fields[n]->name));
|
||||
enums.append("typedef enum { ");
|
||||
// Go through each option
|
||||
QStringList options = info->fields[n]->options;
|
||||
@ -138,14 +140,14 @@ bool UAVObjectGeneratorFlight::process_object(ObjectInfo* info)
|
||||
.arg(m) );
|
||||
|
||||
}
|
||||
enums.append( QString(" } %1%2Options;\n")
|
||||
enums.append( QString(" } %1%2Options;\r\n")
|
||||
.arg( info->name )
|
||||
.arg( info->fields[n]->name ) );
|
||||
}
|
||||
// Generate element names (only if field has more than one element)
|
||||
if (info->fields[n]->numElements > 1 && !info->fields[n]->defaultElementNames)
|
||||
{
|
||||
enums.append(QString("/* Array element names for field %1 */\n").arg(info->fields[n]->name));
|
||||
enums.append(QString("/* Array element names for field %1 */\r\n").arg(info->fields[n]->name));
|
||||
enums.append("typedef enum { ");
|
||||
// Go through the element names
|
||||
QStringList elemNames = info->fields[n]->elementNames;
|
||||
@ -159,15 +161,15 @@ bool UAVObjectGeneratorFlight::process_object(ObjectInfo* info)
|
||||
.arg(m) );
|
||||
|
||||
}
|
||||
enums.append( QString(" } %1%2Elem;\n")
|
||||
enums.append( QString(" } %1%2Elem;\r\n")
|
||||
.arg( info->name )
|
||||
.arg( info->fields[n]->name ) );
|
||||
}
|
||||
// Generate array information
|
||||
if (info->fields[n]->numElements > 1)
|
||||
{
|
||||
enums.append(QString("/* Number of elements for field %1 */\n").arg(info->fields[n]->name));
|
||||
enums.append( QString("#define %1_%2_NUMELEM %3\n")
|
||||
enums.append(QString("/* Number of elements for field %1 */\r\n").arg(info->fields[n]->name));
|
||||
enums.append( QString("#define %1_%2_NUMELEM %3\r\n")
|
||||
.arg( info->name.toUpper() )
|
||||
.arg( info->fields[n]->name.toUpper() )
|
||||
.arg( info->fields[n]->numElements ) );
|
||||
@ -186,19 +188,19 @@ bool UAVObjectGeneratorFlight::process_object(ObjectInfo* info)
|
||||
{
|
||||
if ( info->fields[n]->type == FIELDTYPE_ENUM )
|
||||
{
|
||||
initfields.append( QString("\tdata.%1 = %2;\n")
|
||||
initfields.append( QString("\tdata.%1 = %2;\r\n")
|
||||
.arg( info->fields[n]->name )
|
||||
.arg( info->fields[n]->options.indexOf( info->fields[n]->defaultValues[0] ) ) );
|
||||
}
|
||||
else if ( info->fields[n]->type == FIELDTYPE_FLOAT32 )
|
||||
{
|
||||
initfields.append( QString("\tdata.%1 = %2;\n")
|
||||
initfields.append( QString("\tdata.%1 = %2;\r\n")
|
||||
.arg( info->fields[n]->name )
|
||||
.arg( info->fields[n]->defaultValues[0].toFloat() ) );
|
||||
}
|
||||
else
|
||||
{
|
||||
initfields.append( QString("\tdata.%1 = %2;\n")
|
||||
initfields.append( QString("\tdata.%1 = %2;\r\n")
|
||||
.arg( info->fields[n]->name )
|
||||
.arg( info->fields[n]->defaultValues[0].toInt() ) );
|
||||
}
|
||||
@ -210,21 +212,21 @@ bool UAVObjectGeneratorFlight::process_object(ObjectInfo* info)
|
||||
{
|
||||
if ( info->fields[n]->type == FIELDTYPE_ENUM )
|
||||
{
|
||||
initfields.append( QString("\tdata.%1[%2] = %3;\n")
|
||||
initfields.append( QString("\tdata.%1[%2] = %3;\r\n")
|
||||
.arg( info->fields[n]->name )
|
||||
.arg( idx )
|
||||
.arg( info->fields[n]->options.indexOf( info->fields[n]->defaultValues[idx] ) ) );
|
||||
}
|
||||
else if ( info->fields[n]->type == FIELDTYPE_FLOAT32 )
|
||||
{
|
||||
initfields.append( QString("\tdata.%1[%2] = %3;\n")
|
||||
initfields.append( QString("\tdata.%1[%2] = %3;\r\n")
|
||||
.arg( info->fields[n]->name )
|
||||
.arg( idx )
|
||||
.arg( info->fields[n]->defaultValues[idx].toFloat() ) );
|
||||
}
|
||||
else
|
||||
{
|
||||
initfields.append( QString("\tdata.%1[%2] = %3;\n")
|
||||
initfields.append( QString("\tdata.%1[%2] = %3;\r\n")
|
||||
.arg( info->fields[n]->name )
|
||||
.arg( idx )
|
||||
.arg( info->fields[n]->defaultValues[idx].toInt() ) );
|
||||
|
Loading…
x
Reference in New Issue
Block a user