Multiwiiconf settings

This forum is dedicated to all issues and questions related to your individual setups and configurations
Post Reply
fly4fun6719
Posts: 26
Joined: Tue Jul 21, 2015 4:35 am

Multiwiiconf settings

Post by fly4fun6719 »

In the Multiwiiconf aux settings there is an option called "land".Under what conditions could that be used?I was hoping it could be used in conjunction with "return to home"if that was possible.Any advice greatly appreciated.

Kbev5709
Posts: 451
Joined: Mon Aug 17, 2015 5:56 pm

Re: Multiwiiconf settings

Post by Kbev5709 »

fly4fun6719 wrote:In the Multiwiiconf aux settings there is an option called "land".Under what conditions could that be used?I was hoping it could be used in conjunction with "return to home"if that was possible.Any advice greatly appreciated.

https://www.youtube.com/watch?v=tx4oGC6LOBU This video demonstrates someone using RTH with an autoland feature on multiwii. I must stress though that this is using an alternate version of the multiwii code found in this thread viewtopic.php?f=8&t=2965 from 3 years ago (and is probably still too big for a 328p) and as far as I can tell you will need to make sure all the version numbers are the same as what they were using and other things that will probably make your quad misbehave after changes if not done just right. Personally, I wouldn't even try it. The new code as downloaded in version 2.4 has incorporated the land into the mission function as far as I can tell. The following excerpts from the GPS.cpp sketch in the 2.4 arduino version of the multiwii code have many references to the land function as it is used in the mission and I would advise you to go through the entire GPS.cpp to see how integrated the land function is with the mission function (which is what a lot of the GPS.cpp code is for)

