Skip to content

Commit

Permalink
ArduPlane: add REP-147 Global Position Control
Browse files Browse the repository at this point in the history
Signed-off-by: Ryan Friedman <[email protected]>
  • Loading branch information
Ryanf55 committed Dec 7, 2023
1 parent cf6debd commit 3180e67
Show file tree
Hide file tree
Showing 3 changed files with 51 additions and 3 deletions.
23 changes: 23 additions & 0 deletions ArduPlane/AP_ExternalControl_Plane.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
/*
external control library for plane
*/


#include "AP_ExternalControl_Plane.h"
#if AP_EXTERNAL_CONTROL_ENABLED

#include "Plane.h"

/*
Sets the target global position for a loiter point.
*/
bool AP_ExternalControl_Plane::set_global_position(const Location& loc)
{

// set_target_location already checks if plane is ready for external control.
// It doesn't check if flying or armed, just that it's in guided mode.
return plane.set_target_location(loc);
// return plane.is_taking_off();
}

#endif // AP_EXTERNAL_CONTROL_ENABLED
21 changes: 21 additions & 0 deletions ArduPlane/AP_ExternalControl_Plane.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@

/*
external control library for plane
*/
#pragma once

#include <AP_ExternalControl/AP_ExternalControl.h>

#if AP_EXTERNAL_CONTROL_ENABLED

#include <AP_Common/Location.h>

class AP_ExternalControl_Plane : public AP_ExternalControl {
public:
/*
Sets the target global position for a loiter point.
*/
bool set_global_position(const Location& loc) override WARN_IF_UNUSED;
};

#endif // AP_EXTERNAL_CONTROL_ENABLED
10 changes: 7 additions & 3 deletions ArduPlane/Plane.h
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@
#include <AP_Follow/AP_Follow.h>
#include <AP_ExternalControl/AP_ExternalControl_config.h>
#if AP_EXTERNAL_CONTROL_ENABLED
#include <AP_ExternalControl/AP_ExternalControl.h>
#include "AP_ExternalControl_Plane.h"
#endif

#include "GCS_Mavlink.h"
Expand Down Expand Up @@ -167,6 +167,10 @@ class Plane : public AP_Vehicle {
friend class ModeThermal;
friend class ModeLoiterAltQLand;

#if AP_EXTERNAL_CONTROL_ENABLED
friend class AP_ExternalControl_Plane;
#endif

Plane(void);

private:
Expand Down Expand Up @@ -776,9 +780,9 @@ class Plane : public AP_Vehicle {

AP_Param param_loader {var_info};

// dummy implementation of external control
// external control library
#if AP_EXTERNAL_CONTROL_ENABLED
AP_ExternalControl external_control;
AP_ExternalControl_Plane external_control;
#endif

static const AP_Scheduler::Task scheduler_tasks[];
Expand Down

0 comments on commit 3180e67

Please sign in to comment.