element14 Community
element14 Community
    Register Log In
  • Site
  • Search
  • Log In Register
  • Community Hub
    Community Hub
    • What's New on element14
    • Feedback and Support
    • Benefits of Membership
    • Personal Blogs
    • Members Area
    • Achievement Levels
  • Learn
    Learn
    • Ask an Expert
    • eBooks
    • element14 presents
    • Learning Center
    • Tech Spotlight
    • STEM Academy
    • Webinars, Training and Events
    • Learning Groups
  • Technologies
    Technologies
    • 3D Printing
    • FPGA
    • Industrial Automation
    • Internet of Things
    • Power & Energy
    • Sensors
    • Technology Groups
  • Challenges & Projects
    Challenges & Projects
    • Design Challenges
    • element14 presents Projects
    • Project14
    • Arduino Projects
    • Raspberry Pi Projects
    • Project Groups
  • Products
    Products
    • Arduino
    • Avnet & Tria Boards Community
    • Dev Tools
    • Manufacturers
    • Multicomp Pro
    • Product Groups
    • Raspberry Pi
    • RoadTests & Reviews
  • About Us
  • Store
    Store
    • Visit Your Store
    • Choose another store...
      • Europe
      •  Austria (German)
      •  Belgium (Dutch, French)
      •  Bulgaria (Bulgarian)
      •  Czech Republic (Czech)
      •  Denmark (Danish)
      •  Estonia (Estonian)
      •  Finland (Finnish)
      •  France (French)
      •  Germany (German)
      •  Hungary (Hungarian)
      •  Ireland
      •  Israel
      •  Italy (Italian)
      •  Latvia (Latvian)
      •  
      •  Lithuania (Lithuanian)
      •  Netherlands (Dutch)
      •  Norway (Norwegian)
      •  Poland (Polish)
      •  Portugal (Portuguese)
      •  Romania (Romanian)
      •  Russia (Russian)
      •  Slovakia (Slovak)
      •  Slovenia (Slovenian)
      •  Spain (Spanish)
      •  Sweden (Swedish)
      •  Switzerland(German, French)
      •  Turkey (Turkish)
      •  United Kingdom
      • Asia Pacific
      •  Australia
      •  China
      •  Hong Kong
      •  India
      • Japan
      •  Korea (Korean)
      •  Malaysia
      •  New Zealand
      •  Philippines
      •  Singapore
      •  Taiwan
      •  Thailand (Thai)
      • Vietnam
      • Americas
      •  Brazil (Portuguese)
      •  Canada
      •  Mexico (Spanish)
      •  United States
      Can't find the country/region you're looking for? Visit our export site or find a local distributor.
  • Translate
  • Profile
  • Settings
Sci Fi Your Pi
  • Challenges & Projects
  • Design Challenges
  • Sci Fi Your Pi
  • More
  • Cancel
Sci Fi Your Pi
Blog QuadCop: Navigation, how do I get to a specific GPS coordinate?
  • Blog
  • Forum
  • Documents
  • Files
  • Mentions
  • Sub-Groups
  • Tags
  • More
  • Cancel
  • New
  • Share
  • More
  • Cancel
Group Actions
  • Group RSS
  • More
  • Cancel
Engagement
  • Author Author: screamingtiger
  • Date Created: 22 Aug 2015 4:47 PM Date Created
  • Views 965 views
  • Likes 4 likes
  • Comments 5 comments
  • quadcop_project
  • design_challenge
  • 5883l
  • sci_fi_your_pi
Related
Recommended

QuadCop: Navigation, how do I get to a specific GPS coordinate?

screamingtiger
screamingtiger
22 Aug 2015

Previous Posts Here:

http://www.element14.com/community/tags#/?tags=quadcop_project

 

Im currently working on 2 major updates this weekend.  I am adding in some sci fi elements and installing sensors to give the QuadCOP a more Science Fiction Look.  The modifications also add quite a bit of realestate to place things and remove the clutter.

Here is a preview, stay tuned for some auwsome pictures of what this looks like when painted!

 

 

image

 

 

 

The other thing I am working on is testing the Raspberry Pi Flight System (RPFS) and I need to give you more information on how this works.  I have to demonstrate the actual functionality of the QuadCOP and it is time to do that.

I currently have about 2000 lines of original code between the systems not counting the TinyGPS++ library I used.  While not a lot, for an embedded system its not small!

 

Heading Information

Heading information is a number between 0 and 360 with 0 pointing magnetic north and 90 degrees pointing magnetic east.  The numbers get bigger as you rotate right and smaller as you rotate left unless you cross north.

For a 3D flight system, there are two forms of heading.  There is a GPS heading which shows the direction that the GPS unit is heading.  Then there is the quadcopter heading, which shows the direction the front of the quadcopter is pointing.

The reason this is important is that the quadcopter can move in one direction while facing another.  So the quad copter may be moving sidways and the GPS heading may say 90 degrees.  But the quadcopter may be pointing north.  The reason this is important to know is that without the quadcopter heading we don't know which way to move to change heading.   If we need to go east, and dont know which way the quadcopter is facing, do we go forward, backwards or sideways?   GPS Heading can also help with wind conditions.  If we are facing north but moving northeast, we know something is pushing us sidways and can make a correction to go due north.  This can be done by adding in some sideways velocity or pointing the front of the quad at an angle to and apply more forward velocity,

 

image

 

 

Way Point Information

A waypoint is a structure that contains altitude, longitude, latitude and heading information.  This information is sent to the RPFS 2 times per second.  So when in automode there are two waypoints.  The current position, and the destination.  The current position is stored in a waypoint structure since it fits nicely.

 

The are then two critical functions needed that let the QuadCOP navigate.  Both of these functions provide relevant information given two waypoints.

 

