ROS Serial C client library
|
00001 00018 #ifndef __ROS_TYPES_H__ 00019 #define __ROS_TYPES_H__ 00020 /* ROS includes */ 00021 #include "ros_std.h" 00022 #include "ros_config.h" 00023 /******************************************************/ 00024 /* */ 00025 /* PROTOTYPES */ 00026 /* */ 00027 /******************************************************/ 00028 typedef struct rosMessageHandle rosMessageHandle_t; 00029 /******************************************************/ 00030 /* */ 00031 /* RETURN CODES */ 00032 /* */ 00033 /******************************************************/ 00037 typedef enum rosReturnCode 00038 { 00039 ROS_NOT_OK = 0, 00040 ROS_OK, 00041 ROS_SUCCESS, 00042 ROS_FAIL, 00043 ROS_INIT_NOT_CALLED, 00044 ROS_NODEHANDLE_NOT_CONFIGURED, 00045 ROS_CONFIGURING, 00046 ROS_OUT_OF_MEMORY, 00047 ROS_FIFO_BUFFER_EMPTY, 00048 ROS_FIFO_BUFFER_OVERFLOW, 00049 } rosReturnCode_t; 00050 /******************************************************/ 00051 /* */ 00052 /* FIFO BUFFER */ 00053 /* */ 00054 /******************************************************/ 00058 typedef struct rosFifoBuffer 00059 { 00060 uint8_t *data; 00061 uint8_t read_index; 00062 uint8_t write_index; 00063 rosReturnCode_t (*write)(uint8_t* byte); 00064 rosReturnCode_t (*read)(uint8_t* byte); 00065 } rosFifoBuffer_t; 00066 /******************************************************/ 00067 /* */ 00068 /* PACKET */ 00069 /* */ 00070 /******************************************************/ 00074 typedef struct rosPacket 00075 { 00076 union 00077 { 00078 uint8_t sync_flag_[2]; 00079 uint16_t sync_flag; 00080 }; 00081 union 00082 { 00083 uint8_t topic_id_[2]; 00084 uint16_t topic_id; 00085 }; 00086 union 00087 { 00088 uint8_t message_length_[2]; 00089 uint16_t message_length; 00090 }; 00091 uint8_t* buffer; 00092 uint16_t buffer_size; 00093 uint8_t checksum; 00094 } rosPacket_t; 00095 /******************************************************/ 00096 /* */ 00097 /* TIME */ 00098 /* */ 00099 /******************************************************/ 00103 typedef struct rosTime 00104 { 00105 uint32_t sec; 00106 uint32_t nsec; 00107 } rosTime_t; 00111 typedef struct rosRate 00112 { 00113 uint32_t last_wake_time; 00114 uint32_t frequency; 00115 } rosRate_t; 00116 /******************************************************/ 00117 /* */ 00118 /* PUBLISHER */ 00119 /* */ 00120 /******************************************************/ 00124 typedef struct rosPublisher 00125 { 00126 rosMessageHandle_t* messagehandle; 00127 rosReturnCode_t (*publish)(void* message); 00128 } rosPublisher_t; 00129 /******************************************************/ 00130 /* */ 00131 /* SUBSCRIBER */ 00132 /* */ 00133 /******************************************************/ 00137 typedef struct rosSubscriber 00138 { 00139 rosMessageHandle_t* messagehandle; 00140 void (*callback)(void* message); 00141 } rosSubscriber_t; 00142 /******************************************************/ 00143 /* */ 00144 /* INTERFACE */ 00145 /* */ 00146 /******************************************************/ 00150 typedef enum INTERFACE_TYPE 00151 { 00152 SLAVE, 00153 MASTER, 00154 BRIDGE, 00155 LOOPBACK, 00156 } rosInterfaceType_t; 00160 typedef struct rosInterface 00161 { 00162 char* device_id; 00163 rosReturnCode_t (*send)(void* data); 00164 rosReturnCode_t (*receive)(void* data); 00165 // bool package_oriented; /**< Used to determine if send function is called once or more */ 00166 rosInterfaceType_t interface_type; 00167 } rosInterface_t; 00168 /******************************************************/ 00169 /* */ 00170 /* NODEHANDLE */ 00171 /* */ 00172 /******************************************************/ 00176 typedef struct rosNodeHandle 00177 { 00199 rosPublisher_t* (*advertise)(rosMessageHandle_t* messagehandle, char* topic, uint16_t buffer_size); 00231 rosSubscriber_t* (*subscribe)(rosMessageHandle_t* messagehandle, char* topic, uint16_t buffer_size, void (*callback)(void* message)); 00232 struct rosSpinner* spinner; 00233 rosInterface_t* interface; 00234 rosPublisher_t *publishers[MAX_PUBLISHERS]; 00235 rosSubscriber_t *subscribers[MAX_SUBSCRIBERS]; 00236 uint8_t publisher_count; 00237 uint8_t subscriber_count; 00238 rosReturnCode_t ok; 00239 rosReturnCode_t configured; 00240 } rosNodeHandle_t; 00241 /******************************************************/ 00242 /* */ 00243 /* MESSAGEHANDLE */ 00244 /* */ 00245 /******************************************************/ 00249 typedef struct rosMessageHandle 00250 { 00251 char* type; 00252 char* topic; 00253 char* md5sum; 00254 uint16_t id; 00255 uint16_t buffer_size; 00256 rosNodeHandle_t *nodehandle; 00257 int (*sizer)(void* message); 00258 void (*serializer)(void* message, uint8_t* buffer, int pos); 00259 void (*deserializer)(void* message, uint8_t* buffer, int pos); 00260 } rosMessageHandle_t; 00261 /******************************************************/ 00262 /* */ 00263 /* OS ROS NODES */ 00264 /* */ 00265 /******************************************************/ 00272 typedef struct osROSNode 00273 { 00274 void (*node_func)(void* args); 00275 const char* name; 00276 uint16_t stack_size; 00277 uint8_t priority; 00278 void* args; 00279 } osROSNode_t; 00280 #endif /* #ifndef __ROS_TYPES_H__ */