Code: Select all

 // Adjust altitude 
      // if we are holding position and reached target altitude, then ignore altitude nav, and let the user trim alt
      if ( !((NAV_state == NAV_STATE_HOLD_INFINIT) && (alt_change_flag == REACHED_ALT))) {
        if (!f.LAND_IN_PROGRESS) {
          alt_to_hold = get_new_altitude();
          AltHold = alt_to_hold;
        }
      }

      int16_t speed = 0;                   //Desired navigation speed

      switch(NAV_state)                    //Navigation state machine
        {
        case NAV_STATE_NONE:               //Just for clarity, do nothing when nav_state is none
          break;

        case NAV_STATE_LAND_START:
          GPS_calc_poshold();              //Land in position hold
          land_settle_timer = millis();
          NAV_state = NAV_STATE_LAND_SETTLE;
          break;

        case NAV_STATE_LAND_SETTLE:
          GPS_calc_poshold();
          if (millis()-land_settle_timer > 5000)
            NAV_state = NAV_STATE_LAND_START_DESCENT;
          break;

        case NAV_STATE_LAND_START_DESCENT:
          GPS_calc_poshold();                //Land in position hold
          f.THROTTLE_IGNORED = 1;            //Ignore Throtte stick input
          f.GPS_BARO_MODE    = 1;            //Take control of BARO mode
          land_detect = 0;                   //Reset land detector
          f.LAND_COMPLETED = 0;
          f.LAND_IN_PROGRESS = 1;            // Flag land process
          NAV_state = NAV_STATE_LAND_IN_PROGRESS;
          break;

        case NAV_STATE_LAND_IN_PROGRESS:
          GPS_calc_poshold();
          check_land();  //Call land detector
          if (f.LAND_COMPLETED) {
            nav_timer_stop = millis() + 5000;
            NAV_state = NAV_STATE_LANDED;
          }
          break;

        case NAV_STATE_LANDED:
          // Disarm if THROTTLE stick is at minimum or 5sec past after land detected
          if (rcData[THROTTLE]<MINCHECK || nav_timer_stop <= millis()) { //Throttle at minimum or 5sec passed.
            go_disarm();
            f.OK_TO_ARM = 0;                //Prevent rearming
            NAV_state = NAV_STATE_NONE;     //Disable position holding.... prevent flippover
            f.GPS_BARO_MODE = 0;
            f.LAND_COMPLETED = 0;
            f.LAND_IN_PROGRESS = 0;
            land_detect = 0;
            f.THROTTLE_IGNORED = 0;
            GPS_reset_nav();
          }
          break;

        case NAV_STATE_HOLD_INFINIT:        //Constant position hold, no timer. Only an rcOption change can exit from this
          GPS_calc_poshold();
          break;

        case NAV_STATE_HOLD_TIMED:
          if (nav_timer_stop == 0) {                         //We are start a timed poshold
            nav_timer_stop = millis() + 1000*nav_hold_time;  //Set when we will continue
          } else if (nav_timer_stop <= millis()) {           //did we reach our time limit ?
            if (mission_step.flag != MISSION_FLAG_END) {
              NAV_state = NAV_STATE_PROCESS_NEXT;            //if yes then process next mission step
            }
            NAV_error = NAV_ERROR_TIMEWAIT;
          }
          GPS_calc_poshold();                                //BTW hold position till next command
          break;

        case NAV_STATE_RTH_START:
          if ((alt_change_flag == REACHED_ALT) || (!GPS_conf.wait_for_rth_alt)) {             //Wait until we reach RTH altitude
            GPS_set_next_wp(&GPS_home[LAT],&GPS_home[LON], &GPS_coord[LAT], &GPS_coord[LON]); //If we reached then change mode and start RTH
            NAV_state = NAV_STATE_RTH_ENROUTE;
            NAV_error = NAV_ERROR_NONE;
          } else {
            GPS_calc_poshold();                                                               //hold position till we reach RTH alt
            NAV_error = NAV_ERROR_WAIT_FOR_RTH_ALT;
          }
          break;

Then there is all of this from the multiwii.cpp sketch:

Code: Select all

#ifdef INFLIGHT_ACC_CALIBRATION
  "CALIB;"
#endif
#ifdef GOVERNOR_P
  "GOVERNOR;"
#endif
#ifdef OSD_SWITCH
  "OSD SW;"
#endif
#if GPS
  "MISSION;"
  "LAND;"
#endif
  ;

const uint8_t boxids[] PROGMEM = {// permanent IDs associated to boxes. This way, you can rely on an ID number to identify a BOX function.
  0, //"ARM;"
  #if ACC
    1, //"ANGLE;"
    2, //"HORIZON;"
  #endif
  #if BARO && (!defined(SUPPRESS_BARO_ALTHOLD))
    3, //"BARO;"
  #endif
  #ifdef VARIOMETER
    4, //"VARIO;"
  #endif
  5, //"MAG;"
#if defined(HEADFREE)
  6, //"HEADFREE;"
  7, //"HEADADJ;" 
#endif
#if defined(SERVO_TILT) || defined(GIMBAL)|| defined(SERVO_MIX_TILT)
  8, //"CAMSTAB;"
#endif
#if defined(CAMTRIG)
  9, //"CAMTRIG;"
#endif
#if GPS
  10, //"GPS HOME;"
  11, //"GPS HOLD;"
#endif
#if defined(FIXEDWING) || defined(HELICOPTER)
  12, //"PASSTHRU;"
#endif
#if defined(BUZZER)
  13, //"BEEPER;"
#endif
#if defined(LED_FLASHER)
  14, //"LEDMAX;"
  15, //"LEDLOW;"
#endif
#if defined(LANDING_LIGHTS_DDR)
  16, //"LLIGHTS;"
#endif
#ifdef INFLIGHT_ACC_CALIBRATION
  17, //"CALIB;"
#endif
#ifdef GOVERNOR_P
  18, //"GOVERNOR;"
#endif
#ifdef OSD_SWITCH
  19, //"OSD_SWITCH;"
#endif
#if GPS
  20, //"MISSION;"
  21, //"LAND;"
#endif
also demonstrating the connection between mission and land and then finally there's this:

Code: Select all

 if ((wp_distance <= GPS_conf.wp_radius) || check_missed_wp()) {               //This decides what happen when we reached the WP coordinates 
            if (mission_step.action == MISSION_LAND) {                                  //Autoland
              NAV_state = NAV_STATE_LAND_START;                                         //Start landing
              set_new_altitude(alt.EstAlt);                                             //Stop any altitude changes
            } else if (mission_step.flag == MISSION_FLAG_END) {                         //If this was the last mission step (flag set by the mission planner), then switch to poshold
              NAV_state = NAV_STATE_HOLD_INFINIT;
              NAV_error = NAV_ERROR_FINISH;
            } else if (mission_step.action == MISSION_HOLD_UNLIM) {                     //If mission_step was POSHOLD_UNLIM and we reached the position then switch to poshold unlimited
              NAV_state = NAV_STATE_HOLD_INFINIT;
              NAV_error = NAV_ERROR_FINISH;
            } else if (mission_step.action == MISSION_HOLD_TIME) {                      //If mission_step was a timed poshold then initiate timed poshold
              nav_hold_time = mission_step.parameter1;
with the part of the code containing this

Code: Select all

 ((wp_distance <= GPS_conf.wp_radius) || check_missed_wp()) {               //This decides what happen when we reached the WP coordinates 
            if (mission_step.action == MISSION_LAND) {                                  //Autoland
              NAV_state = NAV_STATE_LAND_START;                                         //Start landing
and this code:

Code: Select all

case NAV_STATE_PROCESS_NEXT:                             //Processing next mission step
          NAV_error = NAV_ERROR_NONE;
          if (!recallWP(next_step)) {
            abort_mission(NAV_ERROR_WP_CRC);
          } else {
            switch(mission_step.action)
              {
              //Waypoiny and hold commands all starts with an enroute status it includes the LAND command too
              case MISSION_WAYPOINT:
              case MISSION_HOLD_TIME:
              case MISSION_HOLD_UNLIM:
              case MISSION_LAND:
                set_new_altitude(mission_step.altitude);
                GPS_set_next_wp(&mission_step.pos[LAT], &mission_step.pos[LON], &GPS_prev[LAT], &GPS_prev[LON]);
                if ((wp_distance/100) >= GPS_conf.safe_wp_distance)  abort_mission(NAV_ERROR_TOOFAR);
                else NAV_state = NAV_STATE_WP_ENROUTE;
                GPS_prev[LAT] = mission_step.pos[LAT];  //Save wp coordinates for precise route calc
                GPS_prev[LON] = mission_step.pos[LON];
                break;
              case MISSION_RTH:
                f.GPS_head_set = 0;
                if (GPS_conf.rth_altitude == 0 && mission_step.altitude == 0) //if config and mission_step alt is zero
                  set_new_altitude(alt.EstAlt);     // RTH returns at the actual altitude
                else {
                  uint32_t rth_alt;
                  if (mission_step.altitude == 0) rth_alt = GPS_conf.rth_altitude * 100;   //altitude in mission step has priority
                  else rth_alt = mission_step.altitude;

                  if (alt.EstAlt < rth_alt) set_new_altitude(rth_alt);                     //BUt only if we are below it.
                  else set_new_altitude(alt.EstAlt);
                }
                NAV_state = NAV_STATE_RTH_START;
                break;
              case MISSION_JUMP:
                if (jump_times == -10) jump_times = mission_step.parameter2;
                if (mission_step.parameter1 > 0 && mission_step.parameter1 < mission_step.number)
                  NAV_state = NAV_STATE_DO_JUMP;
                else //Error situation, invalid jump target
                  abort_mission(NAV_ERROR_INVALID_JUMP);
                break;
              case MISSION_SET_HEADING:
                GPS_poi[LAT] = 0; GPS_poi[LON] = 0; // zeroing this out clears the possible pervious set_poi
                if (mission_step.parameter1 < 0) f.GPS_head_set = 0;
                else {
                  f.GPS_head_set = 1;
                  GPS_directionToPoi = mission_step.parameter1;
                }
                break;
              case MISSION_SET_POI:
                GPS_poi[LAT] = mission_step.pos[LAT];
                GPS_poi[LON] = mission_step.pos[LON];
                f.GPS_head_set = 1;
                break;
              default:                                  //if we got an unknown action code abort mission and hold position
                abort_mission(NAV_ERROR_INVALID_DATA);
                break;
              }
            next_step++; //Prepare for the next step
          }
          break;
        } // switch end
    } //end of gps calcs ###0002
  }
  return 1;
} // End of GPS_compute

as the final proof that the land function is now a type of waypoint used in missions.
If you still want RTH and land to function together in that sequence without using the land in the mission feature set, you will have to try implementing the code that was used for that three years ago by this dude or write a new version of your own. So, your choices boil down to:
1. Try and modify your code to the 3 year old version.
2. Upgrade to a board that can do waypoint missions.
3. Completely re-write your own code to accomplish your goal.
4. Be happy with what you have.

fly4fun6719
Posts: 26
Joined: Tue Jul 21, 2015 4:35 am

Re: Multiwiiconf settings

Post by fly4fun6719 »

Thanks Kbev.All that sounds a bit beyond my limited experience so best if I stick to item 4.Tried the position hold and RTH today and both worked in winds up to 10 kph.In RTH mode waited till home,selected position hold and manually landed.With the limited memory of the board might be to stick with what I have.

Kbev5709
Posts: 451
Joined: Mon Aug 17, 2015 5:56 pm

Re: Multiwiiconf settings

Post by Kbev5709 »

fly4fun6719 wrote:Thanks Kbev.All that sounds a bit beyond my limited experience so best if I stick to item 4.Tried the position hold and RTH today and both worked in winds up to 10 kph.In RTH mode waited till home,selected position hold and manually landed.With the limited memory of the board might be to stick with what I have.

I plan on flying a mission using the land function and shoot a video of the flight as soon as weather permits. I have never even tried to use it in a mission so far because basically I can't trust my baro to still be accurate after the flight like it was after I zeroed it. But,I have decided to take a risk and see what happens when I do.

fly4fun6719
Posts: 26
Joined: Tue Jul 21, 2015 4:35 am

Re: Multiwiiconf settings

Post by fly4fun6719 »

Kbev5709 wrote:
fly4fun6719 wrote:Thanks Kbev.All that sounds a bit beyond my limited experience so best if I stick to item 4.Tried the position hold and RTH today and both worked in winds up to 10 kph.In RTH mode waited till home,selected position hold and manually landed.With the limited memory of the board might be to stick with what I have.

I plan on flying a mission using the land function and shoot a video of the flight as soon as weather permits. I have never even tried to use it in a mission so far because basically I can't trust my baro to still be accurate after the flight like it was after I zeroed it. But,I have decided to take a risk and see what happens when I do.


Could you let me know what the results were after you try it?

Kbev5709
Posts: 451
Joined: Mon Aug 17, 2015 5:56 pm

Re: Multiwiiconf settings

Post by Kbev5709 »

fly4fun6719 wrote:
Kbev5709 wrote:
fly4fun6719 wrote:Thanks Kbev.All that sounds a bit beyond my limited experience so best if I stick to item 4.Tried the position hold and RTH today and both worked in winds up to 10 kph.In RTH mode waited till home,selected position hold and manually landed.With the limited memory of the board might be to stick with what I have.

I plan on flying a mission using the land function and shoot a video of the flight as soon as weather permits. I have never even tried to use it in a mission so far because basically I can't trust my baro to still be accurate after the flight like it was after I zeroed it. But,I have decided to take a risk and see what happens when I do.


Could you let me know what the results were after you try it?

I will send you a link to the video, but it will be late March at the earliest.

fly4fun6719
Posts: 26
Joined: Tue Jul 21, 2015 4:35 am

Re: Multiwiiconf settings

Post by fly4fun6719 »

No problems.Thanks mate.

User avatar
Leo
Posts: 372
Joined: Wed Sep 17, 2014 7:01 am
Location: Germany
Contact:

Re: Multiwiiconf settings

Post by Leo »

I haven't tried that function either. Since I now have a backup QC from spare parts I had lying around I'm going to try it out too. I'll post a video of the flight as well.

fly4fun6719
Posts: 26
Joined: Tue Jul 21, 2015 4:35 am

Re: Multiwiiconf settings

Post by fly4fun6719 »

Thanks Leo.Will be very interested to see the results.

Kbev5709
Posts: 451
Joined: Mon Aug 17, 2015 5:56 pm

Re: Multiwiiconf settings

Post by Kbev5709 »

Leo wrote:I haven't tried that function either. Since I now have a backup QC from spare parts I had lying around I'm going to try it out too. I'll post a video of the flight as well.

In the mission function when you draw the land waypoint and click on it to open it for parameter editing, you can set the altitude. Are you going to set it to 0? It comes set with whatever the default waypoint height is set at. I can't see leaving the height at 25 meters when I am trying to land so it seems the obvious thing to do would be to set the altitude to 0.
Any ideas on this?

User avatar
Leo
Posts: 372
Joined: Wed Sep 17, 2014 7:01 am
Location: Germany
Contact:

Re: Multiwiiconf settings

Post by Leo »

Kbev5709 wrote:
Leo wrote:I haven't tried that function either. Since I now have a backup QC from spare parts I had lying around I'm going to try it out too. I'll post a video of the flight as well.

In the mission function when you draw the land waypoint and click on it to open it for parameter editing, you can set the altitude. Are you going to set it to 0? It comes set with whatever the default waypoint height is set at. I can't see leaving the height at 25 meters when I am trying to land so it seems the obvious thing to do would be to set the altitude to 0.
Any ideas on this?


My guess would be that the height parameter is ignored as soon as the land function is active. However I will see what happens when I get a chance to test it.

Kbev5709
Posts: 451
Joined: Mon Aug 17, 2015 5:56 pm

Re: Multiwiiconf settings

Post by Kbev5709 »

fly4fun6719 wrote:Thanks Leo.Will be very interested to see the results.

Go read Leo's posts in this topic viewtopic.php?f=8&t=2034&p=66806#p66806
There he mentions that if you can use EZ GUI to program missions into your FC a land can happen on a RTH. Although I never noticed it before, a "Land" options box pops up in the RTH settings menu that opens when you tap on the waypoint ID box. He says if you enter 1 in that box the quad will land (I would try 0 first I think.) I noticed that one problem with doing it that way is that the last waypoint goes away on the mission map. I think it works better when you just program a Land waypoint after a RTH and that way everything is still on the map. Once again though, even this is only possible if you can do a mission and I still don't think a 328p can do that considering it's tiny memory. He also posted a video of his quad doing an autoland by flipping a switch on his TX. You might be able to set up the Land function to work as a toggled on/off function using your TX as well. Then just do a RTH and then flip the switch and it lands.

Post Reply