Main Page   Hardware Class Hierarchy   Hardware API     Mapping Class Hierarchy  Mapping API 

jaus_message.h

Go to the documentation of this file.
00001 /*
00002 DASI Library Copyright (C) 2004-2007  Derek Jones
00003 This software is free for educational use only--no commercial use allowed.
00004 
00005 This library is  distributed in the hope that it will be useful,
00006 but WITHOUT ANY WARRANTY;  without even the implied warranty of
00007 MERCHANTABILITY or FITNESS FOR A  PARTICULAR PURPOSE.  
00008 */
00009 #ifndef JAUS_MESSAGE_H
00010 #define JAUS_MESSAGE_H
00011 #include <types.h>
00012 #include <fixedpoint.h>
00013 #include <utility/status.h>
00014 
00015 // Specify Instance 0 if you don't care which component it uses.
00016 #define DONT_CARE 0
00017 #define BAD_INSTANCE 0
00018 #define BAD_SUBTYPE 0
00019 
00020 #define DEFAULT_SUBTYPE 0
00021 #define IR_SUBTYPE 1
00022 #define SONAR_SUBTYPE 2
00023 
00024 
00026 //#define JAUS_MESSAGE_LENGTH 104
00027 // add adler-32 (hexcoded) checksum.
00028 // declare jaus_message buffer's the below length.
00029 //#define JAUS_DECLARATION_LENGTH 164
00030 #define JAUS_DECLARATION_LENGTH 176
00031 //#define JAUS_DECLARATION_LENGTH 82
00032 // This is the maximum length of the data portion of a jaus_message (thus data_size == Max_JAUS_Output_MS+JAUS_HEADER_LENGTH)
00033 // NOTE: should be divisable by 4 so that the map can easily be transferred.
00034 #define Maximum_JAUS_Output_Message_Size 48
00035 // Maximum for downloading the map.
00036 #define Maximum_JAUS_MAP_Output_Message_Size 32
00037 // This is maximum UU encoded length of a jaus message with adler-32 string, time stamp etc.
00038 #define MAX_JAUS_MESSAGE_LENGTH JAUS_DECLARATION_LENGTH
00039 #define JAUS_PRIORITY(jaus_pointer) (jaus_pointer->_message.header.properties.bits.priority)
00040 #define JAUS_SOURCE_INSTANCE(jaus_pointer) (jaus_pointer->_message.header.source.bits.instance)
00041 #define JAUS_DEST_INSTANCE(jaus_pointer) (jaus_pointer->_message.header.destination.bits.instance)
00042 #define JAUS_SOURCE_COMPONENT(jaus_pointer) (jaus_pointer->_message.header.source.bits.component)
00043 #define JAUS_DEST_COMPONENT(jaus_pointer) (jaus_pointer->_message.header.destination.bits.component)
00044 #define JAUS_SOURCE_NODE(jaus_pointer) (jaus_pointer->_message.header.source.bits.node)
00045 #define JAUS_DEST_NODE(jaus_pointer) (jaus_pointer->_message.header.destination.bits.node)
00046 #define JAUS_SUSSYSTEM(jaus_pointer) (jaus_pointer->_message.header.source.bits.subsystem)
00047 #define JAUS_COMMAND_CODE(jaus_pointer) (JAUS_MESSAGE(jaus_pointer->_message.header.command_code))
00048 #define JAUS_COPY(pjausD,pjausS) for (short imxxx=0; imxxx<(Maximum_JAUS_Output_Message_Size+JAUS_HEADER_LENGTH); imxxx++) ((char*)pjausD)[imxxx] = ((char*)pjausS)[imxxx]
00049 
00050 #define DEFAULT_JAUS_MESSAGE_LENGTH 112
00051 #define JAUS_HEADER_LENGTH 16
00052 #define JAUS_UU_HEADER_LENGTH 32
00053 
00054 enum Destination_Node_Class { NO_DESTINATION_NODE_CLASS, INTRANODE_MESSAGE, INTERNODE_MESSAGE };
00055 
00057 //#define MAX_JAUS_MESSAGE_LENGTH 1058
00058 
00059 /* Ref. JAUS Reference Architecture
00060 Command 0000h - 1FFFh
00061 Query   2000h - 3FFFh
00062 Inform  4000h - 5FFFh
00063 Event Setup     6000h - 7FFFh
00064 Event Notification      8000h - 9FFFh
00065 Node Management A000h - BFFFh
00066 Reserved        C000h - CFFFh
00067 User Defined Message    D000h - FFFFh
00068   Ideally, there will be some sort of system registry like the SGML public DTD registration process,
00069   but with only 255 system IDs allowed; I don't think  the current implementation will be extensible.
00070 
00071   WARNING: it is the responsibility of each component to reverse the endian order [ntoh(...)].  This is because
00072   apart from the header, each message is divided differently thus no one solution will work.  Another solution
00073   if it proves worthy is to have a switch for used message and reverse all needed fields.  I choose the former
00074   because many times, a component will not need each every field, but if too much redudant switching occurs, then...
00075 
00076   NOTE: Deviations from JAUS
00077   1) The presence vector is not used--all fields are sent.  In fact, the transmission is composed of the largest
00078      JAUS message defined since it is built from a union.  
00079   2) [struct peculiarity] If the presence vector is not aligned on a word/long word  boundary
00080      then a pad uint8/word is inserted.
00081      This is a side effect of the way I serialize the struct message for transmission into a character uint8 stream.
00082      The serialize version does not have the pad uint8s and thus, when rearranged on the other end, the struct
00083      format is messed up.
00084        Some processors/compilers can address only to 32 bit boundary.  
00085      Thus, the short presence vector followed by an int
00086      internally inserts a pad short to align to 32 bit boundary.  This is true of internal fields also and
00087      not just the presence vector.  if a short is follwed by and int, then it will be padded unless there are
00088      an even number of shorts preceding the int.  So far all have aligned on a 32 bit boundary except for the
00089      need for padding after the presence vector.
00090   NOTE: an interface can be built to post process this format into a true JAUS format unless I think of another
00091         way of handling this.
00092 */
00094 enum MESSAGE_CLASS { COMMAND_CLASS, QUERY_CLASS, INFORM_CLASS, EVENT_SETUP_CLASS, EVENT_NOTIFICATON_CLASS,
00095                      NODE_MANAGEMENT_CLASS, EXPERIMENTAL_CLASS };
00097 enum JAUS_DATA_FLAG {
00099   ONLY_DATA_PACKET = 0,
00101   FIRST_DATA_PACKET=1,
00103   NORMAL_DATA_PACKET=2,
00105   RETRANSMITTED_DATA_PACKET=4,
00107   LAST_DATA_PACKET=8};
00108   
00109 enum JAUS_MESSAGE { 
00110   Error_Message=0x00,
00111   Set_Component_Authority_Message=0x01,
00112   Shutdown_Message=0x02,
00113   Standby_Message=0x03,
00114   Resume_Message=0x04,
00115   Reset_Message=0x05,
00116   Set_Emergency_Message=0x06,
00117   Clear_Emergency_Message=0x07,
00118   Create_Service_Connection_Message=0x08,
00119   Confirm_Service_Connection_Message=0x09,
00120   Activate_Service_Connection_Message=0x0A,
00121   Suspend_Service_Connection_Message=0x0B,
00122   Terminate_Service_Connection_Message=0x0C,
00123   Set_Local_Pose_Message=0x403, // this is oversight; not in JAUS RA.
00124   Set_Wrench_Effort_Message=0x405,
00125   Set_Discrete_Devices=0x406,
00126   Set_Local_Vector_Message=0x408,
00127   Set_Travel_Speed_Message=0x040A,
00128   Set_Local_Waypoint_Message=0x040D,
00129   Set_Camera_Capabilities_Message=0x805,
00130   Set_Camera_Format_Options_Message=0x806,
00131   Set_Camera_Settings_Message=0x808, // non JAUS but the way it should be
00132   Query_Component_Status_Message=0x2002,
00133   Query_Local_Pose_Message=0x2003,
00134   Query_Time_Message=0x2011,
00135   Query_Heartbeat_Pulse_Message=0x2202,
00136   Query_Platform_Specifications_Message=0x2400,
00137   Query_Platform_Operational_Data_Message=0x2401,
00138   Query_Velocity_State_Message=0x2404,
00139   Query_Local_Vector_Message=0x2408,
00140   Query_Travel_Speed_Message=0x240A,
00141   Query_Waypoint_Count_Message=0x0240B,
00142   Query_Local_Waypoint_Message=0x0240D,
00143   Query_Camera_Count_Message=0x2801,
00144   Query_Relative_Object_Position_Message=0x2802,
00145   Query_Selected_Camera_Message=0x2804,
00146   Query_Camera_Capabilities_Message=0x2805,
00147   Query_Camera_Format_Options_Message=0x2806,
00148   Query_Image_Message=0x2807,
00149   Query_Camera_Settings_Message=0x2808, // non JAUS but the way it should be
00150   Report_Component_Authority=0x4001,
00151   Report_Component_Status_Message=0x4002,
00152   Report_Local_Pose_Message=0x4003,
00153   Report_Time_Message=0x4011,
00154   Report_Heartbeat_Pulse_Message=0x4202,
00155   Report_Platform_Specifications_Message=0x4400,
00156   Report_Platform_Operational_Data_Message=0x4401,
00157   Report_Velocity_State_Message=0x4404,
00158   Report_Local_Vector_Message=0x4408,
00159   Report_Travel_Speed_Message=0x440A, // Reports the last commanded (desired) travel speed given
00160   Report_Waypoint_Count_Message=0x440B,
00161   Report_Local_Waypoint_Message=0x440D,
00162   Report_Camera_Pose_Message=0x4800,
00163   Report_Camera_Count_Message=0x4801,
00164   Report_Relative_Object_Position_Message=0x4802,
00165   Report_Selected_Camera_Message=0x4804,
00166   Report_Camera_Capabilities_Message=0x4805,
00167   Report_Camera_Format_Options_Message=0x4806,
00168   Report_Image_Message=0x4807,
00169   Report_Camera_Settings_Message=0x4808, // non JAUS but way it should be.
00170   // User Group
00171   Query_Identity_Message  =0xD001,     // Similar to ping, receiver must reply with Identity_Message to source ID
00172   Report_Identity_Message =0xD002,     // Message simply identifying system#, subsystem#, node#, of an active node.
00173   Query_Component_Message =0xD003,     // request a list of all defined components on node.
00174   Set_Platform_Specifications_Message=0xD004, // JAUS did not imagine dynamically configuring your vehicle!
00175   // very first node reported in component list is node_manager, thus it simply serves as a start sequence of list.
00176   // Only component required are Node_Manager
00177   Report_Component_Message=0xD005,      // A message identifying a single component on a node. will usually have a sequence number/end data indicator.
00178   Query_IS_Message=0xD006,
00179   Report_IS_Message=0xD007,
00180   Set_IS_Message=0xD008,
00181 //  Report_Motion_Message=0xD009,         // a message identifying a single motion in the motion list
00182 //  Query_Motion_Message          =0xD00A,     // request a tranformation from a waypoint to a motion list.
00183   Query_Error_Message=0xD00B,
00184   Report_Error_Message=0xD00C,
00185   Query_Map_Message=0xD00D,           // Marks beginning of a grid transfer.  Only other characters allowed are to be part of grid transfer.
00186   Report_Map_Message=0xD00E,
00187   Query_Binary_Status_Message=0xD00F,
00188   Set_Binary_Status_Message=0xD010,
00189 //  XMIT_Grid_Message=0xD00D,           // Marks beginning of a grid transfer.  Only other characters allowed are to be part of grid transfer.
00190 //  RECV_Grid_Message=0xD00E,
00191   Last_Message=0xD00F
00192 };
00193 
00194 
00195 struct Data_Size_T
00196 {
00197   JAUS_MESSAGE command;
00198   short size;
00199 };
00200 
00201 
00202 /* Structures with no data can just read the header command code.
00203 struct component_list_t
00204 {
00205 };
00206 
00207 */
00208 struct authority_code_t
00209 {
00210   uint8 code;
00211 };
00212 struct respond_component_t
00213 {
00214   uint8 subclass;
00215 };
00216 struct set_emergency_t
00217 {
00218   unsigned short code;
00219 };
00220 struct clear_emergency_t
00221 {
00222   unsigned short code;
00223 };
00224 
00225 // A maximum 255 value status (for exampel an LED is a 2 value indicator)
00226 struct status_indicator_t
00227 {
00228   uint16 value;    // value to set/report.
00229 };
00230 
00232 
00236 struct camera_settings_t
00237 {
00238   unsigned short horizontal; // resolution.
00239   unsigned short vertical;
00240   unsigned short shutter;   // using direct exposure from GB camera for now.
00241   unsigned short image_control; // reserved for line modes.
00242 };
00243 
00244 
00245 struct camera_format_t
00246 {
00247   unsigned char audio_format;
00248   unsigned char image_format;
00249   unsigned short _pad;
00250   unsigned int format_option;
00251 };
00252 
00253 struct travel_speed_t
00254 {
00255   unsigned short speed; // 2
00256 };
00257 struct IS_t
00258 {
00259   int  sid;    // 4
00260   int  pid;    // 8
00261   int   value; // 12
00262   short x;     // 14
00263   short y;     // 16
00264 };
00265 // Structure used to report system log messages (Query_Error_Message/Report_Error_Message)
00266 typedef OOMRM_Message system_message_t; // 8 bytes
00267 
00268 struct system_error_t
00269 {
00270   int  error; // 4
00271   int  level; // 8
00272 };
00273 // -----------------------
00274 // Set_Local_Vector2 0408h 
00275 // Localized version (with distance to travel).
00276 // Turns to angle  and travels "distance" millimeters at "speed" millimeters/second.
00277 // I think lack of distance is oversight.  Prescense vector for distance would take up 3 less bytes.
00278 // -----------------------
00279 struct local_vector_t
00280 {
00281   int speed; // 4  millimeters per second
00282   int radians; // 8 fixed point radians.
00283   int distance; // 12 Local addition (distance to travel at that speed.)
00284 };
00285 // -----------------------
00287 
00293 // -----------------------
00294 struct component_status_t
00295 {
00296   unsigned int secondary_status_code; // 4
00297   uint8  primary_status_code; // 5 (8)
00298 };
00299 // -----------------------
00300 // DISCRETE_DEVICE
00301 // -----------------------
00302 struct discrete_device_t
00303 {
00304 #if defined(BIG_ENDIAN) && !defined(LITTLE_ENDIAN)
00305   union  {
00306     struct  {
00307     uint8  df2 : 1;
00308     uint8  df3 : 1;
00309     uint8  df4 : 1;
00310     uint8  df5 : 1;
00311     uint8  R   : 4;
00312     } pv;
00313 #elif defined(LITTLE_ENDIAN) && !defined(BIG_ENDIAN)
00314   union  {
00315     struct  {
00316     uint8  R   : 4;
00317     uint8  df5 : 1;
00318     uint8  df4 : 1;
00319     uint8  df3 : 1;
00320     uint8  df2 : 1;
00321     } pv;
00322 #else
00323   #error "Either BIG_ENDIAN or LITTLE_ENDIAN must be #defined, but not both."
00324 #endif
00325     uint8 presence_vector; // this needs htons applied.
00326   };
00327   uint8          main_propulsion; 
00328   uint8          brake_horn;
00329   uint8          gear;
00330   uint8          transfer_case;
00331 };
00332 // -----------------------
00333 // Platform Specification
00334 // -----------------------
00335 struct platform_specification_t
00336 {
00337 #if defined(BIG_ENDIAN) && !defined(LITTLE_ENDIAN)
00338   union  {
00339     struct  {
00340     unsigned int  df2 : 1;
00341     unsigned int  df3 : 1;
00342     unsigned int  df4 : 1;
00343     unsigned int  df5 : 1;
00344     unsigned int  df6 : 1;
00345     unsigned int  df7 : 1;
00346     unsigned int  df8 : 1;
00347     unsigned int  df9 : 1;
00348     unsigned int  df10 : 1;
00349     unsigned int  df11 : 1;
00350     unsigned int  df12 : 1;
00351     unsigned int  df13 : 1;
00352     unsigned int  df14 : 1;
00353     unsigned int  df15 : 1;
00354     unsigned int  df16 : 1;
00355     unsigned int  df17 : 1;
00356     unsigned int  df18 : 1;
00357     unsigned int  df19 : 1;
00358     unsigned int  df20 : 1;
00359     unsigned int  df21 : 1;
00360     unsigned int  df22 : 1;
00361     unsigned int  R   : 11;
00362     } pv;
00363 #elif defined(LITTLE_ENDIAN) && !defined(BIG_ENDIAN)
00364   union  {
00365     struct  {
00366     unsigned int  R    :11;
00367     unsigned int  df22 : 1;
00368     unsigned int  df21 : 1;
00369     unsigned int  df20 : 1;
00370     unsigned int  df19 : 1;
00371     unsigned int  df18 : 1;
00372     unsigned int  df17 : 1;
00373     unsigned int  df16 : 1;
00374     unsigned int  df15 : 1;
00375     unsigned int  df14 : 1;
00376     unsigned int  df13 : 1;
00377     unsigned int  df12 : 1;
00378     unsigned int  df11 : 1;
00379     unsigned int  df10 : 1;
00380     unsigned int  df9 : 1;
00381     unsigned int  df8 : 1;
00382     unsigned int  df7 : 1;
00383     unsigned int  df6 : 1;
00384     unsigned int  df5 : 1;
00385     unsigned int  df4 : 1;
00386     unsigned int  df3 : 1;
00387     unsigned int  df2 : 1;
00388     } pv;
00389 #else
00390   #error "Either BIG_ENDIAN or LITTLE_ENDIAN must be #defined, but not both."
00391 #endif
00392     unsigned int presence_vector; // this needs htons applied.
00393   };
00394   char           name[15]; //* 19
00395   uint8          obstacle;     // 20
00396   unsigned short wheelbase; // 22
00397   unsigned short Lwheel_diameter; // 24
00398   unsigned short Rwheel_diameter; // 26
00399   unsigned short Lmaximum_velocity; // 28
00400   unsigned short Rmaximum_velocity; // 30
00401   unsigned short Lstall;  // 32
00402   unsigned short Rstall;  // 34
00403   unsigned short resolution; // 36
00404   unsigned short robot_diameter; // 38
00405 
00406 /* for the real JAUS definition
00407   unsigned short front;    // 19*2=38+19=57
00408   unsigned short back;
00409   unsigned short right;
00410   unsigned short left;
00411   unsigned short bottom;
00412   unsigned short top;
00413   unsigned short xcg;
00414   unsigned short ycg;
00415   unsigned short zcg;
00416   unsigned short turning_radius;
00417   unsigned short wheelbase;  // * overloaded.
00418   unsigned short trackwidth; // *
00419   unsigned short pitchover;
00420   unsigned short rollover;
00421   unsigned short mvx;           // *
00422   unsigned short mvy;
00423   unsigned short mvz;
00424   unsigned short mrr;
00425   unsigned short myr;
00426 */
00427 };
00428 // -----------------------
00429 // RELATIVE Object Postion
00430 // -----------------------
00431 struct relative_object_position_t
00432 {
00433 #if defined(BIG_ENDIAN) && !defined(LITTLE_ENDIAN)
00434   union  {
00435     struct  {
00436     unsigned short  df3 : 1;
00437     unsigned short  df4 : 1;
00438     unsigned short  df5 : 1;
00439     unsigned short  df6 : 1;
00440     unsigned short  df7 : 1;
00441     unsigned short  df8 : 1;
00442     unsigned short  df9 : 1;
00443     unsigned short  df10 : 1;
00444     unsigned short  df11 : 1;
00445     unsigned short  df12 : 1;
00446     unsigned short  R   : 6;
00447     } pv;
00448 #elif defined(LITTLE_ENDIAN) && !defined(BIG_ENDIAN)
00449   union  {
00450     struct  {
00451     unsigned short  R   : 6;
00452     unsigned short  df12 : 1;
00453     unsigned short  df11 : 1;
00454     unsigned short  df10 : 1;
00455     unsigned short  df9 : 1;
00456     unsigned short  df8 : 1;
00457     unsigned short  df7 : 1;
00458     unsigned short  df6 : 1;
00459     unsigned short  df5 : 1;
00460     unsigned short  df4 : 1;
00461     unsigned short  df3 : 1;
00462     } pv;
00463 #else
00464   #error "Either BIG_ENDIAN or LITTLE_ENDIAN must be #defined, but not both."
00465 #endif
00466     unsigned short presence_vector; // this needs htons applied.
00467   };
00468   short        pad; // 4
00469   unsigned int time_stamp; // 8
00470   unsigned int Range; // 12
00471   unsigned int Range_Error; // 16
00472   int          Bearing; // 20
00473   unsigned int Bearing_Error; // 24
00474   int          Elevation; // 28
00475   unsigned int Elevation_Error; // 32
00476   uint8         Confidence; // 33
00477 };
00478 // -----------------------
00479 // Set Local Pose
00480 // -----------------------
00481 struct local_pose_t
00482 {
00483 #if defined(BIG_ENDIAN) && !defined(LITTLE_ENDIAN)
00484   union  {
00485     struct  {
00486     unsigned short  df2 : 1;
00487     unsigned short  df3 : 1;
00488     unsigned short  df4 : 1;
00489     unsigned short  df5 : 1;
00490     unsigned short  df6 : 1;
00491     unsigned short  df7 : 1;
00492     unsigned short  df8 : 1;
00493     unsigned short  df9 : 1;
00494     unsigned short  df10: 1;
00495     unsigned short  df11: 1;
00496     unsigned short  R   : 6;
00497     } pv;
00498 #elif defined(LITTLE_ENDIAN) && !defined(BIG_ENDIAN)
00499   union  {
00500     struct  {
00501     unsigned short  R   : 6;
00502     unsigned short  df11: 1;
00503     unsigned short  df10: 1;
00504     unsigned short  df9 : 1;
00505     unsigned short  df8 : 1;
00506     unsigned short  df7 : 1;
00507     unsigned short  df6 : 1;
00508     unsigned short  df5 : 1;
00509     unsigned short  df4 : 1;
00510     unsigned short  df3 : 1;
00511     unsigned short  df2 : 1;
00512     } pv;
00513 #else
00514   #error "Either BIG_ENDIAN or LITTLE_ENDIAN must be #defined, but not both."
00515 #endif
00516     unsigned short presence_vector; // this needs htons applied.
00517   };
00518   short          pad;
00519   int            X;
00520   int            Y;
00521   int            Z;
00522   unsigned int   position_RMS;
00523   short          roll;
00524   short          pitch;
00525   short          yaw;
00526   unsigned short attitude_RMS;
00527   unsigned int   time_stamp;
00528   unsigned short data_validity;
00529 };
00530 // -----------------------
00531 // VELOCITY STATE
00532 // -----------------------
00533 struct velocity_state_t
00534 {
00535 #if defined(BIG_ENDIAN) && !defined(LITTLE_ENDIAN)
00536   union  {
00537     struct  {
00538     unsigned short  df2 : 1;
00539     unsigned short  df3 : 1;
00540     unsigned short  df4 : 1;
00541     unsigned short  df5 : 1;
00542     unsigned short  df6 : 1;
00543     unsigned short  df7 : 1;
00544     unsigned short  df8 : 1;
00545     unsigned short  df9 : 1;
00546     unsigned short  df10: 1;
00547     unsigned short  df11: 1;
00548     unsigned short  R   : 6;
00549     } pv;
00550 #elif defined(LITTLE_ENDIAN) && !defined(BIG_ENDIAN)
00551   union  {
00552     struct  {
00553     unsigned short  R   : 6;
00554     unsigned short  df11: 1;
00555     unsigned short  df10: 1;
00556     unsigned short  df9 : 1;
00557     unsigned short  df8 : 1;
00558     unsigned short  df7 : 1;
00559     unsigned short  df6 : 1;
00560     unsigned short  df5 : 1;
00561     unsigned short  df4 : 1;
00562     unsigned short  df3 : 1;
00563     unsigned short  df2 : 1;
00564     } pv;
00565 #else
00566   #error "Either BIG_ENDIAN or LITTLE_ENDIAN must be #defined, but not both."
00567 #endif
00568     unsigned short presence_vector; // this needs htons applied.
00569   };
00570   short          pad;
00571   int            X;
00572   int            Y;
00573   int            Z;
00574   unsigned int   velocity_RMS;
00575   short          roll;
00576   short          pitch;
00577   short          yaw;
00578   unsigned short rate_RMS;
00579   unsigned int   time_stamp;
00580   unsigned short data_validity;
00581 };
00582 // -----------------------
00583 // LOCAL VECTOR (this is actually global vector)
00584 // -----------------------
00585 /*
00586 struct local_vector_t
00587 {
00588 #if defined(BIG_ENDIAN) && !defined(LITTLE_ENDIAN)
00589   union  {
00590     struct  {
00591     uint8  df2 : 1;
00592     uint8  df3 : 1;
00593     uint8  df4 : 1;
00594     uint8  df5 : 1;
00595     uint8  df6 : 1;
00596     uint8  R   : 3;
00597     } pv;
00598 #elif defined(LITTLE_ENDIAN) && !defined(BIG_ENDIAN)
00599   union  {
00600     struct  {
00601     uint8  R   : 3;
00602     uint8  df6 : 1;
00603     uint8  df5 : 1;
00604     uint8  df4 : 1;
00605     uint8  df3 : 1;
00606     uint8  df2 : 1;
00607     } pv;
00608 #else
00609   #error "Either BIG_ENDIAN or LITTLE_ENDIAN must be #defined, but not both."
00610 #endif
00611     uint8 presence_vector; // this needs htons applied.
00612   };
00613   uint8           pad;
00614   unsigned short speed; 
00615   int            altitude;
00616   short          heading;
00617   short          roll;
00618   short          pitch;
00619 };
00620 */
00621 // -----------------------
00622 // Set Local Waypoint
00623 // -----------------------
00624 struct set_local_waypoint_t
00625 {
00626 #if defined(BIG_ENDIAN) && !defined(LITTLE_ENDIAN)
00627   union  {
00628     struct  {
00629     uint8  df5 : 1;
00630     uint8  df6 : 1;
00631     uint8  df7 : 1;
00632     uint8  df8 : 1;
00633     uint8  R   : 4;
00634     } pv;
00635 #elif defined(LITTLE_ENDIAN) && !defined(BIG_ENDIAN)
00636   union  {
00637     struct  {
00638     uint8  R   : 4;
00639     uint8  df8 : 1;
00640     uint8  df7 : 1;
00641     uint8  df6 : 1;
00642     uint8  df5 : 1;
00643     } pv;
00644 #else
00645   #error "Either BIG_ENDIAN or LITTLE_ENDIAN must be #defined, but not both."
00646 #endif
00647     uint8 presence_vector; // this needs htons applied.
00648   };
00649   uint8           pad; // 2
00650   unsigned short number; // 4 these need htons applied.
00651   int            X; // 8
00652   int            Y; // 12
00653   int            Z; // 16
00654   short          roll; // 18
00655   short          pitch; // 20
00656   short          yaw; // 22
00657   short          function; // 24 non JAUS compliant activity code.
00658 };
00659 typedef set_local_waypoint_t report_local_waypoint_t;
00660 
00661 // -----------------------
00662 // Query Local Waypoint
00663 // -----------------------
00664 struct query_local_waypoint_t
00665 {
00666   short         number;
00667 };
00668 typedef query_local_waypoint_t waypoint_count_t;
00669 // -----------------------
00670 // Set Wrench Effort
00671 // -----------------------
00672 struct set_wrench_effort_t
00673 {
00674 #if defined(BIG_ENDIAN) && !defined(LITTLE_ENDIAN)
00675   union  {
00676     struct  {
00677     unsigned short  df2 : 1;
00678     unsigned short  df3 : 1;
00679     unsigned short  df4 : 1;
00680     unsigned short  df5 : 1;
00681     unsigned short  df6 : 1;
00682     unsigned short  df7 : 1;
00683     unsigned short  df8 : 1;
00684     unsigned short  df9 : 1;
00685     unsigned short  df10: 1;
00686     unsigned short  df11: 1;
00687     unsigned short  df12: 1;
00688     unsigned short  df13: 1;
00689     unsigned short  R   : 4;
00690     } pv;
00691 #elif defined(LITTLE_ENDIAN) && !defined(BIG_ENDIAN)
00692   union  {
00693     struct  {
00694     unsigned short  R   : 4;
00695     unsigned short  df13: 1;
00696     unsigned short  df12: 1;
00697     unsigned short  df11: 1;
00698     unsigned short  df10: 1;
00699     unsigned short  df9 : 1;
00700     unsigned short  df8 : 1;
00701     unsigned short  df7 : 1;
00702     unsigned short  df6 : 1;
00703     unsigned short  df5 : 1;
00704     unsigned short  df4 : 1;
00705     unsigned short  df3 : 1;
00706     unsigned short  df2 : 1;
00707     } pv;
00708 #else
00709   #error "Either BIG_ENDIAN or LITTLE_ENDIAN must be #defined, but not both."
00710 #endif
00711     unsigned short presence_vector; // this needs htons applied.
00712   };
00713  // unfortunately backwards, I need to calculate the speed from the throttle setting.
00714   short            PLE_x; // 2
00715   short            PLE_y; // 4
00716   short            PLE_z; // 6
00717   short            PRE_x; // 8
00718   short            PRE_y; // 10
00719   short            PRE_z; // 12 (rotation turn)
00720   // probably should define brake(100) as brake() rather than speed(0) which has slightly different semantic.
00721   uint8             RLE_x;  // 13(brake) uint8s do not need to have network transforms applied (htons, etc.).
00722   uint8             RLE_y; // 14
00723   uint8             RLE_z; // 15
00724   uint8             RRE_x; // 16
00725   uint8             RRE_y; // 17
00726   uint8             RRE_z; // 18
00727 };
00728 
00729 
00733 #define NO_ACKNOWLEDGE 0
00734 
00737 #define ACKNOWLEDGE 1
00738 
00741 #define ACKNOWLEDGE_NEGATIVE 2
00742 
00745 #define ACKNOWLEDGE_OK 3
00746 
00747 
00754 // PC, etc. (need portable solution) This needs htons applied--I don't think it matters whether you delcare as uint8 or word (in GCC).
00756 #if !defined(BIG_ENDIAN) && defined(LITTLE_ENDIAN)
00757 typedef union
00758 {
00759 struct  {
00760   volatile word R        : 2;
00761   volatile word version  : 6;
00762   volatile word ef       : 1; // ack, spf, ef
00763   volatile word scf      : 1;
00765 
00777   volatile word acknak   : 2;
00779 
00790   volatile word priority : 4;
00791 } bits;
00792 word FULLWORD;
00793 } properties_t;
00794 #elif defined(BIG_ENDIAN) && !defined(LITTLE_ENDIAN)
00795 // SUN, 68K, etc. 
00796 typedef union
00797 {
00798 struct  {
00799   volatile word priority : 4;
00800   volatile word acknak   : 2; // ef, spf, ack
00801   volatile word scf      : 1;
00802   volatile word ef       : 1;
00803   volatile word version  : 6;
00804   volatile word R        : 2;
00805 } bits;
00806 word FULLWORD;
00807 } properties_t;
00808 #else
00809   #error "Either BIG_ENDIAN or LITTLE_ENDIAN must be #defined, but not both."
00810 #endif
00811 
00812 
00813 typedef union
00814 {
00815 struct {
00816   uint8 instance;
00817   uint8 component;
00818   uint8 node;
00819   uint8 subsystem;
00820 } bits;
00821 long_word FULLWORD;
00822 } ID_T;
00823 
00824 
00825 
00826 typedef union
00827 {
00828 struct {
00829 #if defined(BIG_ENDIAN) && !defined(LITTLE_ENDIAN)
00830   unsigned short data_size : 12;
00831   unsigned short data_flag : 4;
00832 #elif defined(LITTLE_ENDIAN) && !defined(BIG_ENDIAN)
00833   unsigned short data_flag : 4;
00834   unsigned short data_size : 12;
00835 #else
00836   #error "Either BIG_ENDIAN or LITTLE_ENDIAN must be #defined, but not both."
00837 #endif
00838 } bits;
00839 word FULLWORD;
00840 } data_control_T2;
00841 
00842 struct header_t {
00843   properties_t            properties; // 2
00844   unsigned short          command_code; // 2
00845   ID_T                    destination; // 4
00846   ID_T                    source; // 4
00847   data_control_T2         data_control; // 2
00848   unsigned short          sequence_number; // 2
00849 };
00850 
00851 struct service_connection_t
00852 {
00853   unsigned short command; // 2 command code for service connection
00854   unsigned short rate; // 4 rate of service connection
00855 //  unsigned int   pv;     // 8 presence vector.
00856   ID_T           destination; // 14 service proxy node (same subsystem
00857   uint8          id;  // 9
00858   uint8          response_code; // 10
00859 
00860 };
00861 
00862 void hton(header_t* const);
00863 void ntoh(header_t* const);
00864 
00865 // represents a JAUS expanded format message consisting of a JAUS compliant header followed by one of the 
00866 // JAUS compliant expanded messages.  An expanded message is one that transmits all field within the prescence vector.
00867 // By requiring all fields, parsing can be done simply by converting the incoming uint8 stream into the appropriate structure
00868 // represented by the data.  the obvious disadvantage is the trasmission of unused uint8s.
00869 
00870 
00871 
00872 struct message {
00873   header_t             header; // 16
00874   union {
00875     IS_t                IS;
00876     system_message_t   system_message; // 8
00877     service_connection_t service_connection;
00878     authority_code_t    authority_code;
00879     set_emergency_t     set_emergency; 
00880     set_wrench_effort_t set_wrench_effort; // 20
00881     set_local_waypoint_t set_local_waypoint; // 24
00882     discrete_device_t   discrete_device; // 5
00883     local_pose_t        local_pose; // 32
00884     velocity_state_t    velocity_state;
00885     clear_emergency_t   clear_emergency;
00886     query_local_waypoint_t query_local_waypoint; // 2
00887     travel_speed_t  travel_speed; // 4
00888     status_indicator_t  indicators; // 4
00889     respond_component_t respond_component; // 1
00890     report_local_waypoint_t report_local_waypoint; // 24
00891     local_vector_t      local_vector; // 21
00892     relative_object_position_t relative_object_position; // 31
00893     platform_specification_t platform_specification; // 38
00894     component_status_t  component_status; // 3
00895     waypoint_count_t    waypoint_count;
00896     system_error_t      system_error;
00897     camera_settings_t camera_settings;
00898     camera_format_t   camera_format; // 8
00899   };
00900 };
00901 
00902 extern void jaus_message_send_sci_callback(char c);
00903 
00904 //#define COMPONENT_MAX 10
00905 #define NO_SERVICE_CONNECTION 0
00906 #define SERVICE_CONNECTION 1
00907 
00908 
00909 class jaus_message 
00910 {
00911 public:
00912   static MESSAGE_CLASS message_class(JAUS_MESSAGE jm);
00913   // factory used to both create and terminate SC
00914   void service_connection(unsigned short cc, unsigned short irate);
00915   void service_connection_confirm(unsigned short cc, unsigned short irate, uint8 rc, uint8 id);
00916   void service_connection_activate(unsigned short cc, uint8 id);
00917   void local_vector(int speed, FIXED_POINT radians, uint32 distance);
00918   void IS(int isid, int ipid, int ivalue, short x=0, short y=0);
00919   void system_error(int e, int l);
00920   void local_map_spec(unsigned short);
00921   void wrench_effort(short, short, short);
00922   void local_waypoint(short num,int x, int y, short iyaw, short ifn); // added non JAUS compliant activity code.
00923   void local_waypoint(short num);
00924   void local_pose(int X, int Y, short yaw); // maybe add others later.
00925   void system_message(OOMRM_Message m);
00926   void camera_settings(unsigned short, unsigned short, unsigned short, unsigned short);
00927   void jaus_message::camera_format(uint32 ioptions);
00928   void travel_speed(unsigned short ispeed);
00929   void status_indicator(uint16 value);
00930   void discrete_device(uint8 horn);
00931   void component_status(uint8 primary, unsigned int secondary);
00932   void relative_object_position(unsigned int itime, unsigned int irange, int ibearing);
00933   void platform_specification(const char* const iname,uint8 obstacle, word wb, word lwd, word rwd, word lmv, word rmv, word lstall, word rstall, word resolution, word rd);
00934   void respond_component(uint8 subclass);
00935   // NOTE: last parameter is for OSCPUUsage from uCOS if used.
00936   void header(uint8 ipriority, word cc, uint8 ack, JAUS_DATA_FLAG flag, // const ID_T& isrc, const ID_T& idest)
00937                  uint8 Sss, uint8  Snode, uint8 Scomp, uint8 Sinst,
00938          uint8 Dss, uint8  Dnode, uint8 Dcomp, uint8 Dinst, int8 cpu=0);
00939   // internal version that does not put in network order.
00940   void iheader(uint8 ipriority, word cc, uint8 ack, JAUS_DATA_FLAG flag, // const ID_T& isrc, const ID_T& idest)
00941                  uint8 Sss, uint8  Snode, uint8 Scomp, uint8 Sinst,
00942          uint8 Dss, uint8  Dnode, uint8 Dcomp, uint8 Dinst, int8 cpu=0);
00943   void receive(void);
00944   message* msg(void);
00945   void send(void);
00946   void inter_send(void);
00947   #ifdef DOS
00948   static const char* log_message(jaus_message &lmsg);
00949   #endif
00950   static void send_simple_message(uint8 ipriority, word cc, uint8 ack, JAUS_DATA_FLAG flag, // const ID_T& isrc, const ID_T& idest)
00951              uint8 Sss, uint8  Snode, uint8 Scomp, uint8 Sinst,
00952          uint8 Dss, uint8  Dnode, uint8 Dcomp, uint8 Dinst);
00953   message _message;
00954 };
00955 // Utilities
00956 const char* format_message(char idir, char hexbuf[]);
00957 
00958 typedef void (*fooxmit)(jaus_message&, uint8); // uart callback
00959 
00960 #endif

Generated on Mon Oct 8 19:32:19 2007 for OOMRM Mapping API by doxygen1.3