Skip to content

Commit

Permalink
[nav] trying to harmonize nav modules
Browse files Browse the repository at this point in the history
  • Loading branch information
gautierhattenberger committed Nov 4, 2013
1 parent c666677 commit 1e73436
Show file tree
Hide file tree
Showing 21 changed files with 102 additions and 91 deletions.
26 changes: 13 additions & 13 deletions conf/flight_plans/nav_modules.xml
Expand Up @@ -74,16 +74,16 @@
</block>
<!--===================== Nav modules example blocks =================================-->
<block name="Bungee take-off">
<call fun="bungee_takeoff_start(WP_HOME)"/>
<call fun="bungee_takeoff_run()"/>
<call fun="nav_bungee_takeoff_start(WP_HOME)"/>
<call fun="nav_bungee_takeoff_run()"/>
</block>
<block name="Poly Survey S1-S2" strip_button="Poly Survey">
<call fun="poly_survey_adv_start(WP_S1,5,180,30,10,50,100)"/>
<call fun="poly_survey_adv_run()"/>
<call fun="nav_survey_poly_adv_start(WP_S1,5,180,30,10,50,100)"/>
<call fun="nav_survey_poly_adv_run()"/>
</block>
<block name="Border line 1-2" strip_button="Border Line (wp 1-2)">
<call fun="border_line_start()"/>
<call fun="border_line_run(WP_1, WP_2, nav_radius)"/>
<call fun="nav_line_border_start()"/>
<call fun="nav_line_border_run(WP_1, WP_2, nav_radius)"/>
</block>
<block name="Smooth nav" strip_button="Smooth nav (wp 1-2)">
<set var="snav_desired_tow" value="gps.tow / 1000. + 200."/>
Expand All @@ -96,19 +96,19 @@
<deroute block="Standby"/>
</block>
<block name="Flower" strip_button="Flower (wp 1-2)">
<call fun="flower_start(WP_1, WP_2)"/>
<call fun="flower_run()"/>
<call fun="nav_flower_start(WP_1, WP_2)"/>
<call fun="nav_flower_run()"/>
</block>
<block name="Poly survey">
<call fun="osam_poly_survey_start(WP_S1, 5, 50, 45)"/>
<call fun="osam_poly_survey_run()"/>
<call fun="nav_survey_poly_osam_start(WP_S1, 5, 50, 45)"/>
<call fun="nav_survey_poly_osam_run()"/>
</block>
<block name="Flight Line block">
<call fun="osam_flight_line_block_run(WP_S1, WP_S5, nav_radius, 30, 10)"/>
<call fun="nav_line_osam_block_run(WP_S1, WP_S5, nav_radius, 30, 10)"/>
</block>
<block name="Vertical Raster">
<call fun="vertical_raster_start()"/>
<call fun="vertical_raster_run(WP_S1, WP_S2, nav_radius, 50)"/>
<call fun="nav_vertical_raster_start()"/>
<call fun="nav_vertical_raster_run(WP_S1, WP_S2, nav_radius, 50)"/>
</block>
<!--====================================================================================-->

