1
0
mirror of https://bitbucket.org/librepilot/librepilot.git synced 2024-12-01 09:24:10 +01:00

OP-1156: Added new (stub template) pathFollower Module as well as builkd environment changes to compile it instead of old pathfollowers

This commit is contained in:
Corvus Corax 2014-08-10 12:50:38 +02:00
parent 50956a8620
commit ca1923f76f
9 changed files with 146 additions and 13 deletions

View File

@ -149,7 +149,6 @@ int32_t configuration_check()
case FLIGHTMODESETTINGS_FLIGHTMODEPOSITION_RETURNTOBASE:
case FLIGHTMODESETTINGS_FLIGHTMODEPOSITION_AUTOCRUISE:
ADDSEVERITY(!coptercontrol);
ADDSEVERITY(PIOS_TASK_MONITOR_IsRunning(TASKINFO_RUNNING_PATHFOLLOWER));
ADDSEVERITY(navCapableFusion);
break;
default:

View File

@ -0,0 +1,138 @@
/**
******************************************************************************
*
* @file pathfollower.c
* @author The OpenPilot Team, http://www.openpilot.org Copyright (C) 2010.
* @brief This module compared @ref PositionActuatl to @ref ActiveWaypoint
* and sets @ref AttitudeDesired. It only does this when the FlightMode field
* of @ref ManualControlCommand is Auto.
*
* @see The GNU Public License (GPL) Version 3
*
*****************************************************************************/
/*
* 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
*/
/**
* Input object: PathDesired
* Input object: PositionState
* Input object: ManualControlCommand
* Output object: StabilizationDesired
*
* This module acts as "autopilot" - it controls the setpoints of stabilization
* based on current flight situation and desired flight path (PathDesired) as
* directed by flightmode selection or pathplanner
* This is a periodic delayed callback module
*
* Modules have no API, all communication to other modules is done through UAVObjects.
* However modules may use the API exposed by shared libraries.
* See the OpenPilot wiki for more details.
* http://www.openpilot.org/OpenPilot_Application_Architecture
*
*/
#include <openpilot.h>
#include <callbackinfo.h>
#include <math.h>
#include <pid.h>
#include <CoordinateConversions.h>
#include <fixedwingpathfollowersettings.h>
#include <vtolpathfollowersettings.h>
#include <flightstatus.h>
#include <pathstatus.h>
// Private constants
#define CALLBACK_PRIORITY CALLBACK_PRIORITY_LOW
#define CBTASK_PRIORITY CALLBACK_TASK_FLIGHTCONTROL
#define PF_IDLE_UPDATE_RATE_MS 100
#define STACK_SIZE_BYTES 2048
// Private types
// Private variables
static DelayedCallbackInfo *pathFollowerCBInfo;
static uint32_t updatePeriod = PF_IDLE_UPDATE_RATE_MS;
// Private functions
static void pathFollowerTask(void);
static void SettingsUpdatedCb(UAVObjEvent *ev);
/**
* Initialise the module, called on startup
* \returns 0 on success or -1 if initialisation failed
*/
int32_t PathFollowerStart()
{
// Start main task
SettingsUpdatedCb(NULL);
PIOS_CALLBACKSCHEDULER_Dispatch(pathFollowerCBInfo);
return 0;
}
/**
* Initialise the module, called on startup
* \returns 0 on success or -1 if initialisation failed
*/
int32_t PathFollowerInitialize()
{
// initialize objects
FixedWingPathFollowerSettingsInitialize();
VtolPathFollowerSettingsInitialize();
FlightStatusInitialize();
PathStatusInitialize();
// Create object queue
pathFollowerCBInfo = PIOS_CALLBACKSCHEDULER_Create(&pathFollowerTask, CALLBACK_PRIORITY, CBTASK_PRIORITY, CALLBACKINFO_RUNNING_ALTITUDEHOLD, STACK_SIZE_BYTES);
FixedWingPathFollowerSettingsConnectCallback(&SettingsUpdatedCb);
VtolPathFollowerSettingsConnectCallback(&SettingsUpdatedCb);
return 0;
}
MODULE_INITCALL(PathFollowerInitialize, PathFollowerStart);
/**
* Module thread, should not return.
*/
static void pathFollowerTask(void)
{
FlightStatusData flightStatus;
FlightStatusGet(&flightStatus);
if (flightStatus.ControlChain.PathFollower != FLIGHTSTATUS_CONTROLCHAIN_TRUE) {
PIOS_CALLBACKSCHEDULER_Schedule(pathFollowerCBInfo, PF_IDLE_UPDATE_RATE_MS, CALLBACK_UPDATEMODE_SOONER);
return;
}
// do pathfollower things here
PIOS_CALLBACKSCHEDULER_Schedule(pathFollowerCBInfo, updatePeriod, CALLBACK_UPDATEMODE_SOONER);
}
static void SettingsUpdatedCb(__attribute__((unused)) UAVObjEvent *ev)
{
// read in settings (TODO)
}

View File

@ -35,7 +35,6 @@ USE_DSP_LIB ?= NO
#MODULES += Airspeed
#MODULES += AltitudeHold
#MODULES += Stabilization
MODULES += VtolPathFollower
MODULES += ManualControl
MODULES += Actuator
MODULES += GPS
@ -45,7 +44,7 @@ MODULES += Battery
MODULES += FirmwareIAP
#MODULES += Radio
MODULES += PathPlanner
MODULES += FixedWingPathFollower
MODULES += PathFollower
MODULES += Osd/osdoutout
MODULES += Logging
MODULES += Telemetry

