Skip to content

Commit

Permalink
[nav] fix survey hybrid (#3025)
Browse files Browse the repository at this point in the history
* [nav] fix survey hybrid

- call init function
- set to valid at the end of setup so it works with mission correctly

* [nav] fix unit, indexes and doc for survey hybrid
  • Loading branch information
gautierhattenberger committed Apr 24, 2023
1 parent 2a98d9f commit 5f4a460
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 7 deletions.
5 changes: 3 additions & 2 deletions conf/modules/nav_survey_hybrid.xml
Original file line number Diff line number Diff line change
Expand Up @@ -11,11 +11,11 @@
Support mission mode with custom elements:
- points in local NED: SRVHL orientation sweep_distance radius height p1x p1y p2x p2y p3x p3y [p4x p4y]
- points in global LLA: SRVHG orientation sweep_distance radius height p1lat p1lon p2lat p2lon p3lat p3lon [p4lat p4lon]
- orientation is in degrees
- orientation is in degrees, 0 pointing at east, positive counter clockwise
- sweep_distance in meters
- radius can be: negative, automatically set to sweep/2; zero, not turning on circles; positive, fixed radius
- height in meters above reference point
- the polygon in mission mode can have either 3 or 4 points.
- the polygon in mission mode can have either 3 or 4 points, with positions in meters (local) or degrees (global).
</description>
<section name="SURVEY_HYBRID" prefix="SURVEY_HYBRID_">
<define name="MAX_POLYGON_SIZE" value="20" description="max waypoints usable in polygon survey"/>
Expand All @@ -42,6 +42,7 @@
<header>
<file name="nav_survey_hybrid.h"/>
</header>
<init fun="nav_survey_hybrid_init()"/>
<makefile target="ap|nps">
<file name="nav_survey_hybrid.c"/>
<test firmware="rotorcraft">
Expand Down
9 changes: 4 additions & 5 deletions sw/airborne/modules/nav/nav_survey_hybrid.c
Original file line number Diff line number Diff line change
Expand Up @@ -130,7 +130,7 @@ static bool nav_survey_hybrid_mission_local(uint8_t nb, float *params, enum Miss
else { survey_private.size = 4; }
for (int i = 0; i < survey_private.size; i++) {
survey_private.corners[i].x = params[4+2*i];
survey_private.corners[i].y = params[5+2*i];
survey_private.corners[i].y = params[5+2*i+1];
survey_private.corners[i].z = height;
}
nav_survey_hybrid_setup(orientation, sweep, radius);
Expand All @@ -155,8 +155,8 @@ static bool nav_survey_hybrid_mission_global(uint8_t nb, float *params, enum Mis
else { survey_private.size = 4; }
for (int i = 0; i < survey_private.size; i++) {
struct LlaCoor_f lla = {
.lat = params[4+2*i],
.lon = params[4+2*i],
.lat = RadOfDeg(params[4+2*i]),
.lon = RadOfDeg(params[4+2*i+1]),
.alt = state.ned_origin_f.lla.alt + height
};
struct EnuCoor_f corner;
Expand Down Expand Up @@ -353,6 +353,7 @@ static void nav_survey_hybrid_setup(float orientation, float sweep, float radius

LINE_STOP_FUNCTION;
NavVerticalAltitudeMode(survey_private.entry.z, 0.f);
survey_private.valid = true;
}

void nav_survey_hybrid_setup_orientation(uint8_t start_wp, float orientation, uint8_t size, float sweep, float radius)
Expand All @@ -370,7 +371,6 @@ void nav_survey_hybrid_setup_orientation(uint8_t start_wp, float orientation, ui
}
survey_private.size = size;

survey_private.valid = true;
nav_survey_hybrid_setup(orientation, sweep, radius);
}

Expand All @@ -382,7 +382,6 @@ void nav_survey_hybrid_setup_towards(uint8_t start_wp, uint8_t second_wp, uint8_
if (start == NULL || second == NULL) {
return;
}
survey_private.valid = true;

float dx = second->x - start->x;
float dy = second->y - start->y;
Expand Down

0 comments on commit 5f4a460

Please sign in to comment.