[fix] split the sweep variable and let each module use its own (#2504)

this is to prevent multiple declarations
This commit is contained in:
Gautier Hattenberger
2020-03-19 15:30:00 +01:00
committed by GitHub
parent 9a29798f94
commit 8028e7572b
11 changed files with 22 additions and 16 deletions
+1
View File
@@ -35,6 +35,7 @@ For more details we refer to https://wiki.paparazziuav.org/wiki/Module/guidance_
<dl_settings NAME="GVF"> <dl_settings NAME="GVF">
<dl_settings NAME="Control"> <dl_settings NAME="Control">
<dl_setting MAX="1" MIN="-1" STEP="2" VAR="gvf_control.s" shortname = "direction"/> <dl_setting MAX="1" MIN="-1" STEP="2" VAR="gvf_control.s" shortname = "direction"/>
<dl_setting min="0" max="500" step="1" var="gvf_nav_survey_sweep" type="float" shortname="sweep"/>
</dl_settings> </dl_settings>
<dl_settings NAME="Ellipse"> <dl_settings NAME="Ellipse">
<dl_setting MAX="5" MIN="0.0" STEP="0.01" VAR="gvf_ellipse_par.ke" shortname="ell_ke" param="GVF_ELLIPSE_KE"/> <dl_setting MAX="5" MIN="0.0" STEP="0.01" VAR="gvf_ellipse_par.ke" shortname="ell_ke" param="GVF_ELLIPSE_KE"/>
+1 -1
View File
@@ -21,7 +21,7 @@
<dl_setting MAX="50" MIN="5" STEP="0.5" VAR="nav_ground_speed_setpoint" shortname="ground speed"/> <dl_setting MAX="50" MIN="5" STEP="0.5" VAR="nav_ground_speed_setpoint" shortname="ground speed"/>
<dl_setting MAX="0.2" MIN="0" STEP="0.01" VAR="nav_ground_speed_pgain" shortname="ground speed pgain"/> <dl_setting MAX="0.2" MIN="0" STEP="0.01" VAR="nav_ground_speed_pgain" shortname="ground speed pgain"/>
<dl_setting MAX="500" MIN="50" STEP="5" VAR="nav_survey_shift"/> <dl_setting MAX="500" MIN="50" STEP="5" VAR="nav_survey_shift"/>
<dl_setting min="10" max="500" step="1" var="sweep_var" type="float" shortname="Distance" module="firmwares/fixedwing/nav"/> <dl_setting min="10" max="500" step="1" var="nav_survey_sweep" type="float" shortname="Distance" module="subsystems/navigation/nav_survey_rectangle"/>
</dl_settings> </dl_settings>
</dl_settings> </dl_settings>
</settings> </settings>
+1 -1
View File
@@ -54,7 +54,7 @@ float carrot_x, carrot_y;
float nav_circle_radians; /* Cumulated */ float nav_circle_radians; /* Cumulated */
float nav_circle_radians_no_rewind; /* Cumulated */ float nav_circle_radians_no_rewind; /* Cumulated */
float nav_circle_trigo_qdr; /* Angle from center to mobile */ float nav_circle_trigo_qdr; /* Angle from center to mobile */
float nav_radius, nav_course, nav_climb, nav_shift, sweep_var; float nav_radius, nav_course, nav_climb, nav_shift;
/** Status on the current leg (percentage, 0. < < 1.) in route mode */ /** Status on the current leg (percentage, 0. < < 1.) in route mode */
-1
View File
@@ -107,7 +107,6 @@ extern float nav_radius; /* m */
extern float nav_course; /* degrees, clockwise, 0.0 = N */ extern float nav_course; /* degrees, clockwise, 0.0 = N */
extern float nav_climb; /* m/s */ extern float nav_climb; /* m/s */
extern float nav_shift; /* Lateral shift along a route. In meters */ extern float nav_shift; /* Lateral shift along a route. In meters */
extern float sweep_var; //added to allow dynamic sweep width in surveys
extern float nav_ground_speed_pgain, nav_ground_speed_setpoint; extern float nav_ground_speed_pgain, nav_ground_speed_setpoint;
@@ -39,6 +39,8 @@
#include "modules/digital_cam/dc.h" #include "modules/digital_cam/dc.h"
#endif #endif
float gvf_nav_survey_sweep = 100.f; // dummy non-zero value, will be set at setup
struct gvf_SurveyPolyAdv gvf_survey; struct gvf_SurveyPolyAdv gvf_survey;
static void gvf_nav_points(struct FloatVect2 start, struct FloatVect2 end) static void gvf_nav_points(struct FloatVect2 start, struct FloatVect2 end)
@@ -147,6 +149,7 @@ void gvf_nav_survey_polygon_setup(uint8_t first_wp, uint8_t size, float angle, f
gvf_survey.poly_first = first_wp; gvf_survey.poly_first = first_wp;
gvf_survey.poly_count = size; gvf_survey.poly_count = size;
gvf_nav_survey_sweep = sweep_width;
gvf_survey.psa_sweep_width = sweep_width; gvf_survey.psa_sweep_width = sweep_width;
gvf_survey.psa_min_rad = min_rad; gvf_survey.psa_min_rad = min_rad;
gvf_survey.psa_shot_dist = shot_dist; gvf_survey.psa_shot_dist = shot_dist;
@@ -247,7 +250,7 @@ void gvf_nav_direction_circle(float rad)
bool gvf_nav_survey_polygon_run(void) bool gvf_nav_survey_polygon_run(void)
{ {
#ifdef NAV_SURVEY_POLY_GVF_DYNAMIC #ifdef NAV_SURVEY_POLY_GVF_DYNAMIC
sweep_width = (nav_survey_shift > 0 ? sweep_var : -sweep_var); sweep_width = (nav_survey_shift > 0 ? gvf_nav_survey_sweep : -gvf_nav_survey_sweep);
#endif #endif
NavVerticalAutoThrottleMode(0.0); NavVerticalAutoThrottleMode(0.0);
@@ -83,6 +83,9 @@ struct gvf_SurveyPolyAdv {
struct FloatVect2 ret_end; struct FloatVect2 ret_end;
}; };
// external setting
extern float gvf_nav_survey_sweep;
extern void gvf_nav_survey_polygon_setup(uint8_t first_wp, uint8_t size, float angle, float sweep_width, float shot_dist, extern void gvf_nav_survey_polygon_setup(uint8_t first_wp, uint8_t size, float angle, float sweep_width, float shot_dist,
float min_rad, float altitude); float min_rad, float altitude);
@@ -178,7 +178,7 @@ void nav_survey_poly_osam_setup(uint8_t EntryWP, uint8_t Size, float sw, float O
SurveyEntryWP = EntryWP; SurveyEntryWP = EntryWP;
SurveySize = Size; SurveySize = Size;
sweep_var = sw; Poly_Sweep = sw;
struct Point2D Corners[PolygonSize]; struct Point2D Corners[PolygonSize];
@@ -349,7 +349,7 @@ void nav_survey_poly_osam_setup(uint8_t EntryWP, uint8_t Size, float sw, float O
bool nav_survey_poly_osam_run(void) bool nav_survey_poly_osam_run(void)
{ {
#ifdef NAV_SURVEY_POLY_OSAM_DYNAMIC #ifdef NAV_SURVEY_POLY_OSAM_DYNAMIC
dSweep = (nav_survey_shift > 0 ? sweep_var : -sweep_var); dSweep = (nav_survey_shift > 0 ? Poly_Sweep : -Poly_Sweep);
#endif #endif
struct Point2D C; struct Point2D C;
@@ -59,7 +59,6 @@
uint8_t Poly_Size = POLYSURVEY_DEFAULT_SIZE; uint8_t Poly_Size = POLYSURVEY_DEFAULT_SIZE;
float Poly_Distance = POLYSURVEY_DEFAULT_DISTANCE; float Poly_Distance = POLYSURVEY_DEFAULT_DISTANCE;
float sweep_var;
void nav_survey_poly_setup_towards(uint8_t FirstWP, uint8_t Size, float Sweep, int SecondWP) void nav_survey_poly_setup_towards(uint8_t FirstWP, uint8_t Size, float Sweep, int SecondWP)
{ {
@@ -149,7 +148,7 @@ void nav_survey_poly_setup(uint8_t EntryWP, uint8_t Size, float sw, float Orient
SurveyEntryWP = EntryWP; SurveyEntryWP = EntryWP;
SurveySize = Size; SurveySize = Size;
sweep_var = sw; Poly_Distance = sw;
struct EnuCoor_f Corners[MaxPolygonSize]; struct EnuCoor_f Corners[MaxPolygonSize];
@@ -309,7 +308,7 @@ bool nav_survey_poly_run(void)
{ {
#ifdef NAV_SURVEY_POLY_DYNAMIC #ifdef NAV_SURVEY_POLY_DYNAMIC
dSweep = (nav_survey_shift > 0 ? sweep_var : -sweep_var); dSweep = (nav_survey_shift > 0 ? Poly_Distance : -Poly_Distance);
#endif #endif
struct EnuCoor_f C; struct EnuCoor_f C;
@@ -31,7 +31,6 @@
extern uint8_t Poly_Size; extern uint8_t Poly_Size;
extern float Poly_Distance; extern float Poly_Distance;
extern float sweep_var;
extern uint16_t PolySurveySweepNum; extern uint16_t PolySurveySweepNum;
extern uint16_t PolySurveySweepBackNum; extern uint16_t PolySurveySweepBackNum;
extern bool Half_Sweep_Enabled; extern bool Half_Sweep_Enabled;
@@ -49,7 +48,7 @@ extern void nav_survey_poly_setup(uint8_t FirstWP, uint8_t Size, float Sweep, fl
* Setup "dynamic" polygon survey with sweep orientation towards a waypoint. * Setup "dynamic" polygon survey with sweep orientation towards a waypoint.
* Computes the sweep orientation angle from the line FirstWP-SecondWP. * Computes the sweep orientation angle from the line FirstWP-SecondWP.
* If you pass zero for Size and/or Sweep it will use the global Poly_Size and * If you pass zero for Size and/or Sweep it will use the global Poly_Size and
* Poly_Sweep variables respectively (which can be changed via telemetry/settings). * Poly_Distance variables respectively (which can be changed via telemetry/settings).
* @param FirstWP first waypoint/corner of the polygon * @param FirstWP first waypoint/corner of the polygon
* @param Size number of waypoints/corners used to define the polygon, * @param Size number of waypoints/corners used to define the polygon,
* if zero uses Poly_Size * if zero uses Poly_Size
@@ -30,6 +30,8 @@
#include "subsystems/navigation/nav_survey_rectangle.h" #include "subsystems/navigation/nav_survey_rectangle.h"
#include "state.h" #include "state.h"
float nav_survey_sweep;
static struct point survey_from; static struct point survey_from;
static struct point survey_to; static struct point survey_to;
static bool survey_uturn __attribute__((unused)) = false; static bool survey_uturn __attribute__((unused)) = false;
@@ -82,7 +84,7 @@ void nav_survey_rectangle_init(uint8_t wp1, uint8_t wp2, float grid, survey_orie
} }
} }
nav_survey_shift = grid; nav_survey_shift = grid;
sweep_var = grid; nav_survey_sweep = grid;
survey_uturn = false; survey_uturn = false;
LINE_START_FUNCTION; LINE_START_FUNCTION;
} }
@@ -90,7 +92,7 @@ void nav_survey_rectangle_init(uint8_t wp1, uint8_t wp2, float grid, survey_orie
void nav_survey_rectangle(uint8_t wp1, uint8_t wp2) void nav_survey_rectangle(uint8_t wp1, uint8_t wp2)
{ {
#ifdef NAV_SURVEY_RECTANGLE_DYNAMIC #ifdef NAV_SURVEY_RECTANGLE_DYNAMIC
nav_survey_shift = (nav_survey_shift > 0 ? sweep_var : -sweep_var); nav_survey_shift = (nav_survey_shift > 0 ? nav_survey_sweep : -nav_survey_sweep);
#endif #endif
static float survey_radius; static float survey_radius;
@@ -33,7 +33,7 @@
#include "firmwares/fixedwing/nav.h" #include "firmwares/fixedwing/nav.h"
typedef enum {NS, WE} survey_orientation_t; typedef enum {NS, WE} survey_orientation_t;
extern float sweep_var; //added to allow dynamic grid argument extern float nav_survey_sweep; //added to allow dynamic grid argument
extern void nav_survey_rectangle_init(uint8_t wp1, uint8_t wp2, float grid, survey_orientation_t so); extern void nav_survey_rectangle_init(uint8_t wp1, uint8_t wp2, float grid, survey_orientation_t so);
extern void nav_survey_rectangle(uint8_t wp1, uint8_t wp2); extern void nav_survey_rectangle(uint8_t wp1, uint8_t wp2);