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

Plane: add radius for GUIDED mode #19297

Closed
wants to merge 1 commit 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.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
2 changes: 1 addition & 1 deletion ArduPlane/GCS_Mavlink.cpp
Expand Up @@ -604,7 +604,7 @@ const struct GCS_MAVLINK::stream_entries GCS_MAVLINK::all_stream_entries[] = {
*/
bool GCS_MAVLINK_Plane::handle_guided_request(AP_Mission::Mission_Command &cmd)
{
return plane.control_mode->handle_guided_request(cmd.content.location);
return plane.control_mode->handle_guided_request(cmd.content.location, cmd.p1);
}

/*
Expand Down
14 changes: 9 additions & 5 deletions ArduPlane/mode.h
Expand Up @@ -119,8 +119,8 @@ class Mode
// method for mode specific target altitude profiles
virtual bool update_target_altitude() { return false; }

// handle a guided target request from GCS
virtual bool handle_guided_request(Location target_loc) { return false; }
// handle a guided target request from GCS. A radius of Zero indicates to use WP_LOITER_RAD
virtual bool handle_guided_request(const Location target_loc, const uint16_t radius = 0) { return false; }

protected:

Expand Down Expand Up @@ -224,11 +224,15 @@ class ModeGuided : public Mode
bool does_auto_throttle() const override { return true; }

// handle a guided target request from GCS
bool handle_guided_request(Location target_loc) override;
bool handle_guided_request(const Location target_loc, const uint16_t radius = 0) override;

protected:

bool _enter() override;

private:
// adjustable radius for guided. A radius of Zero indicates to use WP_LOITER_RAD
uint16_t loiter_radius_m;
};

class ModeCircle: public Mode
Expand Down Expand Up @@ -287,8 +291,8 @@ class ModeLoiterAltQLand : public ModeLoiter
const char *name() const override { return "Loiter to QLAND"; }
const char *name4() const override { return "L2QL"; }

// handle a guided target request from GCS
bool handle_guided_request(Location target_loc) override;
// handle a guided target request from GCS. Radius is unused.
bool handle_guided_request(const Location target_loc, const uint16_t radius = 0) override;

protected:
bool _enter() override;
Expand Down
2 changes: 1 addition & 1 deletion ArduPlane/mode_LoiterAltQLand.cpp
Expand Up @@ -42,7 +42,7 @@ void ModeLoiterAltQLand::switch_qland()
}
}

bool ModeLoiterAltQLand::handle_guided_request(Location target_loc)
bool ModeLoiterAltQLand::handle_guided_request(const Location target_loc, const uint16_t radius)
{
plane.guided_WP_loc = target_loc;

Expand Down
7 changes: 4 additions & 3 deletions ArduPlane/mode_guided.cpp
Expand Up @@ -39,13 +39,14 @@ void ModeGuided::update()

void ModeGuided::navigate()
{
// Zero indicates to use WP_LOITER_RAD
plane.update_loiter(0);
// A radius of Zero indicates to use WP_LOITER_RAD
plane.update_loiter(loiter_radius_m);
}

bool ModeGuided::handle_guided_request(Location target_loc)
bool ModeGuided::handle_guided_request(const Location target_loc, const uint16_t radius)
{
plane.guided_WP_loc = target_loc;
loiter_radius_m = radius;

// add home alt if needed
if (plane.guided_WP_loc.relative_alt) {
Expand Down