Expand Down
13 changes: 12 additions & 1 deletion conf/modules/nav_bungee_takeoff.xml
Expand Up @@ -3,8 +3,19 @@
<module name="nav_bungee_takeoff" dir="nav">
<doc>
<description>
Takeoff procedure using a bungee
Takeoff functions for bungee takeoff.
Run initialize function when the plane is on the bungee, the bungee is fully extended and you are ready to
launch the plane. After initialized, the plane will follow a line drawn by the position of the plane on initialization and the
position of the bungee (given in the arguments). Once the plane crosses the throttle line, which is perpendicular to the line the plane is following,
and intersects the position of the bungee (plus or minus a fixed distance (TakeOff_Distance in airframe file) from the bungee just in case the bungee doesn't release directly above the bungee) the prop will come on. The plane will then continue to follow the line until it has reached a specific
height (defined in as Takeoff_Height in airframe file) above the bungee waypoint and speed (defined as Takeoff_Speed in the airframe file).
</description>
<section name="Takeoff" prefix="Takeoff_">
<define name="Height" value="distance" unit="m" description="Takeoff height"/>
<define name="Speed" value="speed" unit="m/s" description="Procedures ends above this speed (and above Height)"/>
<define name="Distance" value="distance" unit="m" description="After this distance, the throttle is activated (if above MinSpeed)"/>
<define name="MinSpeed" value="speed" unit="m/s" description="Throttle is activated if crossing the line above this speed"/>
</section>
</doc>
<header>
<file name="nav_bungee_takeoff.h"/>
Expand Down
@@ -1,6 +1,6 @@
<!DOCTYPE module SYSTEM "module.dtd">

<module name="nav_border_line" dir="nav">
<module name="nav_line_border" dir="nav">
<doc>
<description>
navigate along a border line (line 1-2) with turns in the same direction
Expand All @@ -10,17 +10,17 @@
take care youre navigation radius is not to small in strong wind conditions!
In the flight plan:
<!--
<call fun="nav_line_init()"/>
<call fun="nav_line(WP_waypoint1_name, WP_waypoint1_name, nav_radius)"/>
<call fun="nav_line_border_start()"/>
<call fun="nav_line_border_run(WP_waypoint1_name, WP_waypoint1_name, nav_radius)"/>
-->

</description>
</doc>
<header>
<file name="nav_border_line.h"/>
<file name="nav_line_border.h"/>
</header>
<makefile>
<file name="nav_border_line.c"/>
<file name="nav_line_border.c"/>
</makefile>
</module>

@@ -1,16 +1,16 @@
<!DOCTYPE module SYSTEM "module.dtd">

<module name="nav_disc_survey" dir="nav">
<module name="nav_survey_disc" dir="nav">
<doc>
<description>
Disc Survey.
</description>
</doc>
<header>
<file name="nav_disc_survey.h"/>
<file name="nav_survey_disc.h"/>
</header>
<makefile>
<file name="nav_disc_survey.c"/>
<file name="nav_survey_disc.c"/>
</makefile>
</module>

@@ -1,16 +1,16 @@
<!DOCTYPE module SYSTEM "module.dtd">

<module name="zamboni_survey" dir="nav">
<module name="nav_survey_zamboni" dir="nav">
<doc>
<description>
Zamboni pattern survey for fixedwings.
</description>
</doc>
<header>
<file name="zamboni_survey.h"/>
<file name="nav_survey_zamboni.h"/>
</header>
<makefile>
<file name="zamboni_survey.c"/>
<file name="nav_survey_zamboni.c"/>
</makefile>
</module>

4 changes: 2 additions & 2 deletions sw/airborne/modules/nav/nav_bungee_takeoff.c
Expand Up @@ -76,7 +76,7 @@ static float BungeeAlt;
static float TDistance;
static uint8_t BungeeWaypoint;

bool_t bungee_takeoff_start(uint8_t BungeeWP)
bool_t nav_bungee_takeoff_start(uint8_t BungeeWP)
{
float ThrottleB;

Expand Down Expand Up @@ -130,7 +130,7 @@ bool_t bungee_takeoff_start(uint8_t BungeeWP)
return FALSE;
}

bool_t bungee_takeoff_run(void)
bool_t nav_bungee_takeoff_run(void)
{
//Translate current position so Throttle point is (0,0)
float Currentx = stateGetPositionEnu_f()->x-throttlePx;
Expand Down
4 changes: 2 additions & 2 deletions sw/airborne/modules/nav/nav_bungee_takeoff.h
Expand Up @@ -31,8 +31,8 @@

#include "std.h"

extern bool_t bungee_takeoff_start(uint8_t BungeeWP);
extern bool_t bungee_takeoff_run(void);
extern bool_t nav_bungee_takeoff_start(uint8_t BungeeWP);
extern bool_t nav_bungee_takeoff_run(void);

#endif

4 changes: 2 additions & 2 deletions sw/airborne/modules/nav/nav_flower.c
Expand Up @@ -57,7 +57,7 @@ static float Flowerradius;
static uint8_t Center;
static uint8_t Edge;

bool_t flower_start(uint8_t CenterWP, uint8_t EdgeWP)
bool_t nav_flower_start(uint8_t CenterWP, uint8_t EdgeWP)
{
Center = CenterWP;
Edge = EdgeWP;
Expand Down Expand Up @@ -87,7 +87,7 @@ bool_t flower_start(uint8_t CenterWP, uint8_t EdgeWP)
return FALSE;
}

bool_t flower_run(void)
bool_t nav_flower_run(void)
{
TransCurrentX = stateGetPositionEnu_f()->x - WaypointX(Center);
TransCurrentY = stateGetPositionEnu_f()->y - WaypointY(Center);
Expand Down
4 changes: 2 additions & 2 deletions sw/airborne/modules/nav/nav_flower.h
Expand Up @@ -29,7 +29,7 @@

#include "std.h"

extern bool_t flower_run(void);
extern bool_t flower_start(uint8_t CenterWP, uint8_t EdgeWP);
extern bool_t nav_flower_run(void);
extern bool_t nav_flower_start(uint8_t CenterWP, uint8_t EdgeWP);

#endif
Expand Up @@ -21,28 +21,28 @@
*/

/**
* @file modules/nav/nav_border_line.c
* @file modules/nav/nav_line_border.c
* @brief navigate along a border line (line 1-2) with turns in the same direction
*
* you can use this function to navigate along a border if it is essetial not to cross it
* navigation is along line p1, p2 with turns in the same direction to make sure you dont cross the line
* take care youre navigation radius is not to small in strong wind conditions!
*/

#include "modules/nav/nav_border_line.h"
#include "modules/nav/nav_line_border.h"
#include "generated/airframe.h"
#include "subsystems/nav.h"


enum border_line_status { LR12, LQC21, LTC2, LQC22, LR21, LQC12, LTC1, LQC11 };
static enum border_line_status border_line_status;
enum line_border_status { LR12, LQC21, LTC2, LQC22, LR21, LQC12, LTC1, LQC11 };
static enum line_border_status line_border_status;

bool_t border_line_start( void ) {
border_line_status = LR12;
bool_t nav_line_border_start( void ) {
line_border_status = LR12;
return FALSE;
}

bool_t border_line_run(uint8_t l1, uint8_t l2, float radius) {
bool_t nav_line_border_run(uint8_t l1, uint8_t l2, float radius) {
radius = fabs(radius);
float alt = waypoints[l1].a;
waypoints[l2].a = alt;
Expand Down Expand Up @@ -80,48 +80,48 @@ bool_t border_line_run(uint8_t l1, uint8_t l2, float radius) {
NavVerticalAutoThrottleMode(0);
NavVerticalAltitudeMode(WaypointAlt(l1), 0.);

switch (border_line_status) {
switch (line_border_status) {
case LR12:
NavSegment(l2, l1);
if (NavApproachingFrom(l1, l2, CARROT)) {
border_line_status = LQC21;
line_border_status = LQC21;
nav_init_stage();
}
break;
case LQC21:
nav_circle_XY(l2_c1.x, l2_c1.y, -radius);
if (NavQdrCloseTo(DegOfRad(qdr_out_2_2)-10)) {
border_line_status = LTC2;
line_border_status = LTC2;
nav_init_stage();
}
break;
case LTC2:
nav_circle_XY(l2_c2.x, l2_c2.y, radius);
if (NavQdrCloseTo(DegOfRad(qdr_out_2_3)-10)) {
border_line_status = LR21;
line_border_status = LR21;
nav_init_stage();
}
break;

case LR21:
NavSegment(l1, l2);
if (NavApproachingFrom(l2, l1, CARROT)) {
border_line_status = LTC1;
line_border_status = LTC1;
nav_init_stage();
}
break;

case LTC1:
nav_circle_XY(l1_c2.x, l1_c2.y, radius);
if (NavQdrCloseTo(DegOfRad(qdr_out_2_1) + 10)) {
border_line_status = LQC11;
line_border_status = LQC11;
nav_init_stage();
}
break;
case LQC11:
nav_circle_XY(l1_c3.x, l1_c3.y, -radius);
if (NavQdrCloseTo(DegOfRad(qdr_out_2_3 + M_PI + 10))) {
border_line_status = LR12;
line_border_status = LR12;
nav_init_stage();
}
break;
Expand Down
Expand Up @@ -20,16 +20,16 @@
*/

/**
* @file modules/nav/nav_border_line.h
* @file modules/nav/nav_line_border.h
* @brief navigate along a border line (line 1-2) with turns in the same direction
*/

#ifndef BORDER_LINE_H
#define BORDER_LINE_H
#ifndef NAV_LINE_BORDER_H
#define NAV_LINE_BORDER_H

#include "std.h"

extern bool_t border_line_start( void );
extern bool_t border_line_run(uint8_t wp1, uint8_t wp2, float radius);
extern bool_t nav_line_border_start( void );
extern bool_t nav_line_border_run(uint8_t wp1, uint8_t wp2, float radius);

#endif /* BORDER_LINE_H */
#endif /* NAV_LINE_BORDER_H */
8 changes: 4 additions & 4 deletions sw/airborne/modules/nav/nav_line_osam.c
Expand Up @@ -61,7 +61,7 @@ static void TranslateAndRotateFromWorld(struct Point2D *p, float Zrot, float tra
}


bool_t osam_flight_line_run(uint8_t From_WP, uint8_t To_WP, float radius, float Space_Before, float Space_After)
bool_t nav_line_osam_run(uint8_t From_WP, uint8_t To_WP, float radius, float Space_Before, float Space_After)
{
struct Point2D V;
struct Point2D P;
Expand Down Expand Up @@ -168,11 +168,11 @@ bool_t osam_flight_line_run(uint8_t From_WP, uint8_t To_WP, float radius, float

static uint8_t FLBlockCount = 0;

bool_t osam_flight_line_block_run(uint8_t First_WP, uint8_t Last_WP, float radius, float Space_Before, float Space_After)
bool_t nav_line_osam_block_run(uint8_t First_WP, uint8_t Last_WP, float radius, float Space_Before, float Space_After)
{
if(First_WP < Last_WP)
{
osam_flight_line_run(First_WP+FLBlockCount, First_WP+FLBlockCount+1, radius, Space_Before, Space_After);
nav_line_osam_run(First_WP+FLBlockCount, First_WP+FLBlockCount+1, radius, Space_Before, Space_After);

if(CFLStatus == FLInitialize)
{
Expand All @@ -186,7 +186,7 @@ bool_t osam_flight_line_block_run(uint8_t First_WP, uint8_t Last_WP, float radiu
}
else
{
osam_flight_line_run(First_WP-FLBlockCount, First_WP-FLBlockCount-1, radius, Space_Before, Space_After);
nav_line_osam_run(First_WP-FLBlockCount, First_WP-FLBlockCount-1, radius, Space_Before, Space_After);

if(CFLStatus == FLInitialize)
{
Expand Down
4 changes: 2 additions & 2 deletions sw/airborne/modules/nav/nav_line_osam.h
Expand Up @@ -29,7 +29,7 @@

#include "std.h"

extern bool_t osam_flight_line_run(uint8_t From_WP, uint8_t To_WP, float radius, float Space_Before, float Space_After);
extern bool_t osam_flight_line_block_run(uint8_t First_WP, uint8_t Last_WP, float radius, float Space_Before, float Space_After);
extern bool_t nav_line_osam_run(uint8_t From_WP, uint8_t To_WP, float radius, float Space_Before, float Space_After);
extern bool_t nav_line_osam_block_run(uint8_t First_WP, uint8_t Last_WP, float radius, float Space_Before, float Space_After);

#endif
Expand Up @@ -20,11 +20,11 @@
*/

/**
* @file modules/nav/nav_disc_survey.c
* @file modules/nav/nav_survey_disc.c
*
*/

#include "modules/nav/nav_disc_survey.h"
#include "modules/nav/nav_survey_disc.h"

#include "generated/airframe.h"
#include "state.h"
Expand All @@ -46,7 +46,7 @@ struct DiscSurvey {
static struct DiscSurvey disc_survey;


bool_t nav_disc_survey_start( float grid ) {
bool_t nav_survey_disc_start( float grid ) {
nav_survey_shift = grid;
disc_survey.status = DOWNWIND;
disc_survey.sign = 1;
Expand All @@ -55,7 +55,7 @@ bool_t nav_disc_survey_start( float grid ) {
return FALSE;
}

bool_t nav_disc_survey_run( uint8_t center_wp, float radius) {
bool_t nav_survey_disc_run( uint8_t center_wp, float radius) {
struct FloatVect2* wind = stateGetHorizontalWindspeed_f();
float wind_dir = atan2(wind->x, wind->y) + M_PI;

Expand Down

0 comments on commit 1e73436

Please sign in to comment.