Code for autonomous ground vehicle, Data Bus, 3rd place winner in 2012 Sparkfun AVC.

Dependencies:   Watchdog mbed Schedule SimpleFilter LSM303DLM PinDetect DebounceIn Servo

Embed: (wiki syntax)

« Back to documentation index

Show/hide line numbers Mapping.h Source File

Mapping.h

00001 #ifndef __MAPPING_H
00002 #define __MAPPING_H
00003 
00004 #include "GeoPosition.h"
00005 #include "CartPosition.h"
00006 
00007 /** Maps GeoPosition latitude/longitude to CartPosition cartesian x,y
00008  */
00009 class Mapping {
00010 public:
00011     /** Initialize mapping with a number of GeoPosition coordinates
00012      *  The maximum/minimum values for lat/lon are then used to form
00013      *  four coordinates and linear interpolation is used to map lat/lon to y/x
00014      */
00015     void init(int count, GeoPosition *p);
00016     /** Convert a GeoPosition to a CartPosition
00017      * @param pos is the lat/lon pair
00018      * @returns cart is the converted cartesian coordinate pair
00019      */
00020     void geoToCart(GeoPosition pos, CartPosition *cart);
00021     /** Convert a GeoPosition to a CartPosition
00022      * @param x is the cartesian x coordinate
00023      * @param y is the cartesian y coordinate
00024      * @returns pos is the converted GeoPosition lat/lon coordinate pair
00025      */
00026     void cartToGeo(float x, float y, GeoPosition *pos);
00027     /** Convert a GeoPosition to a CartPosition
00028      * @param cart is the x,y cartesian coordinate pair
00029      * @returns pos is the converted GeoPosition lat/lon coordinate pair
00030      */
00031     void cartToGeo(CartPosition cart, GeoPosition *pos);
00032 
00033 private:
00034     double lonToX;
00035     double latToY;
00036     double latZero;
00037     double lonZero;
00038 };
00039 #endif