2015-05-13 00:16:45 -03:00
|
|
|
#include "Rover.h"
|
|
|
|
|
2012-04-30 04:17:14 -03:00
|
|
|
//****************************************************************
|
|
|
|
// Function that will calculate the desired direction to fly and distance
|
|
|
|
//****************************************************************
|
2015-05-12 02:03:23 -03:00
|
|
|
void Rover::navigate()
|
2012-04-30 04:17:14 -03:00
|
|
|
{
|
2016-12-20 09:33:29 -04:00
|
|
|
// do not navigate with corrupt data
|
|
|
|
// ---------------------------------
|
|
|
|
if (!have_position) {
|
|
|
|
return;
|
|
|
|
}
|
2012-04-30 04:17:14 -03:00
|
|
|
|
2016-12-20 09:33:29 -04:00
|
|
|
if ((next_WP.lat == 0 && next_WP.lng == 0) || (home_is_set == HOME_UNSET)){
|
|
|
|
return;
|
|
|
|
}
|
2012-04-30 04:17:14 -03:00
|
|
|
|
2016-12-20 09:33:29 -04:00
|
|
|
// waypoint distance from rover
|
|
|
|
// ----------------------------
|
|
|
|
wp_distance = get_distance(current_loc, next_WP);
|
2012-04-30 04:17:14 -03:00
|
|
|
|
2016-12-20 09:33:29 -04:00
|
|
|
// control mode specific updates to nav_bearing
|
|
|
|
// --------------------------------------------
|
|
|
|
update_navigation();
|
2012-04-30 04:17:14 -03:00
|
|
|
}
|
|
|
|
|
|
|
|
|