Autonomous Flight

Post Reply
awoods177
Posts: 14
Joined: Mon Apr 30, 2012 10:08 pm

Autonomous Flight

Post by awoods177 »

Hi all,

I have been playing around with a quad using a MultiWii SE board and your standard TX/RX combo but I would like to make it autonomous.

My immediate goal is to simply to have it hover at a given height for say 10 seconds and then land.

In the future more complex maneuvers would be in store but for now I'm taking baby steps.

Has anyone ever done this with MultiWii? I know that the Arducopters on DIYdrones.com do this (and more...) but I already have the MultiWii copter and would like to minimize cost.

If it's not possible with the MiltiWii software, is there anyway to adapt the Arducopter Autopilot to the MultiWii board?

--Alex

Pyrofer
Posts: 180
Joined: Sat Apr 14, 2012 2:55 pm

Re: Autonomous Flight

Post by Pyrofer »

If you want accurate height hold for take off and landing you probably want a sonar sensor.
Stick in GPS and you are well on the way to having it do what you want.

Arf
Posts: 22
Joined: Tue May 22, 2012 10:48 pm

Re: Autonomous Flight

Post by Arf »

The approach I will be using is to insert another micro controller between the receiver and the FC which will have additional sensors to auto pilot, thus leaving the FC to do the things which it already does well. ie. treat the MWC as a black box and leave it unchanged.

Wayne
Posts: 86
Joined: Sun Jul 31, 2011 10:44 pm

Re: Autonomous Flight

Post by Wayne »

Have you seen what Copterrichie is doing….
viewtopic.php?f=6&t=1611
He has that very setup.

awoods177
Posts: 14
Joined: Mon Apr 30, 2012 10:08 pm

Re: Autonomous Flight

Post by awoods177 »

