hello all.

I have a question, in the mode back to home, if you are higer of defined height, the aircraft first descends to the height defined, losing a lot of height.

can be configured so that the plane should go down to the height defined, and only up if it is below the height.??

Sorry for my english.

Views: 298

Reply to This

Replies to This Discussion

Hi, is that ArduCopter or ArduPlane?

Regards Soren



OK assuming ArduPlane since you write "plane",


In commands_logic.pde, ArduPlane 2.68: (I trust code more than documentation :)

static void do_RTL(void)
control_mode = RTL;
crash_timer = 0;
next_WP = home;
// Altitude to hold over home
// Set by configuration tool
// -------------------------
next_WP.alt = read_alt_to_hold();
if (g.log_bitmask & MASK_LOG_MODE)

It sets the next waypoint to home, with the altitude returned from read_static int32_t read_alt_to_hold()

alt_to_hold(). This is:

static int32_t read_alt_to_hold()
if (g.RTL_altitude_cm < 0) {
return current_loc.alt;
return g.RTL_altitude_cm + home.alt;

g.RTL_altitude_cm is another name for the ALT_HOLD_RTL parameter.

So if that parameter is <0, target altitude for RTL will be current altitude when RTL is engaged. Else it will be the value of the parameter in cm plus the home altitude.


In the medium loop of ArduPlane.pde:

// Read altitude from sensors (updates current_loc.alt)
// ------------------
// altitude smoothing
// ------------------
if (control_mode != FLY_BY_WIRE_B)

the latter is in navigation.pde:

static void calc_altitude_error()
if(control_mode == AUTO && offset_altitude_cm != 0) {
... ignore this part, as control_mode is not AUTO in our case....
} else if (non_nav_command_ID != MAV_CMD_CONDITION_CHANGE_ALT) {
target_altitude_cm = next_WP.alt;
altitude_error_cm = target_altitude_cm - adjusted_altitude_cm();


The computed value, altitude_error_cm, is used directly in Attitude.pde to control pitch and throttle.


calc_altitude_error() makes use of the function adjusted_altitude_cm:

static int32_t adjusted_altitude_cm(void)
return current_loc.alt - (g.alt_offset*100);

(g.alt_offset is a sort of manual correction usually left at zero)

So unless I am totally wrong here, this explains what I and probably also you have been seeing: Engaging RTL causes a very abrupt change in altitude (pitch will probably go right to the positive or negative) limit until the RTL altitude has been reached as by the read_alt_to_hold() logic.

If there is terrain in between that is higher than read_alt_to_hold() altitude, bye bye plane.

can (it) be configured so that the plane should go down to the height defined, and only up if it is below the height.??

It I read your question right, it does that alredy. If you are worried about crashing into something on the way home, set ALT_HOLD_RTL to something higher than the altitude of the highest hill around, minus the altitude of your airfield. Remember it's in centimeters. I will set mine to 50000 next time I fly..





Reply to Discussion



Season Two of the Trust Time Trial (T3) Contest 
A list of all T3 contests is here. The current round, the Vertical Horizontal one, is here

© 2020   Created by Chris Anderson.   Powered by

Badges  |  Report an Issue  |  Terms of Service