Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
Status.h
00001 #ifndef _ROS_mav_msgs_Status_h 00002 #define _ROS_mav_msgs_Status_h 00003 00004 #include <stdint.h> 00005 #include <string.h> 00006 #include <stdlib.h> 00007 #include "ros/msg.h" 00008 #include "std_msgs/Header.h" 00009 00010 namespace mav_msgs 00011 { 00012 00013 class Status : public ros::Msg 00014 { 00015 public: 00016 typedef std_msgs::Header _header_type; 00017 _header_type header; 00018 typedef const char* _vehicle_name_type; 00019 _vehicle_name_type vehicle_name; 00020 typedef const char* _vehicle_type_type; 00021 _vehicle_type_type vehicle_type; 00022 typedef float _battery_voltage_type; 00023 _battery_voltage_type battery_voltage; 00024 typedef const char* _rc_command_mode_type; 00025 _rc_command_mode_type rc_command_mode; 00026 typedef bool _command_interface_enabled_type; 00027 _command_interface_enabled_type command_interface_enabled; 00028 typedef float _flight_time_type; 00029 _flight_time_type flight_time; 00030 typedef float _system_uptime_type; 00031 _system_uptime_type system_uptime; 00032 typedef float _cpu_load_type; 00033 _cpu_load_type cpu_load; 00034 typedef const char* _motor_status_type; 00035 _motor_status_type motor_status; 00036 typedef bool _in_air_type; 00037 _in_air_type in_air; 00038 typedef const char* _gps_status_type; 00039 _gps_status_type gps_status; 00040 typedef int32_t _gps_num_satellites_type; 00041 _gps_num_satellites_type gps_num_satellites; 00042 enum { RC_COMMAND_ATTITUDE = "attitude_thrust" }; 00043 enum { RC_COMMAND_ATTITUDE_HEIGHT = "attitude_height" }; 00044 enum { RC_COMMAND_POSITION = "position" }; 00045 enum { MOTOR_STATUS_RUNNING = "running" }; 00046 enum { MOTOR_STATUS_STOPPED = "stopped" }; 00047 enum { MOTOR_STATUS_STARTING = "starting" }; 00048 enum { MOTOR_STATUS_STOPPING = "stopping" }; 00049 enum { GPS_STATUS_LOCK = "lock" }; 00050 enum { GPS_STATUS_NO_LOCK = "no_lock" }; 00051 00052 Status(): 00053 header(), 00054 vehicle_name(""), 00055 vehicle_type(""), 00056 battery_voltage(0), 00057 rc_command_mode(""), 00058 command_interface_enabled(0), 00059 flight_time(0), 00060 system_uptime(0), 00061 cpu_load(0), 00062 motor_status(""), 00063 in_air(0), 00064 gps_status(""), 00065 gps_num_satellites(0) 00066 { 00067 } 00068 00069 virtual int serialize(unsigned char *outbuffer) const 00070 { 00071 int offset = 0; 00072 offset += this->header.serialize(outbuffer + offset); 00073 uint32_t length_vehicle_name = strlen(this->vehicle_name); 00074 varToArr(outbuffer + offset, length_vehicle_name); 00075 offset += 4; 00076 memcpy(outbuffer + offset, this->vehicle_name, length_vehicle_name); 00077 offset += length_vehicle_name; 00078 uint32_t length_vehicle_type = strlen(this->vehicle_type); 00079 varToArr(outbuffer + offset, length_vehicle_type); 00080 offset += 4; 00081 memcpy(outbuffer + offset, this->vehicle_type, length_vehicle_type); 00082 offset += length_vehicle_type; 00083 union { 00084 float real; 00085 uint32_t base; 00086 } u_battery_voltage; 00087 u_battery_voltage.real = this->battery_voltage; 00088 *(outbuffer + offset + 0) = (u_battery_voltage.base >> (8 * 0)) & 0xFF; 00089 *(outbuffer + offset + 1) = (u_battery_voltage.base >> (8 * 1)) & 0xFF; 00090 *(outbuffer + offset + 2) = (u_battery_voltage.base >> (8 * 2)) & 0xFF; 00091 *(outbuffer + offset + 3) = (u_battery_voltage.base >> (8 * 3)) & 0xFF; 00092 offset += sizeof(this->battery_voltage); 00093 uint32_t length_rc_command_mode = strlen(this->rc_command_mode); 00094 varToArr(outbuffer + offset, length_rc_command_mode); 00095 offset += 4; 00096 memcpy(outbuffer + offset, this->rc_command_mode, length_rc_command_mode); 00097 offset += length_rc_command_mode; 00098 union { 00099 bool real; 00100 uint8_t base; 00101 } u_command_interface_enabled; 00102 u_command_interface_enabled.real = this->command_interface_enabled; 00103 *(outbuffer + offset + 0) = (u_command_interface_enabled.base >> (8 * 0)) & 0xFF; 00104 offset += sizeof(this->command_interface_enabled); 00105 union { 00106 float real; 00107 uint32_t base; 00108 } u_flight_time; 00109 u_flight_time.real = this->flight_time; 00110 *(outbuffer + offset + 0) = (u_flight_time.base >> (8 * 0)) & 0xFF; 00111 *(outbuffer + offset + 1) = (u_flight_time.base >> (8 * 1)) & 0xFF; 00112 *(outbuffer + offset + 2) = (u_flight_time.base >> (8 * 2)) & 0xFF; 00113 *(outbuffer + offset + 3) = (u_flight_time.base >> (8 * 3)) & 0xFF; 00114 offset += sizeof(this->flight_time); 00115 union { 00116 float real; 00117 uint32_t base; 00118 } u_system_uptime; 00119 u_system_uptime.real = this->system_uptime; 00120 *(outbuffer + offset + 0) = (u_system_uptime.base >> (8 * 0)) & 0xFF; 00121 *(outbuffer + offset + 1) = (u_system_uptime.base >> (8 * 1)) & 0xFF; 00122 *(outbuffer + offset + 2) = (u_system_uptime.base >> (8 * 2)) & 0xFF; 00123 *(outbuffer + offset + 3) = (u_system_uptime.base >> (8 * 3)) & 0xFF; 00124 offset += sizeof(this->system_uptime); 00125 union { 00126 float real; 00127 uint32_t base; 00128 } u_cpu_load; 00129 u_cpu_load.real = this->cpu_load; 00130 *(outbuffer + offset + 0) = (u_cpu_load.base >> (8 * 0)) & 0xFF; 00131 *(outbuffer + offset + 1) = (u_cpu_load.base >> (8 * 1)) & 0xFF; 00132 *(outbuffer + offset + 2) = (u_cpu_load.base >> (8 * 2)) & 0xFF; 00133 *(outbuffer + offset + 3) = (u_cpu_load.base >> (8 * 3)) & 0xFF; 00134 offset += sizeof(this->cpu_load); 00135 uint32_t length_motor_status = strlen(this->motor_status); 00136 varToArr(outbuffer + offset, length_motor_status); 00137 offset += 4; 00138 memcpy(outbuffer + offset, this->motor_status, length_motor_status); 00139 offset += length_motor_status; 00140 union { 00141 bool real; 00142 uint8_t base; 00143 } u_in_air; 00144 u_in_air.real = this->in_air; 00145 *(outbuffer + offset + 0) = (u_in_air.base >> (8 * 0)) & 0xFF; 00146 offset += sizeof(this->in_air); 00147 uint32_t length_gps_status = strlen(this->gps_status); 00148 varToArr(outbuffer + offset, length_gps_status); 00149 offset += 4; 00150 memcpy(outbuffer + offset, this->gps_status, length_gps_status); 00151 offset += length_gps_status; 00152 union { 00153 int32_t real; 00154 uint32_t base; 00155 } u_gps_num_satellites; 00156 u_gps_num_satellites.real = this->gps_num_satellites; 00157 *(outbuffer + offset + 0) = (u_gps_num_satellites.base >> (8 * 0)) & 0xFF; 00158 *(outbuffer + offset + 1) = (u_gps_num_satellites.base >> (8 * 1)) & 0xFF; 00159 *(outbuffer + offset + 2) = (u_gps_num_satellites.base >> (8 * 2)) & 0xFF; 00160 *(outbuffer + offset + 3) = (u_gps_num_satellites.base >> (8 * 3)) & 0xFF; 00161 offset += sizeof(this->gps_num_satellites); 00162 return offset; 00163 } 00164 00165 virtual int deserialize(unsigned char *inbuffer) 00166 { 00167 int offset = 0; 00168 offset += this->header.deserialize(inbuffer + offset); 00169 uint32_t length_vehicle_name; 00170 arrToVar(length_vehicle_name, (inbuffer + offset)); 00171 offset += 4; 00172 for(unsigned int k= offset; k< offset+length_vehicle_name; ++k){ 00173 inbuffer[k-1]=inbuffer[k]; 00174 } 00175 inbuffer[offset+length_vehicle_name-1]=0; 00176 this->vehicle_name = (char *)(inbuffer + offset-1); 00177 offset += length_vehicle_name; 00178 uint32_t length_vehicle_type; 00179 arrToVar(length_vehicle_type, (inbuffer + offset)); 00180 offset += 4; 00181 for(unsigned int k= offset; k< offset+length_vehicle_type; ++k){ 00182 inbuffer[k-1]=inbuffer[k]; 00183 } 00184 inbuffer[offset+length_vehicle_type-1]=0; 00185 this->vehicle_type = (char *)(inbuffer + offset-1); 00186 offset += length_vehicle_type; 00187 union { 00188 float real; 00189 uint32_t base; 00190 } u_battery_voltage; 00191 u_battery_voltage.base = 0; 00192 u_battery_voltage.base |= ((uint32_t) (*(inbuffer + offset + 0))) << (8 * 0); 00193 u_battery_voltage.base |= ((uint32_t) (*(inbuffer + offset + 1))) << (8 * 1); 00194 u_battery_voltage.base |= ((uint32_t) (*(inbuffer + offset + 2))) << (8 * 2); 00195 u_battery_voltage.base |= ((uint32_t) (*(inbuffer + offset + 3))) << (8 * 3); 00196 this->battery_voltage = u_battery_voltage.real; 00197 offset += sizeof(this->battery_voltage); 00198 uint32_t length_rc_command_mode; 00199 arrToVar(length_rc_command_mode, (inbuffer + offset)); 00200 offset += 4; 00201 for(unsigned int k= offset; k< offset+length_rc_command_mode; ++k){ 00202 inbuffer[k-1]=inbuffer[k]; 00203 } 00204 inbuffer[offset+length_rc_command_mode-1]=0; 00205 this->rc_command_mode = (char *)(inbuffer + offset-1); 00206 offset += length_rc_command_mode; 00207 union { 00208 bool real; 00209 uint8_t base; 00210 } u_command_interface_enabled; 00211 u_command_interface_enabled.base = 0; 00212 u_command_interface_enabled.base |= ((uint8_t) (*(inbuffer + offset + 0))) << (8 * 0); 00213 this->command_interface_enabled = u_command_interface_enabled.real; 00214 offset += sizeof(this->command_interface_enabled); 00215 union { 00216 float real; 00217 uint32_t base; 00218 } u_flight_time; 00219 u_flight_time.base = 0; 00220 u_flight_time.base |= ((uint32_t) (*(inbuffer + offset + 0))) << (8 * 0); 00221 u_flight_time.base |= ((uint32_t) (*(inbuffer + offset + 1))) << (8 * 1); 00222 u_flight_time.base |= ((uint32_t) (*(inbuffer + offset + 2))) << (8 * 2); 00223 u_flight_time.base |= ((uint32_t) (*(inbuffer + offset + 3))) << (8 * 3); 00224 this->flight_time = u_flight_time.real; 00225 offset += sizeof(this->flight_time); 00226 union { 00227 float real; 00228 uint32_t base; 00229 } u_system_uptime; 00230 u_system_uptime.base = 0; 00231 u_system_uptime.base |= ((uint32_t) (*(inbuffer + offset + 0))) << (8 * 0); 00232 u_system_uptime.base |= ((uint32_t) (*(inbuffer + offset + 1))) << (8 * 1); 00233 u_system_uptime.base |= ((uint32_t) (*(inbuffer + offset + 2))) << (8 * 2); 00234 u_system_uptime.base |= ((uint32_t) (*(inbuffer + offset + 3))) << (8 * 3); 00235 this->system_uptime = u_system_uptime.real; 00236 offset += sizeof(this->system_uptime); 00237 union { 00238 float real; 00239 uint32_t base; 00240 } u_cpu_load; 00241 u_cpu_load.base = 0; 00242 u_cpu_load.base |= ((uint32_t) (*(inbuffer + offset + 0))) << (8 * 0); 00243 u_cpu_load.base |= ((uint32_t) (*(inbuffer + offset + 1))) << (8 * 1); 00244 u_cpu_load.base |= ((uint32_t) (*(inbuffer + offset + 2))) << (8 * 2); 00245 u_cpu_load.base |= ((uint32_t) (*(inbuffer + offset + 3))) << (8 * 3); 00246 this->cpu_load = u_cpu_load.real; 00247 offset += sizeof(this->cpu_load); 00248 uint32_t length_motor_status; 00249 arrToVar(length_motor_status, (inbuffer + offset)); 00250 offset += 4; 00251 for(unsigned int k= offset; k< offset+length_motor_status; ++k){ 00252 inbuffer[k-1]=inbuffer[k]; 00253 } 00254 inbuffer[offset+length_motor_status-1]=0; 00255 this->motor_status = (char *)(inbuffer + offset-1); 00256 offset += length_motor_status; 00257 union { 00258 bool real; 00259 uint8_t base; 00260 } u_in_air; 00261 u_in_air.base = 0; 00262 u_in_air.base |= ((uint8_t) (*(inbuffer + offset + 0))) << (8 * 0); 00263 this->in_air = u_in_air.real; 00264 offset += sizeof(this->in_air); 00265 uint32_t length_gps_status; 00266 arrToVar(length_gps_status, (inbuffer + offset)); 00267 offset += 4; 00268 for(unsigned int k= offset; k< offset+length_gps_status; ++k){ 00269 inbuffer[k-1]=inbuffer[k]; 00270 } 00271 inbuffer[offset+length_gps_status-1]=0; 00272 this->gps_status = (char *)(inbuffer + offset-1); 00273 offset += length_gps_status; 00274 union { 00275 int32_t real; 00276 uint32_t base; 00277 } u_gps_num_satellites; 00278 u_gps_num_satellites.base = 0; 00279 u_gps_num_satellites.base |= ((uint32_t) (*(inbuffer + offset + 0))) << (8 * 0); 00280 u_gps_num_satellites.base |= ((uint32_t) (*(inbuffer + offset + 1))) << (8 * 1); 00281 u_gps_num_satellites.base |= ((uint32_t) (*(inbuffer + offset + 2))) << (8 * 2); 00282 u_gps_num_satellites.base |= ((uint32_t) (*(inbuffer + offset + 3))) << (8 * 3); 00283 this->gps_num_satellites = u_gps_num_satellites.real; 00284 offset += sizeof(this->gps_num_satellites); 00285 return offset; 00286 } 00287 00288 const char * getType(){ return "mav_msgs/Status"; }; 00289 const char * getMD5(){ return "e191265664a5f7c1871338dc13be0958"; }; 00290 00291 }; 00292 00293 } 00294 #endif
Generated on Thu Jul 14 2022 10:09:24 by
