I'd like to ask any of the math wizards out there if you can write and post an improved "get_bearing" function for the navigation tab of the ArduPilot source.
The more I test the ArduPilot code with my emulator, the more nervous I get. You'll notice in the screenshot of my 43MPH flight around Paris on my emulator, the ArduPilot decided to take a few loops around waypoints and the larger the distance between the waypoints, the greater the error in bearing.
Here's the existing get_bearing function
long get_bearing(struct Location *loc1, struct Location *loc2)
{
long off_x = loc2->lng - loc1->lng;
long off_y = (loc2->lat - loc1->lat) * scaleLongUp;
long bearing = 9000 + atan2(-off_y, off_x) * 5729.57795;
if (bearing < 0) bearing += 36000;
return bearing;
}
Comments
Serial.print("!!!");
Serial.print("STT:");
Serial.print((int)control_mode);
Serial.print(",WPN:");
Serial.print((int)wp_index);
Serial.print(",DST:");
Serial.print(wp_distance);
Serial.print(",RER:");
Serial.print(nav_roll/100);
Serial.print(",PSET:");
Serial.print(nav_pitch/100);
Serial.print(",THH:");
Serial.print(servo_throttle);
Serial.print(",WPR:");
Serial.print((int)wp_radius);
Serial.print(",ALT:");
Serial.print(current_loc.alt/100,DEC);
Serial.print(",ALH:");
Serial.print(next_WP.alt/100,DEC);
Serial.println(",***");
print_telemetry = false;
Jason
- Someone from the DIYDrones community would try this for real
- Someone from Paris would load the data and actually try it, the site would take the blame (I know the Frenchies and especially the Parisians, having some 30+ years of experience leaving there before managing to escape ;) )
Kind regards,
Lionel
Never the less, first step is to check for:
- The local regulation
- The open mindness of the authorities