View File

@ -35,7 +35,6 @@ MODULES += Altitude/revolution
MODULES += Airspeed
#MODULES += AltitudeHold # now integrated in Stabilization
MODULES += Stabilization
MODULES += VtolPathFollower
MODULES += ManualControl
MODULES += Receiver
MODULES += Actuator
@ -46,7 +45,7 @@ MODULES += Battery
MODULES += FirmwareIAP
MODULES += Radio
MODULES += PathPlanner
MODULES += FixedWingPathFollower
MODULES += PathFollower
MODULES += Osd/osdoutout
MODULES += Logging
MODULES += Telemetry

View File

@ -35,7 +35,6 @@ MODULES += Altitude/revolution
MODULES += Airspeed
#MODULES += AltitudeHold # now integrated in Stabilization
MODULES += Stabilization
MODULES += VtolPathFollower
MODULES += ManualControl
MODULES += Receiver
MODULES += Actuator
@ -45,7 +44,7 @@ MODULES += CameraStab
MODULES += Battery
MODULES += FirmwareIAP
MODULES += PathPlanner
MODULES += FixedWingPathFollower
MODULES += PathFollower
MODULES += Osd/osdoutout
MODULES += Logging
MODULES += Telemetry

View File

@ -33,8 +33,7 @@ DEBUG ?= YES
# List of modules to include
MODULES = ManualControl Stabilization GPS
MODULES += PathPlanner
MODULES += FixedWingPathFollower
MODULES += VtolPathFollower
MODULES += PathFollower
MODULES += CameraStab
MODULES += Telemetry
MODULES += Logging

View File

@ -8,6 +8,7 @@
<elementname>AltitudeHold</elementname>
<elementname>Stabilization0</elementname>
<elementname>Stabilization1</elementname>
<elementname>PathFollower</elementname>
<elementname>PathPlanner0</elementname>
<elementname>PathPlanner1</elementname>
<elementname>ManualControl</elementname>
@ -20,6 +21,7 @@
<elementname>AltitudeHold</elementname>
<elementname>Stabilization0</elementname>
<elementname>Stabilization1</elementname>
<elementname>PathFollower</elementname>
<elementname>PathPlanner0</elementname>
<elementname>PathPlanner1</elementname>
<elementname>ManualControl</elementname>
@ -36,6 +38,7 @@
<elementname>AltitudeHold</elementname>
<elementname>Stabilization0</elementname>
<elementname>Stabilization1</elementname>
<elementname>PathFollower</elementname>
<elementname>PathPlanner0</elementname>
<elementname>PathPlanner1</elementname>
<elementname>ManualControl</elementname>

View File

@ -22,7 +22,7 @@
<field name="USB_HIDPort" units="function" type="enum" elements="1" options="USBTelemetry,RCTransmitter,Disabled" defaultvalue="USBTelemetry"/>
<field name="USB_VCPPort" units="function" type="enum" elements="1" options="USBTelemetry,ComBridge,DebugConsole,Disabled" defaultvalue="Disabled"/>
<field name="OptionalModules" units="" type="enum" elementnames="CameraStab,GPS,ComUsbBridge,Fault,Altitude,Airspeed,TxPID,Autotune,VtolPathFollower,FixedWingPathFollower,Battery,Overo,MagBaro,OsdHk" options="Disabled,Enabled" defaultvalue="Disabled"/>
<field name="OptionalModules" units="" type="enum" elementnames="CameraStab,GPS,ComUsbBridge,Fault,Altitude,Airspeed,TxPID,Autotune,Battery,Overo,MagBaro,OsdHk" options="Disabled,Enabled" defaultvalue="Disabled"/>
<field name="ADCRouting" units="" type="enum" elementnames="adc0,adc1,adc2,adc3" options="Disabled,BatteryVoltage,BatteryCurrent,AnalogAirspeed,Generic" defaultvalue="Disabled"/>
<field name="DSMxBind" units="" type="uint8" elements="1" defaultvalue="0"/>
<field name="WS2811LED_Out" units="" type="enum" elements="1" options="ServoOut1,ServoOut2,ServoOut3,ServoOut4,ServoOut5,ServoOut6,FlexiPin3,FlexiPin4,Disabled" defaultvalue="Disabled" />

View File

@ -19,7 +19,6 @@
<elementname>Airspeed</elementname>
<elementname>MagBaro</elementname>
<!-- navigation -->
<elementname>PathFollower</elementname>
<elementname>FlightPlan</elementname>
<!-- telemetry -->
<elementname>TelemetryTx</elementname>
@ -52,7 +51,6 @@
<elementname>Airspeed</elementname>
<elementname>MagBaro</elementname>
<!-- navigation -->
<elementname>PathFollower</elementname>
<elementname>FlightPlan</elementname>
<!-- telemetry -->
<elementname>TelemetryTx</elementname>
@ -89,7 +87,6 @@
<elementname>Airspeed</elementname>
<elementname>MagBaro</elementname>
<!-- navigation -->
<elementname>PathFollower</elementname>
<elementname>FlightPlan</elementname>
<!-- telemetry -->
<elementname>TelemetryTx</elementname>