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:
Mon May 27 13:26:03 2013 +0000
Revision:
0:a6a169de725f
Child:
1:cb84b477886c
Working version with priorities set and update time display

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 0:a6a169de725f 4 #define SSBUF 0x2F
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 0:a6a169de725f 39 * estHeading estimated heading in degrees, this is the robot's reference for heading
shimniok 0:a6a169de725f 40 * estLatitude estimated latitude in fractional degrees (e.g., 39.123456)
shimniok 0:a6a169de725f 41 * estLongitude estimated longitude in fractional degrees (e.g., -104.123456)
shimniok 0:a6a169de725f 42 * estNorthing some algorithms use UTM. Estimated UTM northing
shimniok 0:a6a169de725f 43 * estEasting estimated UTM easting
shimniok 0:a6a169de725f 44 * estX, estY some algorithms use simple x, y distance from origin (meters)
shimniok 0:a6a169de725f 45 ****** Waypoint data
shimniok 0:a6a169de725f 46 * nextWaypoint integer ID of the next waypoint
shimniok 0:a6a169de725f 47 * bearing estimated bearing to next waypoint in degrees
shimniok 0:a6a169de725f 48 * distance estimated distance to next waypoint in meters
shimniok 0:a6a169de725f 49 ****** Control data
shimniok 0:a6a169de725f 50 * throttle raw servo setting(units?)
shimniok 0:a6a169de725f 51 * steering raw servo setting(units?)
shimniok 0:a6a169de725f 52 */
shimniok 0:a6a169de725f 53 typedef struct {
shimniok 0:a6a169de725f 54 unsigned int millis;
shimniok 0:a6a169de725f 55 float current, voltage;
shimniok 0:a6a169de725f 56 int g[3];
shimniok 0:a6a169de725f 57 int gTemp;
shimniok 0:a6a169de725f 58 int a[3];
shimniok 0:a6a169de725f 59 int m[3];
shimniok 0:a6a169de725f 60 float gHeading;
shimniok 0:a6a169de725f 61 float cHeading;
shimniok 0:a6a169de725f 62 //float roll, pitch, yaw;
shimniok 0:a6a169de725f 63 double gpsLatitude;
shimniok 0:a6a169de725f 64 double gpsLongitude;
shimniok 0:a6a169de725f 65 float gpsCourse_deg;
shimniok 0:a6a169de725f 66 float gpsSpeed_mps;
shimniok 0:a6a169de725f 67 float gpsHDOP;
shimniok 0:a6a169de725f 68 int gpsSats;
shimniok 0:a6a169de725f 69
shimniok 0:a6a169de725f 70 double gpsLatitude2;
shimniok 0:a6a169de725f 71 double gpsLongitude2;
shimniok 0:a6a169de725f 72 float gpsCourse_deg2;
shimniok 0:a6a169de725f 73 float gpsSpeed_mps2;
shimniok 0:a6a169de725f 74 float gpsHDOP2;
shimniok 0:a6a169de725f 75 int gpsSats2;
shimniok 0:a6a169de725f 76
shimniok 0:a6a169de725f 77 float lrEncDistance, rrEncDistance;
shimniok 0:a6a169de725f 78 float lrEncSpeed, rrEncSpeed;
shimniok 0:a6a169de725f 79 float encHeading;
shimniok 0:a6a169de725f 80 float estHeading;
shimniok 0:a6a169de725f 81 double estLatitude, estLongitude;
shimniok 0:a6a169de725f 82 //double estNorthing, estEasting;
shimniok 0:a6a169de725f 83 float estX, estY;
shimniok 0:a6a169de725f 84 unsigned short nextWaypoint;
shimniok 0:a6a169de725f 85 float bearing;
shimniok 0:a6a169de725f 86 float distance;
shimniok 0:a6a169de725f 87 float gbias;
shimniok 0:a6a169de725f 88 float errAngle;
shimniok 0:a6a169de725f 89 float leftRanger;
shimniok 0:a6a169de725f 90 float rightRanger;
shimniok 0:a6a169de725f 91 float centerRanger;
shimniok 0:a6a169de725f 92 float crossTrackErr;
shimniok 0:a6a169de725f 93 } SystemState;
shimniok 0:a6a169de725f 94
shimniok 0:a6a169de725f 95 #endif