Skip to content

Commit

Permalink
Copter: don't assume home is at the origin
Browse files Browse the repository at this point in the history
  • Loading branch information
jschall committed Feb 3, 2015
1 parent 46cbbe7 commit da84d13
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 2 deletions.
3 changes: 2 additions & 1 deletion ArduCopter/control_rtl.pde
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,8 @@ static void rtl_return_start()
rally_point.alt = max(rally_point.alt, current_loc.alt); // ensure we do not descend before reaching home
Vector3f destination = pv_location_to_vector(rally_point);
#else
Vector3f destination = Vector3f(0,0,get_RTL_alt());
Vector3f destination = pv_location_to_vector(ahrs.get_home());
destination.z = get_RTL_alt();
#endif

wp_nav.set_wp_destination(destination);
Expand Down
3 changes: 2 additions & 1 deletion ArduCopter/navigation.pde
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,8 @@ static void calc_home_distance_and_bearing()
// calculate home distance and bearing
if (position_ok()) {
home_distance = pythagorous2(curr.x, curr.y);
home_bearing = pv_get_bearing_cd(curr,Vector3f(0,0,0));
Vector3f home = pv_location_to_vector(ahrs.get_home());
home_bearing = pv_get_bearing_cd(curr,home);

// update super simple bearing (if required) because it relies on home_bearing
update_super_simple_bearing(false);
Expand Down

0 comments on commit da84d13

Please sign in to comment.