Better implementation of the GPS sensing.

You must now be on the ground and before you cant set the initial angle for Simple mode.

git-svn-id: https://arducopter.googlecode.com/svn/trunk@1819 f9c3cf11-9bcb-44bc-f272-b75c42450872
This commit is contained in:
jasonshort 2011-03-27 06:24:53 +00:00
parent 8daed835c8
commit eead295208
3 changed files with 21 additions and 21 deletions

View File

@ -263,7 +263,7 @@ float cos_pitch_x = 1;
float cos_yaw_x = 1; float cos_yaw_x = 1;
float sin_pitch_y, sin_yaw_y, sin_roll_y; float sin_pitch_y, sin_yaw_y, sin_roll_y;
float sin_nav_y, cos_nav_x; // used in calc_waypoint_nav float sin_nav_y, cos_nav_x; // used in calc_waypoint_nav
long initial_simple_bearing; // used for Simple mode long initial_simple_bearing = -1; // used for Simple mode
// Airspeed // Airspeed
// -------- // --------
@ -426,9 +426,7 @@ unsigned long elapsedTime; // for doing custom events
float load; // % MCU cycles used float load; // % MCU cycles used
byte counter_one_herz; byte counter_one_herz;
bool GPS_disabled = true;
byte GPS_failure_counter = 3;
bool GPS_disabled = false;
//////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////
// Top-level logic // Top-level logic
@ -522,12 +520,7 @@ void medium_loop()
case 0: case 0:
medium_loopCounter++; medium_loopCounter++;
if(GPS_failure_counter > 0){ update_GPS();
update_GPS();
}else if(GPS_failure_counter == 0){
GPS_disabled = true;
}
//readCommands(); //readCommands();
if(g.compass_enabled){ if(g.compass_enabled){
@ -780,13 +773,15 @@ void super_slow_loop()
void update_GPS(void) void update_GPS(void)
{ {
if(Serial1.available() == 0){
return;
}
g_gps->update(); g_gps->update();
update_GPS_light(); update_GPS_light();
if(g_gps->new_data)
GPS_failure_counter = 3;
if (g_gps->new_data && g_gps->fix) { if (g_gps->new_data && g_gps->fix) {
GPS_disabled = false;
// XXX We should be sending GPS data off one of the regular loops so that we send // XXX We should be sending GPS data off one of the regular loops so that we send
// no-GPS-fix data too // no-GPS-fix data too
@ -828,10 +823,6 @@ void update_GPS(void)
current_loc.lng = g_gps->longitude; // Lon * 10 * *7 current_loc.lng = g_gps->longitude; // Lon * 10 * *7
current_loc.lat = g_gps->latitude; // Lat * 10 * *7 current_loc.lat = g_gps->latitude; // Lat * 10 * *7
}else{
if(GPS_failure_counter > 0)
GPS_failure_counter--;
} }
} }

View File

@ -43,7 +43,7 @@ void reset_control_switch()
{ {
oldSwitchPosition = -1; oldSwitchPosition = -1;
read_control_switch(); read_control_switch();
SendDebug("MSG: reset_control_switch"); SendDebug("MSG: reset_control_switch ");
SendDebugln(oldSwitchPosition , DEC); SendDebugln(oldSwitchPosition , DEC);
} }

View File

@ -221,7 +221,7 @@ void startup_ground(void)
delay(GROUND_START_DELAY * 1000); delay(GROUND_START_DELAY * 1000);
#endif #endif
setup_show(NULL,NULL); //setup_show(NULL,NULL);
// Output waypoints for confirmation // Output waypoints for confirmation
// -------------------------------- // --------------------------------
@ -254,6 +254,9 @@ void startup_ground(void)
// ------------------- // -------------------
init_commands(); init_commands();
// clear out the GPS buffer
Serial1.flush();
gcs.send_text_P(SEVERITY_LOW,PSTR("\n\n Ready to FLY.")); gcs.send_text_P(SEVERITY_LOW,PSTR("\n\n Ready to FLY."));
} }
@ -293,7 +296,14 @@ void set_mode(byte mode)
break; break;
case SIMPLE: case SIMPLE:
initial_simple_bearing = dcm.yaw_sensor; if(g.rc_3.control_in == 0){ // we are on the ground
if(initial_simple_bearing == -1){ // only set once
initial_simple_bearing = dcm.yaw_sensor;
}
}else if(initial_simple_bearing == -1){ // we are flying
// don't enter simple mode
control_mode = STABILIZE; // just stabilize
}
break; break;
case LOITER: case LOITER:
@ -310,7 +320,6 @@ void set_mode(byte mode)
// output control mode to the ground station // output control mode to the ground station
gcs.send_message(MSG_MODE_CHANGE); gcs.send_message(MSG_MODE_CHANGE);
} }
void set_failsafe(boolean mode) void set_failsafe(boolean mode)