element14 Community
element14 Community
    Register Log In
  • Site
  • Search
  • Log In Register
  • About Us
  • 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 Boards Community
    • Dev Tools
    • Manufacturers
    • Multicomp Pro
    • Product Groups
    • Raspberry Pi
    • RoadTests & Reviews
  • 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
      •  Korea (Korean)
      •  Malaysia
      •  New Zealand
      •  Philippines
      •  Singapore
      •  Taiwan
      •  Thailand (Thai)
      • 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 Sci Fi your Pi - Prince Dakkar's patent log taking chart compass - Direction of Travel Indicator 2
  • Blog
  • Forum
  • Documents
  • Files
  • Mentions
  • Sub-Groups
  • Tags
  • More
  • Cancel
  • New
  • Share
  • More
  • Cancel
Group Actions
  • Group RSS
  • More
  • Cancel
Engagement
  • Author Author: nbizzell
  • Date Created: 28 Aug 2015 10:39 PM Date Created
  • Views 706 views
  • Likes 1 like
  • Comments 0 comments
  • steampunk_navigation
  • projection
  • Design
  • map
  • gps
  • sci_fi_your_pi
  • mapping
Related
Recommended

Sci Fi your Pi - Prince Dakkar's patent log taking chart compass - Direction of Travel Indicator 2

nbizzell
nbizzell
28 Aug 2015

Previously:

Sci Fi Your Pi - Prince Dakkar's patent log taking chart compass

Sci Fi Your Pi - Prince Dakkar's patent log taking chart compass - Functional Design

Sci Fi Your Pi - Prince Dakkar's patent log taking chart compass - Route selection and indication

Sci Fi Your Pi - Prince Dakkar's patent log taking chart compass - Direction of Travel Indicator 1

Sci Fi your Pi - Prince Dakkar's patent log taking chart compass - Current Position

Sci Fi your Pi - Prince Dakkar's patent log taking chart compass - GPS Test

 

Direction of Travel Indicator 2

Having got the GPS working I could now get the GPS position for the current location and then compare that with the intended destination. The next challenge was to decide on some suitable destinations and to get the latitude and longitude for those places.

 

After a quick think I selected a short list of possible destinations to test the functionality (which would also act as start points for the route indication):

 

1. Sheffield

2. London

3. Perth

4. New York

5 St Petersburg

 

These destinations were chosen as they were visible on the map I had selected (and being based near Sheffield it would be easier to test using that as one of the destinations. They are also major cities that may feature in a steampunk adventure.

 

using Latitude Longitude Finder on Map Get Coordinates I came up with the following list.

 

1. latitude: 53.381129 longitude: -1.470085

2  51.507351  -0.127758

3. -31.953513 115.857047

4. 40.712784 -74.005941

5.  59.920613 30.322952

 

 

To test the device have set up these as variables and compare the position and print N or S and E or W to indicate the direction. Once the device is put together these would set a GPIO pin high to light an LED under the appropriate arrow.

 

To decide which way that the adventurer needs to travel the device needs to calculate the difference between the current location and the destination.

 

image

 

To calculate the direction to travel the latitude and longitude numbers of each location are compared. There is two ways to compare the numbers and indicate the direction to travel thatIi have considered.

 

The first is to simply take the destination figures away from the current location figure. If the result is a negative number then the destination is south (for latitude, west for longitude) of the current location so the adventure is shown the South arrow (West arrow for longitude) to move towards the destination. This gives a quick comparison and points the traveler towards the destination. The problem with this method is that if the destinations are at the edges of our flat map (with 0 0 at the centre) then the direction indicated could be moving all of the way around the world in the oposite direction to the one which would be the shortest way to get to the destination.


To correct this difficulty and travel in the shortest direction a correction need to be applied. To do this the difference can be used to check if the two positions are closer in the initial direction or by traveling in the opposite direction. This is actually simpler than it sounds as we just need to check if the difference is larger than 90 for latitude and larger for 180 for longitude then the traveler would be best served traveling in the opposite direction to that indicated above.

 

so that would be something like this (having got the position and in real python rather than a late night mix of python and pseudo python)

 

clat = current latitude
clong = current longitude
dlat = destination latitude
dlong = destination longitude

difflat = clat-dlat
difflong = clong-dlong

#for latitude
if difflat > 90 OR difflat < -90:
     if difflat > 0:
          print "N"
     else
          print "S"
else
     if difflat > 0:
          print "S"
     else
          print "N"

#for longitude
 if difflong > 180 OR difflong < -180:
     if difflat > 0 :
          print "W"
     else
          print "E"
else
     if difflat > 0:
          print "E"
     else
          print "W"


This would then go in a loop tested every few seconds and the print statements replaced with GPIO pins being set to high.


All sorted then, well not quite this would throw up issues if the destination was due south (or east, west or north) of the current position as the difference would be zero (although with the number of decimal places given by the GPS module you would have to be pretty accurately directly in line with the destination the problem still remains so a check to see if either difflong or difflat would be added before each section and no light in that section lit.


I also mentioned previously the possibility or adding the ordinals if there were sufficient pins left to do so. This would be a relatively easy task of adding a couple of variables and then seating those with the move directions. if both latitude and longitude required movement the appropriate ordinal could be lit up and only when there was no difference in Latitude or longitude would one of the cardinal points be lit.

 

The next job is to tidy up the above and get it running on the RPi as a test (which might happen this evening, but more likely over the weekend). Once the basic comparison is working i will then look at adding in the code to pick up the current and destination locations, With this part of the device working it could then function as a very basic navigation system. Having looked at blogs about the subject on here the idea occurred to me that I could use this part of the device as a way of locating geocaches if those locations were used instead of the major cities for the theatrical steampunk navigation device. Once in it's big case it may be a little impractical but adds an everyday use to what is going to be a bit of a novelty.

  • Sign in to reply
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