Code for autonomous ground vehicle, Data Bus, 3rd place winner in 2012 Sparkfun AVC.
Dependencies: Watchdog mbed Schedule SimpleFilter LSM303DLM PinDetect DebounceIn Servo
Estimation/Mapping/Mapping.h@0:826c6171fc1b, 2012-06-20 (annotated)
- Committer:
- shimniok
- Date:
- Wed Jun 20 14:57:48 2012 +0000
- Revision:
- 0:826c6171fc1b
Updated documentation
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
shimniok | 0:826c6171fc1b | 1 | #ifndef __MAPPING_H |
shimniok | 0:826c6171fc1b | 2 | #define __MAPPING_H |
shimniok | 0:826c6171fc1b | 3 | |
shimniok | 0:826c6171fc1b | 4 | #include "GeoPosition.h" |
shimniok | 0:826c6171fc1b | 5 | #include "CartPosition.h" |
shimniok | 0:826c6171fc1b | 6 | |
shimniok | 0:826c6171fc1b | 7 | /** Maps GeoPosition latitude/longitude to CartPosition cartesian x,y |
shimniok | 0:826c6171fc1b | 8 | */ |
shimniok | 0:826c6171fc1b | 9 | class Mapping { |
shimniok | 0:826c6171fc1b | 10 | public: |
shimniok | 0:826c6171fc1b | 11 | /** Initialize mapping with a number of GeoPosition coordinates |
shimniok | 0:826c6171fc1b | 12 | * The maximum/minimum values for lat/lon are then used to form |
shimniok | 0:826c6171fc1b | 13 | * four coordinates and linear interpolation is used to map lat/lon to y/x |
shimniok | 0:826c6171fc1b | 14 | */ |
shimniok | 0:826c6171fc1b | 15 | void init(int count, GeoPosition *p); |
shimniok | 0:826c6171fc1b | 16 | /** Convert a GeoPosition to a CartPosition |
shimniok | 0:826c6171fc1b | 17 | * @param pos is the lat/lon pair |
shimniok | 0:826c6171fc1b | 18 | * @returns cart is the converted cartesian coordinate pair |
shimniok | 0:826c6171fc1b | 19 | */ |
shimniok | 0:826c6171fc1b | 20 | void geoToCart(GeoPosition pos, CartPosition *cart); |
shimniok | 0:826c6171fc1b | 21 | /** Convert a GeoPosition to a CartPosition |
shimniok | 0:826c6171fc1b | 22 | * @param x is the cartesian x coordinate |
shimniok | 0:826c6171fc1b | 23 | * @param y is the cartesian y coordinate |
shimniok | 0:826c6171fc1b | 24 | * @returns pos is the converted GeoPosition lat/lon coordinate pair |
shimniok | 0:826c6171fc1b | 25 | */ |
shimniok | 0:826c6171fc1b | 26 | void cartToGeo(float x, float y, GeoPosition *pos); |
shimniok | 0:826c6171fc1b | 27 | /** Convert a GeoPosition to a CartPosition |
shimniok | 0:826c6171fc1b | 28 | * @param cart is the x,y cartesian coordinate pair |
shimniok | 0:826c6171fc1b | 29 | * @returns pos is the converted GeoPosition lat/lon coordinate pair |
shimniok | 0:826c6171fc1b | 30 | */ |
shimniok | 0:826c6171fc1b | 31 | void cartToGeo(CartPosition cart, GeoPosition *pos); |
shimniok | 0:826c6171fc1b | 32 | |
shimniok | 0:826c6171fc1b | 33 | private: |
shimniok | 0:826c6171fc1b | 34 | double lonToX; |
shimniok | 0:826c6171fc1b | 35 | double latToY; |
shimniok | 0:826c6171fc1b | 36 | double latZero; |
shimniok | 0:826c6171fc1b | 37 | double lonZero; |
shimniok | 0:826c6171fc1b | 38 | }; |
shimniok | 0:826c6171fc1b | 39 | #endif |