HeadingTo:  Given two waypoints, this returns a heading between 0 and 360 that points directly to destination.  This function is ran 2 times per second and is passed the current waypoint (current position) and the destination waypoint.  The heading is then updated to make the front of the QuadCOP point towards the destination.

 

DistanceBetween:  This provides the distance, in inches, between two waypoints.

 

 

How do we know when we reach the destination?  Well when the DistanceBetween the current position and the destination is "Zero".  Zero, is not really zero but a threshold that is good enough.  For my purposes 1 foot (.3 meters) is considered Zero.  I also have experimented with allowing the QuadCOP to move faster if the distance between is large enough.

 

 

 

CurrentSpeed:  This is calculated by the GPS.  It is not used by the waypoint functions but rather the flight heuristic system.  If the current speed is too fast, the QuadCop will slow down.  If it is too slow to QuadCOP an apply more power to move forward.  This allows correction for wind conditions that may affect flight.

 

 

The simplest approach to move between points is to always move forward.  This means that we have to keep the QuadCOP pointing in the direction of the next waypoint and apply a forward velocity to move in that direction.

 

Setting and Correcting Heading and Velocity

Two functions are used to get the QuadCOP going in the right direction.

 

SetHeading:  Given the required heading, it is compared with the current heading of the QuadCOP.   Care is needed to ensure that this is done correctly.  As an example., lets way we want to move due east at 90 degrees.  But the heading information shows 93 degrees.  This means we need to rotate left 3 degrees.  How does the QuadCOP know which direction to rotate?  A serious issue could happen if the QuadCOP tires to get to 90 degrees from 93 degrees by rotating right.  It would do nearly a 360 degree turn!  So simple care is needed to ensure we rotate the least amount.  We also need to make sure we don't over rotate.  So some heuristics are applied based on the correction needed.  If we only need to adjust 3 degrees, only a small amount of power is needed.

 

The amount of rotation we apply given the degree differential, is called the Heading Gain.  As an example, we are facing 93 degrees and need to get to 90 degrees by rotating left.  If we apply too much power, by the time the heading information is updated we have over corrected and now are facing 88 degrees.  So now another correction is needed to rotate right, and if we once again apply too mulch power we may up facing 92 degrees,  This cycle repeats quickly and causes a condition called "wag".

 

The front of the quad copter is looking left and right at a rapid pace and may never be able to hit its target.  If it gets bad enough it can cause the flight to become unstable.  Choosing the correct gain is an empirical processes that requires guesswork.  Also it is possible different values for the gain are needed at different times.  All of this is handled by the heuristic built into the RPFS so it can detect how its actions affect the sensor input and make adjustments as needed.

 

This seems fine for setting the heading but what about getting the QuadCOP moving?

I mentioned in previous posts the ControlSwitch (ChipKit Pi) is what actually controls the QuadCOP, the RPFS simply sends commands to the ControlSwitch to tell it what to do.  This done via ControlBytes.  These are a set of bytes that represent directions and adjustment information.  This simple structure ignores power information and will result in a small predetermined amount of power, in MicroSeconds, being applied in each direction.  Another control byte can be sent that is on a per direction level, with power information indicated.  This allows the QuadCOP to make fine adjustments in each direction as needed.  This to deal with the wind as discussed above.

 

So that concludes the first update for the weekend.  More to Come!  We are now getting into the fun stuff that final week!

 

 

 


  • Sign in to reply

Top Comments

  • balearicdynamics
    balearicdynamics over 10 years ago +1
    The project is going very good and the structure sounds futuristic. Very nice Does not impact with the winds, the big red and yellow legs ? Enrico
  • jw0752
    jw0752 over 10 years ago +1
    Thank you for the great insights into quad copter navigation. Really enjoyed the blog. John
  • jw0752
    jw0752 over 10 years ago in reply to screamingtiger +1
    Your nasty storm is on my doorstep as I type. I look forward to your video. John
Parents
  • jw0752
    jw0752 over 10 years ago

    Thank you for the great insights into quad copter navigation. Really enjoyed the blog.

    John

    • Cancel
    • Vote Up +1 Vote Down
    • Sign in to reply
    • More
    • Cancel
Comment
  • jw0752
    jw0752 over 10 years ago

    Thank you for the great insights into quad copter navigation. Really enjoyed the blog.

    John

    • Cancel
    • Vote Up +1 Vote Down
    • Sign in to reply
    • More
    • Cancel
Children
  • screamingtiger
    screamingtiger over 10 years ago in reply to jw0752

    Thanks John for the comment.  I have a bit more to explain.  I need to get a video of it being tested but had a nasty storm all day.  Will try for tomorrow!

    • Cancel
    • Vote Up 0 Vote Down
    • Sign in to reply
    • More
    • Cancel
  • jw0752
    jw0752 over 10 years ago in reply to screamingtiger

    Your nasty storm is on my doorstep as I type. I look forward to your video.

    John

    • Cancel
    • Vote Up +1 Vote Down
    • Sign in to reply
    • More
    • Cancel
element14 Community

element14 is the first online community specifically for engineers. Connect with your peers and get expert answers to your questions.

  • Members
  • Learn
  • Technologies
  • Challenges & Projects
  • Products
  • Store
  • About Us
  • Feedback & Support
  • FAQs
  • Terms of Use
  • Privacy Policy
  • Legal and Copyright Notices
  • Sitemap
  • Cookies

An Avnet Company © 2025 Premier Farnell Limited. All Rights Reserved.

Premier Farnell Ltd, registered in England and Wales (no 00876412), registered office: Farnell House, Forge Lane, Leeds LS12 2NE.

ICP 备案号 10220084.

Follow element14

  • X
  • Facebook
  • linkedin
  • YouTube