[mission] fix segmentation fault and add generic mission FP

This commit is contained in:
Gautier Hattenberger
2013-10-03 22:24:23 +02:00
parent f45d69a323
commit ddab784efb
4 changed files with 69 additions and 9 deletions
+63
View File
@@ -0,0 +1,63 @@
<!DOCTYPE flight_plan SYSTEM "flight_plan.dtd">
<flight_plan alt="260" ground_alt="185" lat0="43.46223" lon0="1.27289" max_dist_from_home="1500" name="Basic" security_height="25">
<header/>
<waypoints>
<waypoint name="HOME" x="0" y="0"/>
<waypoint name="STDBY" x="49.5" y="100.1"/>
<waypoint alt="215.0" name="AF" x="177.4" y="45.1"/>
<waypoint alt="185.0" name="TD" x="28.8" y="57.0"/>
<waypoint name="_BASELEG" x="168.8" y="-13.8"/>
<waypoint name="CLIMB" x="-114.5" y="162.3"/>
</waypoints>
<exceptions/>
<blocks>
<block name="Wait GPS">
<set value="1" var="kill_throttle"/>
<while cond="!GpsFixValid()"/>
</block>
<block name="Geo init">
<while cond="LessThan(NavBlockTime(), 10)"/>
<call fun="NavSetGroundReferenceHere()"/>
</block>
<block name="Holding point">
<!--set var="nav_mode" value="NAV_MODE_ROLL"/-->
<set value="1" var="kill_throttle"/>
<attitude roll="0" throttle="0" vmode="throttle"/>
</block>
<block key="t" name="Takeoff" strip_button="Takeoff (wp CLIMB)" strip_icon="takeoff.png" group="home">
<exception cond="GetPosAlt() > ground_alt+25" deroute="Standby"/>
<set value="0" var="kill_throttle"/>
<set value="0" var="autopilot_flight_time"/>
<go from="HOME" throttle="1.0" vmode="throttle" wp="CLIMB" pitch="15"/>
</block>
<block key="<Control>a" name="Standby" strip_button="Standby" strip_icon="home.png" group="home">
<circle radius="nav_radius" wp="STDBY"/>
</block>
<block name="Mission" strip_button="Mission">
<call fun="mission_run()"/>
<deroute block="Standby"/>
</block>
<block name="Land Right AF-TD" strip_button="Land right (wp AF-TD)" strip_icon="land-right.png" group="land">
<set value="DEFAULT_CIRCLE_RADIUS" var="nav_radius"/>
<deroute block="land"/>
</block>
<block name="Land Left AF-TD" strip_button="Land left (wp AF-TD)" strip_icon="land-left.png" group="land">
<set value="-DEFAULT_CIRCLE_RADIUS" var="nav_radius"/>
<deroute block="land"/>
</block>
<block name="land">
<call fun="nav_compute_baseleg(WP_AF, WP_TD, WP__BASELEG, nav_radius)"/>
<circle radius="nav_radius" until="NavCircleCount() > 0.5" wp="_BASELEG"/>
<circle radius="nav_radius" until="And(NavQdrCloseTo(DegOfRad(baseleg_out_qdr)-(nav_radius/fabs(nav_radius))*10), 10 > fabs(GetPosAlt() - WaypointAlt(WP__BASELEG)))" wp="_BASELEG"/>
</block>
<block name="final">
<exception cond="ground_alt + 10 > GetPosAlt()" deroute="flare"/>
<go from="AF" hmode="route" vmode="glide" wp="TD"/>
</block>
<block name="flare">
<go approaching_time="0" from="AF" hmode="route" throttle="0.0" vmode="throttle" wp="TD"/>
<attitude roll="0.0" throttle="0.0" until="FALSE" vmode="throttle"/>
</block>
</blocks>
</flight_plan>
+3 -5
View File
@@ -76,13 +76,11 @@ bool_t mission_insert(enum MissionInsertMode insert, struct _mission_element * e
} }
bool_t mission_get(struct _mission_element * element __attribute__((unused))) { struct _mission_element * mission_get(void) {
if (mission.current_idx == mission.insert_idx) { if (mission.current_idx == mission.insert_idx) {
element = NULL; return NULL;
return FALSE;
} }
element = &(mission.elements[mission.current_idx]); return &(mission.elements[mission.current_idx]);
return TRUE;
} }
+2 -3
View File
@@ -104,10 +104,9 @@ extern void mission_init(void);
extern bool_t mission_insert(enum MissionInsertMode insert, struct _mission_element * element); extern bool_t mission_insert(enum MissionInsertMode insert, struct _mission_element * element);
/** Get current mission element /** Get current mission element
* @param element pointer to the current mission element * @return return a pointer to the next mission element or NULL if no more elements
* @return TRUE if valid element, FALSE if mission queue is empty (add element is set to NULL)
*/ */
extern bool_t mission_get(struct _mission_element * element); extern struct _mission_element * mission_get(void);
/** Run mission /** Run mission
* *
+1 -1
View File
@@ -105,7 +105,7 @@ static inline bool_t mission_nav_path(struct _mission_path * path) {
int mission_run() { int mission_run() {
// current element // current element
struct _mission_element * el = NULL; struct _mission_element * el = NULL;
if (!mission_get(el)) { if ((el = mission_get()) == NULL) {
// TODO do something special like a waiting circle before ending the mission ? // TODO do something special like a waiting circle before ending the mission ?
return FALSE; // end of mission return FALSE; // end of mission
} }