it seems like it would be fairly simple to use all the given hardware and sensors (although I'm sure sonar would be more accurate) but just use modified code.

For example, put in code that says

ground alt = estimated alt
desired alt = ground alt + 2 (in meters, or whatever)

while estimated alt < desired alt
turn on motors
***some kind of PID thing here***
end while

***normal altitude hold code here***

delay a few seconds

desired alt = ground alt

while estimated alt > desired alt
***controlled descent***
endwhile

Obviously this is a very very rough draft that I just came up with off the top of my head but I don't see any reason why it wouldn't work.

The problems I am having are figuring out WHERE to put this code, and how to actually control the output of the motors so as not to shoot past desired altitude and how to do a controlled descent. Hell, I don't even know how to tell the motors to turn on. I looked at the write motor and mixtable function in the code but i'm not sure how they work.

copterrichie
Posts: 2261
Joined: Sat Feb 19, 2011 8:30 pm

Re: Autonomous Flight

Post by copterrichie »

I hope to adapt this old Lunar lander game to enable auto landing. Because of resources, building is slow but we are making some progress.

http://phet.colorado.edu/en/simulation/lunar-lander

ocugod09
Posts: 4
Joined: Mon Nov 28, 2016 3:09 pm

Re: Autonomous Flight

Post by ocugod09 »

Hi Alex,

I was wondering if you managed to make your multiWii Quadcopter fly autonomously? I'm in a similar boat right now except instead of using sonar I've got a Lidar. If yes, could you tell me what you used to communicate/control it?

Also, thanks very in advance for responding to a 4 year old discussion :D

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

Re: Autonomous Flight

Post by Kbev5709 »

ocugod09 wrote:Hi Alex,

I was wondering if you managed to make your multiWii Quadcopter fly autonomously? I'm in a similar boat right now except instead of using sonar I've got a Lidar. If yes, could you tell me what you used to communicate/control it?

Also, thanks very in advance for responding to a 4 year old discussion :D

This thread is so old it was made before MW used GPS. Just go upload MW 2.4 and get a good Ublox GPS module. Use win gui or ez gui and you can fly autonomously using gps. I do it all the time. It's called waypoint navigation.

ocugod09
Posts: 4
Joined: Mon Nov 28, 2016 3:09 pm

Re: Autonomous Flight

Post by ocugod09 »

Hey, thanks for the reply but I'm still a little lost.
Would a module like this one https://www.amazon.com/U-blox-Module-Mu ... B00KTYRZC8 or this one http://www.robotshop.com/en/gps-bee-min ... tenna.html be everything I need to communicate with the drone from my laptop. If so how do you connect it to the multiWii FC?
Sorry if this is obvious but I can't find a clear answer to this online..

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

Re: Autonomous Flight

Post by Kbev5709 »

ocugod09 wrote:Hey, thanks for the reply but I'm still a little lost.
Would a module like this one https://www.amazon.com/U-blox-Module-Mu ... B00KTYRZC8 or this one http://www.robotshop.com/en/gps-bee-min ... tenna.html be everything I need to communicate with the drone from my laptop.
The first one is most likely the better choice of the two you listed in your links. The autonomous flights are pre-programmed by you on your laptop using win gui then uploaded to the FC. Your FC must have sufficient memory to actually do waypoint navigation. An old 328P based processor won't work. I noticed from another thread you posted that you use a Flip MCW Flight Controller 1.5. That FC is based on a 328P. The GPS module only communicates with the FC and the GPS satellites. You still need a TX of some sort even for autonomous flight if for nothing else than at least to set the flight mode and arm the craft.
ocugod09 wrote:If so how do you connect it to the multiWii FC?
Sorry if this is obvious but I can't find a clear answer to this online..
This depends entirely on which FC and GPS module you use. With most MW FC's the GPS is used on a serial port (TX, RX, +5v, Gnd.) You must set everything up in the firmware's GPS section. It is not easy to learn everything you need to know for successful GPS performance but the info is out there. I didn't figure mine out by accident.
Following is a working snippet of a config.h GPS sketch set up to run Ublox GPS at 57600.

Code: Select all

 /**************************************************************************************/
  /***********************                  GPS                **************************/
  /**************************************************************************************/

    /* ENable this for using GPS simulator (NMEA only)*/
    //#define GPS_SIMULATOR

    /* GPS using a SERIAL port
       if enabled, define here the Arduino Serial port number and the UART speed
       note: only the RX PIN is used in case of NMEA mode, the GPS is not configured by multiwii
       in NMEA mode the GPS must be configured to output GGA and RMC NMEA sentences (which is generally the default conf for most GPS devices)
       at least 5Hz update rate. uncomment the first line to select the GPS serial port of the arduino */
       
    #define GPS_SERIAL 2         // should be 2 for flyduino v2. It's the serial port number on arduino MEGA
                                   // must be 0 for PRO_MINI (ex GPS_PRO_MINI)
                                   // note: Now a GPS can share MSP on the same port. The only constrain is to not use it simultaneously, and use the same port speed.

    // avoid using 115200 baud because with 16MHz arduino the 115200 baudrate have more than 2% speed error (57600 have 0.8% error)
    #define GPS_BAUD   57600       // GPS_BAUD will override SERIALx_COM_SPEED for the selected port

   /* GPS protocol
       NMEA  - Standard NMEA protocol GGA, GSA and RMC  sentences are needed
       UBLOX - U-Blox binary protocol, use the ublox config file (u-blox-config.ublox.txt) from the source tree
       MTK_BINARY16 and MTK_BINARY19 - MTK3329 chipset based GPS with DIYDrones binary firmware (v1.6 or v1.9)
       With UBLOX and MTK_BINARY you don't have to use GPS_FILTERING in multiwii code !!! */

   
    //#define NMEA
    #define UBLOX
    //#define MTK_BINARY16
    //#define MTK_BINARY19
    //#define INIT_MTK_GPS        // initialize MTK GPS for using selected speed, 5Hz update rate and GGA & RMC sentence or binary settings


    /* I2C GPS device made with an independant arduino + GPS device
       including some navigation functions
       contribution from EOSBandi   http://code.google.com/p/i2c-gps-nav/
       You have to use at least I2CGpsNav code r33 */
    /* all functionnalities allowed by SERIAL_GPS are now available for I2C_GPS: all relevant navigation computations are gathered in the main FC */

    //#define I2C_GPS

    // If your I2C GPS board has Sonar support enabled
    //#define I2C_GPS_SONAR

    /* indicate a valid GPS fix with at least 5 satellites by flashing the LED  - Modified by MIS - Using stable LED (YELLOW on CRIUS AIO) led work as sat number indicator
      - No GPS FIX -> LED blink at speed of incoming GPS frames
      - Fix and sat no. bellow 5 -> LED off
      - Fix and sat no. >= 5 -> LED blinks, one blink for 5 sat, two blinks for 6 sat, three for 7 ... */
    #define GPS_LED_INDICATOR

   //Enables the MSP_WP command set , which is used by WinGUI for displaying an setting up navigation
    #define USE_MSP_WP

   // HOME position is reset at every arm, uncomment it to prohibit it (you can set home position with GyroCalibration)   
   //#define DONT_RESET_HOME_AT_ARM

/* GPS navigation can control the heading */

// copter faces toward the navigation point, maghold must be enabled for it
#define NAV_CONTROLS_HEADING       1    //(**)
// true - copter comes in with tail first
#define NAV_TAIL_FIRST             0    //(**)
// true - when copter arrives to home position it rotates it's head to takeoff direction
#define NAV_SET_TAKEOFF_HEADING    1    //(**)

/* Get your magnetic declination from here : http://magnetic-declination.com/
Convert the degree+minutes into decimal degree by ==> degree+minutes*(1/60)
Note the sign on declination it could be negative or positive (WEST or EAST)
Also note, that maqgnetic declination changes with time, so recheck your value every 3-6 months */
#define MAG_DECLINATION -5.2f   //(**)<<<Change to match your flight location.

// Adds a forward predictive filterig to compensate gps lag. Code based on Jason Short's lead filter implementation
#define GPS_LEAD_FILTER               //(**)

// add a 5 element moving average filter to GPS coordinates, helps eliminate gps noise but adds latency comment out to disable
// use it with NMEA gps only
//#define GPS_FILTERING                 //(**)

// if we are within this distance to a waypoint then we consider it reached (distance is in cm)
#define GPS_WP_RADIUS              100      //(**)

// Safe WP distance, do not start mission if the first wp distance is larger than this number (in meters)
// Also aborts mission if the next waypoint distance is more than this number
#define SAFE_WP_DISTANCE           200      //(**)

//Maximu allowable navigation altitude (in meters) automatic altitude control will not go above this height
#define MAX_NAV_ALTITUDE           80     //(**)

// minimum speed when approach waypoint
#define NAV_SPEED_MIN              100    // cm/sec //(**)
// maximum speed to reach between waypoints
#define NAV_SPEED_MAX              500    // cm/sec //(**)
// Slow down to zero when reaching waypoint (same as NAV_SPEED_MIN = 0)
#define NAV_SLOW_NAV               0      //(**)
// Weight factor of the crosstrack error in navigation calculations (do not touch)
#define CROSSTRACK_GAIN            .4     //(**)
// Maximum allowable banking than navigation outputs
#define NAV_BANK_MAX 3000                 //(**)

//Defines the RTH altitude. 0 means keep current alt during RTH (in meters)
#define RTH_ALTITUDE               15        //(**)
//Wait to reach RTH alt before start moving to home (0-no, 1-yes)
#define WAIT_FOR_RTH_ALT           1         //(**)

//Navigation engine will takeover BARO mode control
#define NAV_TAKEOVER_BARO          1         //(**)

//Throttle stick input will be ignored  (only in BARO)
#define IGNORE_THROTTLE            1         //(**)

//If FENCE DISTANCE is larger than 0 then copter will switch to RTH when it farther from home
//than the defined number in meters
#define FENCE_DISTANCE      600

//This governs the descent speed during landing. 100 is equals approc 50cm/sec
#define LAND_SPEED          100


    //#define ONLY_ALLOW_ARM_WITH_GPS_3DFIX      // Only allow FC arming if GPS has a 3D fix.

You could just copy and paste this into your sketch but if you do you will still need to change the magnetic declination from -5.2f to whatever the proper reading is for where you will fly. One of the best ways to learn how to set up the MW software is to simply read the descriptions included after each option, then decide if it is what you want or not.
If I were you and I wanted to do autonomous flight, I would first upgrade my FC to a MEGA Atmega2560 processor and then get the GPS module.

Post Reply