2018 revision to classic DataBus AVC code.
Dependencies: LSM303DLM Servo SerialGraphicLCD L3G4200D IncrementalEncoder SimpleShell
SystemState.h@9:fc3575d2cbbf, 2018-12-07 (annotated)
- Committer:
- shimniok
- Date:
- Fri Dec 07 15:58:41 2018 +0000
- Revision:
- 9:fc3575d2cbbf
- Child:
- 24:a7f92dfc5310
Test gyro reading from shell.
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
shimniok | 9:fc3575d2cbbf | 1 | #ifndef _SYSTEMSTATE_H |
shimniok | 9:fc3575d2cbbf | 2 | #define _SYSTEMSTATE_H |
shimniok | 9:fc3575d2cbbf | 3 | |
shimniok | 9:fc3575d2cbbf | 4 | #define SSBUF 32 // must be 2^n |
shimniok | 9:fc3575d2cbbf | 5 | |
shimniok | 9:fc3575d2cbbf | 6 | /** System State is the main mechanism for communicating current realtime system state to |
shimniok | 9:fc3575d2cbbf | 7 | * the rest of the system for logging, data display, etc. |
shimniok | 9:fc3575d2cbbf | 8 | */ |
shimniok | 9:fc3575d2cbbf | 9 | |
shimniok | 9:fc3575d2cbbf | 10 | #include <stdbool.h> |
shimniok | 9:fc3575d2cbbf | 11 | |
shimniok | 9:fc3575d2cbbf | 12 | /* struct systemState |
shimniok | 9:fc3575d2cbbf | 13 | * structure containing system sensor data |
shimniok | 9:fc3575d2cbbf | 14 | ****** System Status |
shimniok | 9:fc3575d2cbbf | 15 | * millis number of milliseconds since epoch (or startup) |
shimniok | 9:fc3575d2cbbf | 16 | * current current draw in amps |
shimniok | 9:fc3575d2cbbf | 17 | * voltage voltage in volts |
shimniok | 9:fc3575d2cbbf | 18 | ****** Data reported by IMU |
shimniok | 9:fc3575d2cbbf | 19 | * g[3] raw 3-axis gyro values; if using 1-axis, then store data in gx |
shimniok | 9:fc3575d2cbbf | 20 | * gTemp Gyro temperature |
shimniok | 9:fc3575d2cbbf | 21 | * a[3] raw 3-axis accelerometer values |
shimniok | 9:fc3575d2cbbf | 22 | * m[3] raw 3-axis magnetometer values; if using 2d then store data in mx and my |
shimniok | 9:fc3575d2cbbf | 23 | * gHeading independently calculated gyro heading in degrees |
shimniok | 9:fc3575d2cbbf | 24 | * cHeading independently calculated compass heading in degrees |
shimniok | 9:fc3575d2cbbf | 25 | ****** AHRS Estimates |
shimniok | 9:fc3575d2cbbf | 26 | * roll, pitch, yaw estimated attitude in degrees relative to the world frame |
shimniok | 9:fc3575d2cbbf | 27 | ****** Data reported by GPS |
shimniok | 9:fc3575d2cbbf | 28 | * gpsLatitude raw GPS latitude in fractional degrees (e.g., 39.123456) |
shimniok | 9:fc3575d2cbbf | 29 | * gpsLongitude raw GPS longitude in fractional degrees (e.g., -104.123456 |
shimniok | 9:fc3575d2cbbf | 30 | * gpsCourse_deg raw GPS course in degrees |
shimniok | 9:fc3575d2cbbf | 31 | * gpsSpeed_mps raw GPS speed in m/s |
shimniok | 9:fc3575d2cbbf | 32 | * gpsHDOP raw GPS Horizontal Dilution of Precision |
shimniok | 9:fc3575d2cbbf | 33 | * gpsSats raw GPS Satellite fix count |
shimniok | 9:fc3575d2cbbf | 34 | ****** Odometry data |
shimniok | 9:fc3575d2cbbf | 35 | * lrEncDistance left rear encoder distance since last log update |
shimniok | 9:fc3575d2cbbf | 36 | * rrEncDistance right rear encoder distance since last log update |
shimniok | 9:fc3575d2cbbf | 37 | * lrEncSpeed left rear encoder speed |
shimniok | 9:fc3575d2cbbf | 38 | * rrEncSpeed right rear encoder speed |
shimniok | 9:fc3575d2cbbf | 39 | * encHeading estimated heading based on encoder readings |
shimniok | 9:fc3575d2cbbf | 40 | ****** Estimated Position and Heading |
shimniok | 9:fc3575d2cbbf | 41 | * estLagHeading estimated heading in degrees, lagged to sync with gps |
shimniok | 9:fc3575d2cbbf | 42 | * estHeading estimated current heading |
shimniok | 9:fc3575d2cbbf | 43 | * estLatitude estimated latitude in fractional degrees (e.g., 39.123456) |
shimniok | 9:fc3575d2cbbf | 44 | * estLongitude estimated longitude in fractional degrees (e.g., -104.123456) |
shimniok | 9:fc3575d2cbbf | 45 | * estNorthing some algorithms use UTM. Estimated UTM northing |
shimniok | 9:fc3575d2cbbf | 46 | * estEasting estimated UTM easting |
shimniok | 9:fc3575d2cbbf | 47 | * estX, estY some algorithms use simple x, y distance from origin (meters) |
shimniok | 9:fc3575d2cbbf | 48 | ****** Waypoint data |
shimniok | 9:fc3575d2cbbf | 49 | * nextWaypoint integer ID of the next waypoint |
shimniok | 9:fc3575d2cbbf | 50 | * bearing estimated bearing to next waypoint in degrees |
shimniok | 9:fc3575d2cbbf | 51 | * distance estimated distance to next waypoint in meters |
shimniok | 9:fc3575d2cbbf | 52 | ****** Control data |
shimniok | 9:fc3575d2cbbf | 53 | * throttle raw servo setting(units?) |
shimniok | 9:fc3575d2cbbf | 54 | * steering raw servo setting(units?) |
shimniok | 9:fc3575d2cbbf | 55 | */ |
shimniok | 9:fc3575d2cbbf | 56 | typedef struct { |
shimniok | 9:fc3575d2cbbf | 57 | unsigned int millis; |
shimniok | 9:fc3575d2cbbf | 58 | float current, voltage; |
shimniok | 9:fc3575d2cbbf | 59 | int g[3]; |
shimniok | 9:fc3575d2cbbf | 60 | float gyro[3]; |
shimniok | 9:fc3575d2cbbf | 61 | int gTemp; |
shimniok | 9:fc3575d2cbbf | 62 | int a[3]; |
shimniok | 9:fc3575d2cbbf | 63 | int m[3]; |
shimniok | 9:fc3575d2cbbf | 64 | float gHeading; |
shimniok | 9:fc3575d2cbbf | 65 | float cHeading; |
shimniok | 9:fc3575d2cbbf | 66 | //float roll, pitch, yaw; |
shimniok | 9:fc3575d2cbbf | 67 | double gpsLatitude; |
shimniok | 9:fc3575d2cbbf | 68 | double gpsLongitude; |
shimniok | 9:fc3575d2cbbf | 69 | float gpsCourse_deg; |
shimniok | 9:fc3575d2cbbf | 70 | float gpsSpeed_mps; |
shimniok | 9:fc3575d2cbbf | 71 | float gpsHDOP; |
shimniok | 9:fc3575d2cbbf | 72 | int gpsSats; |
shimniok | 9:fc3575d2cbbf | 73 | float lrEncDistance, rrEncDistance; |
shimniok | 9:fc3575d2cbbf | 74 | float lrEncSpeed, rrEncSpeed; |
shimniok | 9:fc3575d2cbbf | 75 | float encHeading; |
shimniok | 9:fc3575d2cbbf | 76 | float estHeading; |
shimniok | 9:fc3575d2cbbf | 77 | float estLagHeading; |
shimniok | 9:fc3575d2cbbf | 78 | double estLatitude, estLongitude; |
shimniok | 9:fc3575d2cbbf | 79 | //double estNorthing, estEasting; |
shimniok | 9:fc3575d2cbbf | 80 | float estX, estY; |
shimniok | 9:fc3575d2cbbf | 81 | unsigned short nextWaypoint; |
shimniok | 9:fc3575d2cbbf | 82 | float bearing; |
shimniok | 9:fc3575d2cbbf | 83 | float distance; |
shimniok | 9:fc3575d2cbbf | 84 | float gbias; |
shimniok | 9:fc3575d2cbbf | 85 | float errHeading; |
shimniok | 9:fc3575d2cbbf | 86 | float steerAngle; |
shimniok | 9:fc3575d2cbbf | 87 | float LABrg; |
shimniok | 9:fc3575d2cbbf | 88 | float LAx; |
shimniok | 9:fc3575d2cbbf | 89 | float LAy; |
shimniok | 9:fc3575d2cbbf | 90 | } SystemState; |
shimniok | 9:fc3575d2cbbf | 91 | |
shimniok | 9:fc3575d2cbbf | 92 | void state_clear( SystemState *s ); |
shimniok | 9:fc3575d2cbbf | 93 | bool fifo_init(void); |
shimniok | 9:fc3575d2cbbf | 94 | void fifo_reset(void); |
shimniok | 9:fc3575d2cbbf | 95 | bool fifo_available(void); |
shimniok | 9:fc3575d2cbbf | 96 | bool fifo_push(SystemState *s); |
shimniok | 9:fc3575d2cbbf | 97 | SystemState *fifo_first(void); |
shimniok | 9:fc3575d2cbbf | 98 | SystemState *fifo_last(void); |
shimniok | 9:fc3575d2cbbf | 99 | SystemState *fifo_pull(void); |
shimniok | 9:fc3575d2cbbf | 100 | int fifo_getInState(void); |
shimniok | 9:fc3575d2cbbf | 101 | int fifo_getOutState(void); |
shimniok | 9:fc3575d2cbbf | 102 | |
shimniok | 9:fc3575d2cbbf | 103 | #endif |