/*--------------------------------------------------------------------------------------------------- ** ISC - Inertial Solutions Controller ** NAV - Navigation computer ** Revision history: ** Created 4 Aug 2003, NH. ** Modification 14 Aug. NH. ** 1. IMU message output rate is increased to 8 messages per second (See IMUMSG comments) ** 2. A new Odometry message output is sent 8 messages per second (See new ODEMSG). ** 4 odometry/counter input channels each report grand total count and counts per second. ** 3. A new message carrying slowly changing parameters like temperture, fuel level, etc is created. ** See SLOWMSG defined below. Reporting interval is 8 seconds except for spontaneous send on ** change of status like Manual Override activate or deactivate, or exception conditions, TBD. ** 4. A new command message from the navigation computer defining servo "set point" and slew rate is ** defined. See SETMSG below. It will override/disconnect PID control OR restore PID control. ** 5. Discrete controls for automatic transmission shifting, starter, are defined in the CARMSG below. ** Modification 18 Aug. NH ** 1. MANMSG added - Maneuver message. ** 2. BITMSG added - Bit controls. ** 3. GPSMSG enhancements. Circular Error probability. ** 4. SETMSG enhancements. ** Modification 8 April 2005 N.H. ** Addition of Ultrasonic sensors. Note: IMUMSG, ODEMSG, ISC to NAV update rate remains at 8 per second. (125 msec per message). /****************************************************************************** * Copyright (c) 2005 Nelson Henderson * * Permission to use, copy, modify, and distribute this software for any * purpose without fee is hereby granted, provided that this entire notice * is included in all copies of any software source which includes a copy of, * or any software source code which is derived from modifications to this source code. * * THIS SOFTWARE IS BEING PROVIDED "AS IS", WITHOUT ANY EXPRESS OR IMPLIED * WARRANTY. IN PARTICULAR, THE AUTHOR DOES NOT MAKE ANY REPRESENTATION OR * WARRANTY OF ANY KIND CONCERNING THE MERCHANTABILITY OF THIS SOFTWARE OR ITS * FITNESS FOR ANY PARTICULAR PURPOSE. * * Please report bugs or send useful modifications to: * Nelson Henderson email: nelson@inertialsolutions.us * *************************************************************************/ #define BYTE unsigned char #define USHORT unsigned short #define WORD unsigned short #define ULONG unsigned long /********************************************************************************** * Added 18 Aug 2003 * New MANMSG: Begin a maneuver at an optionally-specified absolute_wheel_count. * A maneuver sets steering, throttle, brake, and gear position to a desired * setpoint at a specified slew rate, and provides for roll-out angle and * max speed limit. An absolute_wheel_count value of 0 indicates * beginning the maneuver immediately. * * Normal control messaging, optional distance based, optional exit or "roll out" heading /**********************************************************************************/ /* NAV to ISC sent anytime */ struct MANMSG { /* Synchronization word */ USHORT unique_word; /* Word 1, 0xff80 - 0xff first, 0x81 second */ USHORT msgID; /* Word 2, */ USHORT msglength; /* Word 3, Number of words in the structure. Including unique_word and checksum */ unsigned long start_count; /* Word 4,absolute wheel count to start command execution. */ /* 0 = Immediate override to current command execution. */ /**** MESSAGES TO STEERING CHANNEL TAKE THIS FORMAT***/ short steer_channel; /* Word 5, Servo output channel, 0 - 7 [0] */ short steer_angle; /* Word 6, +/- steering angle(absolute deflection angle) .1 degrees.*/ short steer_step_size; /* Word 7, Slew step size, 0 to 1048 */ short exit_heading; /* Word 8, Target heading on go straight, exit heading on turn. */ /* 512 = Ignore roll out angle, Integer Units = .1 degrees*/ /**** MESSAGES TO THROTTLE CHANNEL TAKE THIS FORMAT***/ short throttle_channel; /* Word 9, Servo output channel, 0 - 7 [1] */ short throttle_pos; /* Word 10, throttle angle(absolute deflection angle) 0 to 1048 */ short throttle_step_size; /* Word 11, Slew step size, 0 to 1048 */ /**** MESSAGES TO BRAKING CHANNEL TAKE THIS FORMAT***/ short brake_channel; /* Word 12, Servo output channel, 0 - 7 [2] */ short brake_pos; /* Word 13, braking severity(absolute deflection angle) 0 to 1048 */ short brake_step_size; /* Word 14, Slew step size, 0 to 1048 */ short ITC_channel; /* Word 15, Input Transition Counter (ITC) channel #, 0 - 3 */ short max_speed; /* Word 16, availiable to brake or throttle, 0= full stop */ short transmission_set; /* Word 17, Current,setting: Discrete 0 = Neutral, 1 = first gear, 2 = second gear, 3 = 3rd gear, 4 = fourth gear, 5 = 5th gear -1 = reverse. Transmission ignored if invalid (transmission_set > 5) */ USHORT checksum; // Word 18, The method is to sum the entire structure from the unique_word // up to, but excluding the checksum word. All math is performed using // signed 16 bit integers with carries, or overflows, ignored. The sum is // negated. }; typedef struct MANMSG MANMSGst; /*-------------------------------------------------------------------------------------------------- * SET message structure. Slew from present servo output setting to new setting 16 times per second * at the given step size. Fractional modulo step sizes are accounted for * The step size is converted to an absolute number. Direction is determined by the command processor * in the controller by compairing present setting to the new setting command, thus relieving * the navigation computer of having to know the in transit servo position before issuing a new command. * Forbidden conditions: * a. Step size = 0: The control computer will set the new position in one step. * b. Step size = bad size: The control computer will set the new position in one step. * c. Set position invalid: The control computer will set the new position to the default (often center). --------------------------------------------------------------------------------------------------*/ /* NAV to ISC sent anytime */ struct SETMSG { /* Synchronization word */ USHORT unique_word; /* Word 1, 0xff80 - 0xff first, 0x81 second */ USHORT msgID; /* Word 2, */ USHORT msglength; /* Word 3, Number of words in the structure. Including unique_word and checksum */ short command; /* Word 4, 0 = Restore PID control to channel. */ /* 1 = Replace PID with given setting. */ short servo_channel; /* Word 5, Servo output channel, 0 - 7 */ short setting; /* Word 6, Setting. range 1048 to 2096 */ short step_size; /* Word 7, Slew step size, 0 to 1048 */ short transmission_set; /* Word 8, Current,setting: Discrete 0 = Neutral, 1 = first gear, 2 = second gear, 3 = 3rd gear, 4 = fourth gear, 5 = 5th gear -1 = reverse. Transmission ignored if invalid (transmission_set > 5) */ USHORT checksum; // Word 9, The method is to sum the entire structure from the unique_word // up to, but excluding the checksum word. All math is performed using // signed 16 bit integers with carries, or overflows, ignored. The sum is // negated. }; typedef struct SETMSG SETMSGst; /*--------------------------------------------------------------------------------------------------- * Discrete BIT control message structure. Direct bit set or reset sent by NAV to ISC. * * BIT Msg causes ISC unit to release automatic control to the NAV navigation computer. * Re-connect TBD *---------------------------------------------------------------------------------------------------*/ /* NAV to ISC sent anytime */ struct BITMSG { /* Synchronization word */ USHORT unique_word; /* Word 1, 0xff80 - 0xff first, 0x81 second */ USHORT msgID; /* Word 2, */ USHORT msglength; /* Word 3, Number of words in the structure. Including unique_word and checksum */ short command; /* Word 4, 0 = Restore PID control to channel. */ /* 1 = Replace PID with given setting. */ short discrete_channel; /* Word 5, discrete I/O channel */ short on_off; /* Word 6, 0=OFF, 1= ON */ short starter; /* Word 7 TRUE = Activate starter motor, ignition on. FALSE = DeActivate starter motor. */ short ignition; /* Word 8 FALSE = Ignition off. */ short emergency_halt; /* Word 9 TRUE = Engine ignition off, set default brake, throttle, steering. */ USHORT checksum; // Word 10, The method is to sum the entire structure from the unique_word // up to, but excluding the checksum word. All math is performed using // signed 16 bit integers with carries, or overflows, ignored. The sum is // negated. }; typedef struct BITMSG BITMSGst; /*--------------------------------------------------------------------------------------------------- * ODE message structure. Information sent by ISC control computer 8 times per second. 14 Aug 2003 N.H. * Periodic Interval Timer (PIT) is ultimately is derived from the 32.768 KHz CPU oscillator. * this oscillator produces a 16,777,000 CPU clock divided by 16 = 1,048,562 Hz. * * 1 PIT interrupt = 1/1024 sec = .9765625 msec (PIT_count) * 16 PIT interrupts = 1/64 sec = 15.625 msec * 128 PIT interrupts = 1/8th sec = 125 msec (exactly!) This is the ODEMSG reporting interval. ---------------------------------------------------------------------------------------------------*/ /* ISC to NAV, sent 8 times per second */ struct ODEMSG { /* Synchronization word */ USHORT unique_word; /* Word 1, 0xff80 - 0xff first, 0x81 second */ USHORT msgID; /* Word 2, */ USHORT msglength; /* Word 3, Number of words in the structure. Including unique_word and checksum */ short wheel_tics; /* Word 4, ITC_0 instantaneous sample. Integer Units = .01 counts/sec */ ULONG wheel_ode; /* Word 4, ITC_0 instantaneous sample. Grand total tic count */ short engine_tics; /* Word 5, ITC_1 instantaneous sample. Integer Units = .01 counts/sec */ ULONG engine_ode; /* Word 4, ITC_1 instantaneous sample. Grand total tic count */ short ITC_2_tics; /* Word 5, ITC_2 instantaneous sample. Integer Units = .01 counts/sec */ ULONG ITC_2_ode; /* Word 4, ITC_2 instantaneous sample. Grand total tic count */ short ITC_3_tics; /* Word 5, ITC_3 instantaneous sample. Integer Units = .01 counts/sec */ ULONG ITC_3_ode; /* Word 4, ITC_3 instantaneous sample. Grand total tic count */ short manifold_pressure; /* Word 9, Current instantaneous sample. Integer Units = .01 lbs/inch^2 */ short brake_line_pressure;/* Word 10, Current instantaneous sample. Integer Units = .01 lbs/inch^2 */ short steering_setting; /* Word 11, Current setting. Proportional Min = 1048, Center 1572, Max 2096 */ short throttle_setting; /* Word 12, Current setting. Proportional Min = 1048, Center 1572, Max 2096 */ short brake_setting; /* Word 13, Current setting. Proportional Min = 1048, Center 1572, Max 2096 */ short transmission_set; /* Word 14, Current,setting: Discrete 0 = Neutral, 1 = first gear, 2 = second gear, 3 = 3rd gear, 4 = fourth gear, 5 = 5th gear -1 = reverse. */ USHORT checksum; // Word 17, The method is to sum the entire structure from the unique_word // up to, but excluding the checksum word. All math is performed using // signed 16 bit integers with carries, or overflows, ignored. The sum is // negated. }; typedef struct ODEMSG ODEMSGst; /*--------------------------------------------------------------------------------------------------- * IMU message structure. Information sent by ISC control computer 8 times per second. * Periodic Interval Timer (PIT) is ultimately is derived from the 32.768 KHz CPU oscillator. * this oscillator produces a 16,777,000 CPU clock divided by 16 = 1,048,562 Hz. * * 1 PIT interrupt = 1/1024 sec = .9765625 msec (PIT_count) * 16 PIT interrupts = 1/64 sec = 15.625 msec * 128 PIT interrupts = 1/8th sec = 125 msec (exactly!) This is the IMUMSG reporting interval. *---------------------------------------------------------------------------------------------------*/ /* ISC to NAV 8 times per second */ struct IMUMSG { /* Synchronization word */ USHORT unique_word; /* Word 1, 0xff80 - 0xff first, 0x81 second */ USHORT msgID; /* Word 2, */ USHORT msglength; /* Word 3, Number of words in the structure. Including unique_word and checksum */ short body_roll_rate; /* Word 4, Current instantaneous sample. Integer Units = .01 degrees/sec */ short body_pitch_rate; /* Word 5, Current instantaneous sample. Integer Units = .01 degrees/sec */ short body_yaw_rate; /* Word 6, Current instantaneous sample. Integer Units = .01 degrees/sec */ short body_lift_accel; /* Word 7, Current instantaneous sample. Integer Units = .01 meters/sec/sec */ short body_thrust_accel; /* Word 8, Current instantaneous sample. Integer Units = .01 meters/sec/sec */ short body_side_accel; /* Word 9, Current instantaneous sample. Integer Units = .01 meters/sec/sec */ short tilt; /* Word 10, Local horizontal to Body frame side. Integer Units = .01 degrees */ short ascension; /* Word 11, Local horizontal to Body frame nose. Integer Units = .01 degrees */ short heading; /* Word 12, Body frame nose to North. Integer Units = .01 degrees North = 0, East = +90, West = -90, South = +/- 180 */ ULONG PIT_count; /* Periodic Interval Timer interrupt count at sample time. 1/8th second sample seperation time. (128 PIT interrupts) */ USHORT checksum; // Word 14. The method is to sum the entire structure from the unique_word // up to, but excluding the checksum word. All math is performed using // signed 16 bit integers with carries, or overflows, ignored. The sum is // negated. }; typedef struct IMUMSG IMUMSGst; /*--------------------------------------------------------------------------------------------------- * GPS message structure. Information sent by ISC control computer once per second. *---------------------------------------------------------------------------------------------------*/ /* ISC to NAV once per second */ struct GPSMSG { /* Synchronization word */ USHORT int unique_word; /* Word 1, 0xff80 - 0xff first, 0x81 second */ USHORT int msgID; /* Word 2, */ USHORT int msglength; /* Word 3, Number of words in the structure. Including unique_word and checksum */ unsigned long int GPSTimeSeconds; /* Word 4, 0 - 604,799 sec (Sun 1 Week)*/ long Latitude; /* Word 5-6, Latitude 1E+08 * radians */ long Longitude; /* Word 7-8, Longitude 1E+08 * radians */ long Height; /* Word 9-10, Height 1E+02 * meters */ USHORT TrueCourse; // Word 11, 1E+03 * radians (0 - 2pi ) unsigned long GroundSpeed; // Word 12-13, 1E+02 * meters/sec (0 - 1000) short ClimbRate; // Word 14, 1E+02 * meters/sec (0 - 300 ) /*---------------------------------------------------------------------- Derived accelerations from current and previous valid course and speed. Do scaling on all these long integers. ----------------------------------------------------------------------*/ // AlongTrackAccel = (GroundSpeed - GroundSpeedLast) / DeltaTime; Integer Units = .01 meters/sec long AlongTrackAccel;//Word 15-16, = (long)gprec.GroundSpeed - GroundSpeedLast; //meters/sec/sec = (float) (AlongTrackAccel / 1E+02); // VerticalAccel = (ClimbRate - ClimbRateLast) / DeltaTime; Integer Units = .01 meters/sec long VerticalAccel; //Word 17-18, = (long)gprec.ClimbRate - ClimbRateLast; //meters/sec/sec = (float) (VerticalAccel /1E+02); // AngularRate = (TrueCourse - TrueCourseLast) / DeltaTime; Integer Units = .001 radians/sec long AngularRate; //Word 19-20, = (long)gprec.TrueCourse - TrueCourseLast; // deg/sec = ((float) AngularRate) / 1E+03) * r2dF; // CrossTrackAccel = ((float)-AngularRate/0.001f) * ((float)GroundSpeed/0.01f); // meters/sec/sec // CrossTrackAccel = -AngularRate * GroundSpeed; // meters/sec/sec short GeoidalSeparation; // Word 21, 1E+02 * meters USHORT SolutionValidity; // Word 22, TRUE == Valid solution short compass; /* Word 23, (0 - pi/4) magnetic deviation. 1E+04 * radians */ /*---------------------------------------------------------------------- ** Added GPS receiver information - 18 Aug 2003 N.H. ----------------------------------------------------------------------*/ ULONG EHPE; /* Word 24, Est. Horizontal Position error. Integer Units = .01 meters */ ULONG EVPE; /* Word 25, Est. Veritcal Position error. Integer Units = .01 meters */ USHORT EHVE; /* Word 26, Est. Horizontal Velocity error. Integer Units = .01 meters/sec */ USHORT checksum; // Word 27. The method is to sum the entire structure from the unique_word // up to, but excluding the checksum word. All math is performed using // signed 16 bit integers with carries, or overflows, ignored. The sum is // negated. }; typedef struct GPSMSG GPSMSGst; /*--------------------------------------------------------------------------------------------------- /* Slow message structure. Information sent by ISC control computer on 8 second interval. 3 Aug 2003 N.H. ---------------------------------------------------------------------------------------------------*/ /* ISC to NAV, sent every 8 seconds */ struct SLOMSG { /* Synchronization word */ USHORT unique_word; /* Word 1, 0xff80 - 0xff first, 0x81 second */ USHORT msgID; /* Word 2, */ USHORT msglength; /* Word 3, Number of words in the structure. Including unique_word and checksum */ short engine_temp; /* Word 4, Current instantaneous sample. Integer Units = deg F */ short outside_temp; /* Word 5, Current instantaneous sample. Integer Units = deg F */ short oil_pressure; /* Word 6, Current instantaneous sample. Integer Units = .01 lbs/inch^2 */ short fuel_level_reading; /* Word 7, Fuel level. Integer Units = .01 gallons */ short fuel_consumption; /* Word 8, Computed Fuel consumption. Integer Units = .01 gallons */ short manual_override; /* Word 9, TRUE == Radio Control is active. */ USHORT checksum; // Word 10, The method is to sum the entire structure from the unique_word // up to, but excluding the checksum word. All math is performed using // signed 16 bit integers with carries, or overflows, ignored. The sum is // negated. }; typedef struct SLOMSG SLOMSGst; /*--------------------------------------------------------------------------------------------------- Magnetic Compass message structure. Sent by ISC control computer 8 per second. Feb 28,2004 N.H. Note: Pitch and Roll are valid only when no acceleration other than gravity is present. For example, increasing speed or turning will invalidate pitch and roll. Readings are produced by the Honeywell HMR3300 electronic compass. ---------------------------------------------------------------------------------------------------*/ /* ISC to NAV, sent 8 PER second */ struct MAGMSG { /* Synchronization word */ USHORT unique_word; /* Word 1, 0xff80 - 0xff first, 0x81 second */ USHORT msgID; /* Word 2, */ USHORT msglength; /* Word 3, Number of words in the structure. Including unique_word and checksum */ short heading; /* Word 4, Integer Units = .1 degrees */ short pitch; /* Word 5, Integer Units = .1 degrees */ short roll; /* Word 6, Integer Units = .1 degrees */ USHORT checksum; // Word 7, The method is to sum the entire structure from the unique_word // up to, but excluding the checksum word. All math is performed using // signed 16 bit integers with carries, or overflows, ignored. The sum is // negated. }; typedef struct MAGMSG MAGMSGst; /*--------------------------------------------------------------------------------------------------- /* Restart message structure. Sent by ISC control computer at restart. March 4,2003 N.H. ---------------------------------------------------------------------------------------------------*/ /* ISC to NAV, sent once at restart. */ struct RSTMSG { /* Synchronization word */ USHORT unique_word; /* Word 1, 0xff80 - 0xff first, 0x81 second */ USHORT msgID; /* Word 2, */ USHORT msglength; /* Word 3, Number of words in the structure. Including unique_word and checksum */ USHORT count; /* Word 4,= 1 Power on restart. > 1 Subsequent restarts (like reset).*/ USHORT checksum; // Word 5, The method is to sum the entire structure from the unique_word // up to, but excluding the checksum word. All math is performed using // signed 16 bit integers with carries, or overflows, ignored. The sum is // negated. }; typedef struct RSTMSG RSTMSGst; /*--------------------------------------------------------------------------------------------------- /* Key message structure. Carries keyboard commands to tport task. March 5,2003 N.H. ---------------------------------------------------------------------------------------------------*/ /* NAV to ISC, Sent anytime. */ struct KEYMSG { /* Synchronization word */ USHORT unique_word; /* Word 1, 0xff80 - 0xff first, 0x81 second */ USHORT msgID; /* Word 2, */ USHORT msglength; /* Word 3, Number of words in the structure. Including unique_word and checksum */ char char_index0; /* Word 4, 20 characters. */ char char_index1; char char_index2; /* Word 5, */ char char_index3; char char_index4; /* Word 6, */ char char_index5; char char_index6; /* Word 7, */ char char_index7; char char_index8; /* Word 8, */ char char_index9; char char_index10; /* Word 9, */ char char_index11; char char_index12; /* Word 10, */ char char_index13; char char_index14; /* Word 11, */ char char_index15; char char_index16; /* Word 12, */ char char_index17; char char_index18; /* Word 13, */ char char_index19; USHORT checksum; // Word 14, }; typedef struct KEYMSG KEYMSGst; /*--------------------------------------------------------------------------------------------------- /* TTY message structure. Carries TTY console display from tport task. March 5,2003 N.H. ---------------------------------------------------------------------------------------------------*/ /* ISC to NAV, Sent anytime. */ struct TTYMSG { /* Synchronization word */ USHORT unique_word; /* Word 1, 0xff80 - 0xff first, 0x81 second */ USHORT msgID; /* Word 2, */ USHORT msglength; /* Word 3, Number of words in the structure. Including unique_word and checksum */ char char_index0; /* Word 4, 20 characters. */ char char_index1; char char_index2; /* Word 5, */ char char_index3; char char_index4; /* Word 6, */ char char_index5; char char_index6; /* Word 7, */ char char_index7; char char_index8; /* Word 8, */ char char_index9; char char_index10; /* Word 9, */ char char_index11; char char_index12; /* Word 10, */ char char_index13; char char_index14; /* Word 11, */ char char_index15; char char_index16; /* Word 12, */ char char_index17; char char_index18; /* Word 13, */ char char_index19; USHORT checksum; // Word 14, }; typedef struct TTYMSG TTYMSGst; /*--------------------------------------------------------------------------------------------------- /* PWM message structure. Sent by ISC control computer to NAV March 5,2003 N.H. ---------------------------------------------------------------------------------------------------*/ /* ISC to NAV, On change AND on empty RFL queue. */ struct PWMMSG { /* Synchronization word */ USHORT unique_word; /* Word 1, 0xff80 - 0xff first, 0x81 second */ USHORT msgID; /* Word 2, */ USHORT msglength; /* Word 3, Number of words in the structure. Including unique_word and checksum */ short pwmchn0; /* Word 4 */ short pwmchn1; /* Word 5 */ short pwmchn2; /* Word 6 */ short pwmchn3; /* Word 7 */ // short pwmchn4 /* Word 8 */ // short pwmchn5 /* Word 9 */ // short pwmchn6 /* Word 10 */ // short pwmchn7 /* Word 11 */ USHORT checksum; // Word 8, The method is to sum the entire structure from the unique_word // USHORT checksum; // Word 12, The method is to sum the entire structure from the unique_word }; typedef struct PWMMSG PWMMSGst; /*--------------------------------------------------------------------------------------------------- * USS message structure. Information sent by ISC control computer 8 times per second. * Ultrasonic sensor minimum period is 46+ milliseconds. Therefore, the ISC period is * scheduled by the tasker at 1/16 seconds (62.5 msec periods). The time margin (62 msec - 46 msec) * gives time for echos to die down. Reporting to the navigation computer is on 1/8th second * intervals (125 msec period), hence two sensors are reported on each 1/8th second reporting interval. * If compiled for 2 ultrasonic sensors, then each sensor has new data every reporting interval. * If compiled for 4 ultrasonic sensors, then each sensor has new data every other reporting interval. * * Only one Ultrasonic sensor can be active at a time inorder to avoid interference. Hence sensors are * activated in sequential order on 62.5 msec periods. Individual time tags are captured when the * sensor is triggered active to begin ranging. Each count in the time tag is .9765625 milliseconds. * Each count in the range measurement is .953687 micro-seconds (16,777,000/16 = 1,048,562 Hz.) * The SRF04 Ultrasonic sensor provides an echo pulse proportional to distance. Multiply the reported * range count * 0.953687 to compute the range in micro-seconds (usec). For example, * usec/58 is the distance in inches. * usec/148 is the distance in centimeters. * * If nothing is detected then the SRF04 will report a range anyway of about 36,000 usec. * If the sensor was not triggered or does not exist, the range_count field will report = 0; *---------------------------------------------------------------------------------------------------*/ /* ISC to NAV 8 times per second UltraSonic Sensor */ struct USSMSG { /* Synchronization word */ USHORT unique_word; /* Word 1, 0xff80 - 0xff first, 0x81 second */ USHORT msgID; /* Word 2, */ USHORT msglength; /* Word 3, Number of words in the structure. Including unique_word and checksum */ short us_sensor1_id; /* Word 4, Sensor 1 or 3 */ unsigned short range1_count;/* Word 5, 0.953687 microseconds per count. */ ULONG time1_tag; /* Word 6, 0.9765625 milliseconds per count */ short us_sensor2_id; /* Word 8, Sensor 2 or 4 */ unsigned short range2_count;/* Word 9, 0.953687 microseconds per count. */ ULONG time2_tag; /* Word 10, 0.9765625 milliseconds per count */ USHORT checksum; // Word 12. The method is to sum the entire structure from the unique_word // up to, but excluding the checksum word. All math is performed using // signed 16 bit integers with carries, or overflows, ignored. The sum is // negated. }; typedef struct USSMSG USSMSGst; /*--------------------------------------------------------------------------------------------------- * RSC output sent on Righting State Change by ISC to Navigation computer. March 7, 2004 N.H. * Replace any older unsent message with new message regardless. * Righting State 000 0 - No GPS, No IMU, No Compass * Righting State 001 1 - No GPS, No IMU, Compass * Righting State 010 2 - No GPS, IMU, No Compass * Righting State 011 3 - No GPS, IMU, Compass * Righting State 100 4 - GPS, No IMU, No Compass * Righting State 101 5 - GPS, No IMU, Compass * Righting State 110 6 - GPS, IMU, No Compass * Righting State 111 7 - GPS, IMU, Compass * Righting Event TIMER 0 * Righting Event GPSLOSTSYNC 1 * Righting Event GPSSYNC 2 * Righting Event IMULOSTSYNC 3 * Righting Event IMUSYNC 4 * Righting Event COMPASSLOST 5 * Righting Event COMPASSMSG 6 ---------------------------------------------------------------------------------------------------*/ /* RSC - Righting State Change, ISC to NAV, sent on change */ struct RSCMSG { /* Synchronization word */ USHORT unique_word; /* Word 1, 0xff80 - 0xff first, 0x81 second */ USHORT msgID; /* Word 2, */ USHORT msglength; /* Word 3, Number of words in the structure. Including unique_word and checksum */ short old_state; /* Word 4, */ short new_state; /* Word 5, */ short event ; /* Word 6, */ USHORT checksum; // Word 7, The method is to sum the entire structure from the unique_word }; typedef struct RSCMSG RSCMSGst; /*---------------------------------------------------------------------------------------------------*/ /* OFF - Disable message reporting, NAV to ISC */ struct OFFMSG { /* Synchronization word */ USHORT unique_word; /* Word 1, 0xff80 - 0xff first, 0x81 second */ USHORT msgID; /* Word 2, */ USHORT msglength; /* Word 3, Number of words in the structure. Including unique_word and checksum */ short msg_opcode; /* Word 4, message to disable, 0x0000 or invalid # = disables all msg's */ USHORT checksum; // Word 5 }; typedef struct OFFMSG OFFMSGst; /*---------------------------------------------------------------------------------------------------*/ /* On - enable message reporting, NAV to ISC */ struct ENAMSG { /* Synchronization word */ USHORT unique_word; /* Word 1, 0xff80 - 0xff first, 0x81 second */ USHORT msgID; /* Word 2, */ USHORT msglength; /* Word 3, Number of words in the structure. Including unique_word and checksum */ short msg_opcode; /* Word 4, message to disable, 0x0000 or invalid # = enables all msg's */ USHORT checksum; // Word 5 }; typedef struct ENAMSG ENAMSGst; /*--------------------------------------------------------------------------------------------------- ** Customer provided Engineering data used by the control computer. 4 Aug 2003 N.H. ** Provide MS Excel file with equations, or tables generated by those equations giving the following: ** a. Engine power output given manifold pressure and RPM. ** b. Net forward or rearward force (thrust) given manifold pressure, RPM, and speed. (assume no tire slip) ** c. Net rearward force contribution given brake hydraulic pressure and speed. (assume no tire slip) ---------------------------------------------------------------------------------------------------*/ /*--------------------------------------------------------------------------------------------------- * PID parameter message structure. Information sent to ISC control computer. 3 Aug 2003 N.H. * * A Proportional Integral Derivative (PID) controller is associated with each of 8 output PWM chn's. * The customer is responsible to determine, tune, and test the PID parameters thus assuring * stability of the feedback loop. * * This message is used to initially load the PID parameters at startup, and * to modify the PID parameters during operation. For example, PID steering gains * could be modified depending on speed. * One message per channel. PID parameters and PID channel controls are channel independent. ---------------------------------------------------------------------------------------------------*/ /* NAV to ISC, sent anytime */ struct PIDMSG { /* Synchronization word */ USHORT unique_word; /* Word 1, 0xff80 - 0xff first, 0x81 second */ USHORT msgID; /* Word 2 */ USHORT msglength; /* Word 3, Number of words in the structure. Including unique_word and checksum */ short PID_Channel; /* Word 4, PWM PID output channel 0 - 7. */ long proportional_gain; /* Word 5-6, Least Significant Bit = .0001 */ long integral_gain; /* Word 7-8, Least Significant Bit = .0001 */ long derivative_gain; /* Word 9-10, Least Significant Bit = .0001 */ short pos_position_limit; /* Word 11, Never to exceed servo position limit (range 1048 to 2096) */ short min_position_limit; /* Word 12, Never to exceed servo position limit (range 1048 to 2096) */ long iMin; /* Word 13-14, Integrator Minimum wind up limit. (scaling TBD) */ long iMax; /* Word 15-16, Integrator Maximum wind up limit. (scaling TBD) */ USHORT checksum; // Word 17, The method is to sum the entire structure from the unique_word // up to, but excluding the checksum word. All math is performed using // signed 16 bit integers with carries, or overflows, ignored. The sum is // negated. }; typedef struct PIDMSG PIDMSGst; /*--------------------------------------------------------------------------------------------------* * Command message structure. Message sent to ISC control computer. * * The vehicle is directed using the following commands. * 1. Go Straight, hold constant speed. * 2. Go Straight, accellerate to target speed, at given acceleration rate. * 3. Go Straight, decellerate to target speed, at given deceleration rate. (Target may be 0) * 4. Turn at given constant angular velocity, hold constant speed. * a. Hold constant pre-existing speed throughout the turn. * b. Use given turn direction (positive or negative angular velocity [+ cw, - ccw]). * c. Use given constant angular acceleration to reach given angular velocity at start and end * 5. Turn at given constant angular velocity * accellerate to target speed, at given acceleration rate. , * 6. Turn at given constant angular velocity * decellerate to target speed, at given deceleration rate. , *--------------------------------------------------------------------------------------------------*/ /* NAV to ISC, use with PID enabled. */ struct CMDMSG { /* Synchronization word */ USHORT unique_word; /* Word 1, 0xff80 - 0xff first, 0x81 second */ USHORT msgID; /* Word 2, */ USHORT msglength; /* Word 3, Number of words in the structure. Including unique_word and checksum */ short cmd_type; /* Word 4, Command type. */ /* 1 = Go Straight, hold constant speed. Integer Units = .01 mps, .001 m/s/s */ /* 2 = Go Straight, accellerate to target speed, at given acceleration rate. */ /* 3 = Go Straight, decellerate to target speed, at given deceleration rate. */ /* 4 = Turn at given constant angular velocity. Integer Units = .01 degrees/sec */ /* 5 = Turn at given constant angular velocity, accellerate to target speed. */ /* 6 = Turn at given constant angular velocity, decellerate to target speed. */ /* 7 = Go Straight backwards, accelerate to target speed. /* 8 = Emergency halt. Engine off, default break on, default wheel setting. */ short direction; /* Word 5, Target heading on go straight, exit heading on turn. Integer Units = .01 degrees */ short speed; /* Word 6, Target speed on go straight, accelerate, decelerate. Integer Units = .01 mps */ /* Note: Target speed on turn is the speed of entry. */ short turn_rate; /* Word 7, +/- constant turn angular velocity. Integer Units = .01 degrees/sec. */ short turn_acel; /* Word 8, +/- angular acceleration at entry and exit from turn. angular acceleration. Integer Units = .001 degrees/sec/sec. */ /** short finish_heading; Heading on exit from turn. Integer Units = .01 degrees (see direction above)*/ unsigned long ode; /* Word 9, Odometer wheel count at start of command execution. */ /* 0 = Immediate override to current command execution. */ /* Note: override to a turn in progress first invokes turn deceleration on exit. */ short max_speed; /* Word 10, Never to exceed speed. */ short gear_position; /* Word 14, Current, setting: Discrete 0 = Neutral, 1 = first gear, 2 = second gear, 3 = 3rd gear, 4 = fourth gear, 5 = 5th gear -1 = reverse, All else = Ignore gear position. */ USHORT checksum; // Word 11, The method is to sum the entire structure from the unique_word // up to, but excluding the checksum word. All math is performed using // signed 16 bit integers with carries, or overflows, ignored. The sum is // negated. }; typedef struct CMDMSG CMDMSGst; /*-------------------------------------------------------------------------------------------------- * ENG message structure. Physical Engineering constants. --------------------------------------------------------------------------------------------------*/ /* NAV to ISC normally sent once at initialization */ struct ENGMSG { /* Synchronization word */ USHORT unique_word; /* Word 1, 0xff80 - 0xff first, 0x81 second */ USHORT msgID; /* Word 2, */ USHORT msglength; /* Word 3, Number of words in the structure. Including unique_word and checksum */ USHORT vehicle_weight; /* Word 4, Integer Units = lbs */ short default_chn0; /* Word 5, Default setting. range 1048 to 2096 */ short default_chn1; /* Word 6, Default setting. range 1048 to 2096 */ short default_chn2; /* Word 7, Default setting. range 1048 to 2096 */ short default_chn3; /* Word 8, Default setting. range 1048 to 2096 */ short default_chn4; /* Word 9, Default setting. range 1048 to 2096 */ short default_chn5; /* Word 10, Default setting. range 1048 to 2096 */ short default_chn6; /* Word 11, Default setting. range 1048 to 2096 */ short default_chn7; /* Word 12, Default setting. range 1048 to 2096 */ short fuel_load; /* Word 13, Integer Units = .01 gallons. */ short fuel_capacity; /* Word 14, Integer Units = .01 gallons. */ short ITC_0; /* Word 15, Wheel tic count per revolution */ short ITC_1; /* Word 16, Engine tic count per revolution */ short ITC_2; /* Word 17, tic count per revolution */ short ITC_3; /* Word 18, tic count per revolution */ short wheel_circumfrence; /* Word 19, Average Wheel circumfrence Interger units .001 meters. */ short ODE_clear; /* Word 20, Clear all odometer total tic counts. */ USHORT checksum; // Word 21, The method is to sum the entire structure from the unique_word // up to, but excluding the checksum word. All math is performed using // signed 16 bit integers with carries, or overflows, ignored. The sum is // negated. }; typedef struct ENGMSG ENGMSGst; /*---------------------------------------------------------------------------------------------------*/ #define SYNCFF 0 /* Incoming Message State codes */ #define SYNC81 1 #define MSGCODE1 2 #define MSGCODE2 3 #define MSGLENG1 4 #define MSGLENG2 5 #define MSGBODY 6 #define MSGCSUM1 7 #define MSGCSUM2 8 /*---------------------------------------------------------------------------------------------------*/