Code for autonomous rover for Sparkfun AVC. DataBus won 3rd in 2012 and the same code was used on Troubled Child, a 1986 Jeep Grand Wagoneer to win 1st in 2014.

Dependencies:   mbed Watchdog SDFileSystem DigoleSerialDisp

Committer:
shimniok
Date:
Tue May 28 13:58:35 2013 +0000
Revision:
1:cb84b477886c
Parent:
0:a6a169de725f
Child:
3:42f3821c4e54
Changed initial next/prev waypoint to permit steering calc. Removed unnecessary code, added logging for steering angle to diagnose bug.

Who changed what in which revision?

UserRevisionLine numberNew contents of line
shimniok 0:a6a169de725f 1 #ifndef _SYSTEMSTATE_H
shimniok 0:a6a169de725f 2 #define _SYSTEMSTATE_H
shimniok 0:a6a169de725f 3
shimniok 1:cb84b477886c 4 #define SSBUF 0x3F // 0b0000 0011 1111 1111
shimniok 0:a6a169de725f 5
shimniok 0:a6a169de725f 6 /** System State is the main mechanism for communicating current realtime system state to
shimniok 0:a6a169de725f 7 * the rest of the system for logging, data display, etc.
shimniok 0:a6a169de725f 8 */
shimniok 0:a6a169de725f 9
shimniok 0:a6a169de725f 10 /* struct systemState
shimniok 0:a6a169de725f 11 * structure containing system sensor data
shimniok 0:a6a169de725f 12 ****** System Status
shimniok 0:a6a169de725f 13 * millis number of milliseconds since epoch (or startup)
shimniok 0:a6a169de725f 14 * current current draw in amps
shimniok 0:a6a169de725f 15 * voltage voltage in volts
shimniok 0:a6a169de725f 16 ****** Data reported by IMU
shimniok 0:a6a169de725f 17 * g[3] raw 3-axis gyro values; if using 1-axis, then store data in gx
shimniok 0:a6a169de725f 18 * gTemp Gyro temperature
shimniok 0:a6a169de725f 19 * a[3] raw 3-axis accelerometer values
shimniok 0:a6a169de725f 20 * m[3] raw 3-axis magnetometer values; if using 2d then store data in mx and my
shimniok 0:a6a169de725f 21 * gHeading independently calculated gyro heading in degrees
shimniok 0:a6a169de725f 22 * cHeading independently calculated compass heading in degrees
shimniok 0:a6a169de725f 23 ****** AHRS Estimates
shimniok 0:a6a169de725f 24 * roll, pitch, yaw estimated attitude in degrees relative to the world frame
shimniok 0:a6a169de725f 25 ****** Data reported by GPS
shimniok 0:a6a169de725f 26 * gpsLatitude raw GPS latitude in fractional degrees (e.g., 39.123456)
shimniok 0:a6a169de725f 27 * gpsLongitude raw GPS longitude in fractional degrees (e.g., -104.123456
shimniok 0:a6a169de725f 28 * gpsCourse_deg raw GPS course in degrees
shimniok 0:a6a169de725f 29 * gpsSpeed_mps raw GPS speed in m/s
shimniok 0:a6a169de725f 30 * gpsHDOP raw GPS Horizontal Dilution of Precision
shimniok 0:a6a169de725f 31 * gpsSats raw GPS Satellite fix count
shimniok 0:a6a169de725f 32 ****** Odometry data
shimniok 0:a6a169de725f 33 * lrEncDistance left rear encoder distance since last log update
shimniok 0:a6a169de725f 34 * rrEncDistance right rear encoder distance since last log update
shimniok 0:a6a169de725f 35 * lrEncSpeed left rear encoder speed
shimniok 0:a6a169de725f 36 * rrEncSpeed right rear encoder speed
shimniok 0:a6a169de725f 37 * encHeading estimated heading based on encoder readings
shimniok 0:a6a169de725f 38 ****** Estimated Position and Heading
shimniok 1:cb84b477886c 39 * estLagHeading estimated heading in degrees, lagged to sync with gps
shimniok 1:cb84b477886c 40 * estHeading estimated current heading
shimniok 0:a6a169de725f 41 * estLatitude estimated latitude in fractional degrees (e.g., 39.123456)
shimniok 0:a6a169de725f 42 * estLongitude estimated longitude in fractional degrees (e.g., -104.123456)
shimniok 0:a6a169de725f 43 * estNorthing some algorithms use UTM. Estimated UTM northing
shimniok 0:a6a169de725f 44 * estEasting estimated UTM easting
shimniok 0:a6a169de725f 45 * estX, estY some algorithms use simple x, y distance from origin (meters)
shimniok 0:a6a169de725f 46 ****** Waypoint data
shimniok 0:a6a169de725f 47 * nextWaypoint integer ID of the next waypoint
shimniok 0:a6a169de725f 48 * bearing estimated bearing to next waypoint in degrees
shimniok 0:a6a169de725f 49 * distance estimated distance to next waypoint in meters
shimniok 0:a6a169de725f 50 ****** Control data
shimniok 0:a6a169de725f 51 * throttle raw servo setting(units?)
shimniok 0:a6a169de725f 52 * steering raw servo setting(units?)
shimniok 0:a6a169de725f 53 */
shimniok 0:a6a169de725f 54 typedef struct {
shimniok 0:a6a169de725f 55 unsigned int millis;
shimniok 0:a6a169de725f 56 float current, voltage;
shimniok 0:a6a169de725f 57 int g[3];
shimniok 0:a6a169de725f 58 int gTemp;
shimniok 0:a6a169de725f 59 int a[3];
shimniok 0:a6a169de725f 60 int m[3];
shimniok 0:a6a169de725f 61 float gHeading;
shimniok 0:a6a169de725f 62 float cHeading;
shimniok 0:a6a169de725f 63 //float roll, pitch, yaw;
shimniok 0:a6a169de725f 64 double gpsLatitude;
shimniok 0:a6a169de725f 65 double gpsLongitude;
shimniok 0:a6a169de725f 66 float gpsCourse_deg;
shimniok 0:a6a169de725f 67 float gpsSpeed_mps;
shimniok 0:a6a169de725f 68 float gpsHDOP;
shimniok 0:a6a169de725f 69 int gpsSats;
shimniok 0:a6a169de725f 70 float lrEncDistance, rrEncDistance;
shimniok 0:a6a169de725f 71 float lrEncSpeed, rrEncSpeed;
shimniok 0:a6a169de725f 72 float encHeading;
shimniok 0:a6a169de725f 73 float estHeading;
shimniok 1:cb84b477886c 74 float estLagHeading;
shimniok 0:a6a169de725f 75 double estLatitude, estLongitude;
shimniok 0:a6a169de725f 76 //double estNorthing, estEasting;
shimniok 0:a6a169de725f 77 float estX, estY;
shimniok 0:a6a169de725f 78 unsigned short nextWaypoint;
shimniok 0:a6a169de725f 79 float bearing;
shimniok 0:a6a169de725f 80 float distance;
shimniok 0:a6a169de725f 81 float gbias;
shimniok 0:a6a169de725f 82 float errAngle;
shimniok 1:cb84b477886c 83 float steerAngle;
shimniok 0:a6a169de725f 84 } SystemState;
shimniok 0:a6a169de725f 85
shimniok 0:a6a169de725f 86 #endif