Replies

  • Hi,

    It appears just to be that way :)

    From the source, system.pde:

    static void set_mode(enum FlightMode mode)
    {
        if(control_mode == mode) {
            // don't switch modes if we are already in the correct mode.
            return;
        }

    // irrelevant code omitted

        control_mode = mode;
    // irrelevant code omitted


        switch(control_mode)
        {
    // irrelevant code omitted

        case AUTO:
            update_auto();
            break;

    and update_auto is:

    static void update_auto()
    {
        if (g.command_index >= g.command_total) {
            handle_no_commands();
            if(g.command_total == 0) {
                next_WP.lat             = home.lat + 1000;                  // so we don't have bad calcs
                next_WP.lng             = home.lng + 1000;                  // so we don't have bad calcs
            }
        } else {
            if(g.command_index != 0) {
                g.command_index = nav_command_index;
                nav_command_index--;
            }
            nav_command_ID  = NO_COMMAND;
            non_nav_command_ID      = NO_COMMAND;
            next_nav_command.id     = CMD_BLANK;
            process_next_command();
        }
    }

    In your case (re-engaging AUTO while g.command_index == g.command_total in other words, after AUTO was interrupted on its last leg) will do handle_no_commands() which is:

    static void handle_no_commands()
    {
        gcs_send_text_fmt(PSTR("Returning to Home"));
        next_nav_command = home;
        next_nav_command.alt = read_alt_to_hold();
        next_nav_command.id = MAV_CMD_NAV_LOITER_UNLIM;
        nav_command_ID = MAV_CMD_NAV_LOITER_UNLIM;
        non_nav_command_ID = WAIT_COMMAND;
        handle_process_nav_cmd();
    }

    effectively RTL.

    Now we only need to find out if g.command_index is really  == g.command_total (as I claim - I am not really sure) when approaching the last waypoint... It appears that when g.command_index is incremented, a message is sent (commands_process.pde):

        if (nav_command_index <= (int)g.command_total && non_nav_command_ID == NO_COMMAND) {
            temp = get_cmd_with_index(non_nav_command_index);
            if (temp.id <= MAV_CMD_NAV_LAST) {                       
                // The next command is a nav command.  No non-nav commands to do
                g.command_index.set_and_save(nav_command_index);
                non_nav_command_index = nav_command_index;
                non_nav_command_ID = WAIT_COMMAND;
                gcs_send_text_fmt(PSTR("Non-Nav command ID updated to #%i idx=%u"),
                                  (unsigned)non_nav_command_ID,
                                  (unsigned)non_nav_command_index);

    so it should be possible to see if that message is sent (somehow - where can one see the text messages?) with idx=2.

    Regards

    Soren

  • Derin, if you switch to AUTO after RTL, I think the APM should try to return towards WP2 since it has not yet reached it. Something is clearly wrong. Post your TLOG file, it`s easier to diagnose issues that way.

This reply was deleted.

Activity