rosserial library for mbed Inspired by nucho's rosserial library This library is still under development

Dependencies:   MODSERIAL mbed

Dependents:   mbed_roshydro_test

Library still under development!

Committer:
akashvibhute
Date:
Sun Feb 15 10:53:43 2015 +0000
Revision:
0:30537dec6e0b
First commit; Library still need to be debugged, compilation issues with new mbed and modserial updates.

Who changed what in which revision?

UserRevisionLine numberNew contents of line
akashvibhute 0:30537dec6e0b 1 #ifndef _ROS_pr2_mechanism_msgs_ControllerStatistics_h
akashvibhute 0:30537dec6e0b 2 #define _ROS_pr2_mechanism_msgs_ControllerStatistics_h
akashvibhute 0:30537dec6e0b 3
akashvibhute 0:30537dec6e0b 4 #include <stdint.h>
akashvibhute 0:30537dec6e0b 5 #include <string.h>
akashvibhute 0:30537dec6e0b 6 #include <stdlib.h>
akashvibhute 0:30537dec6e0b 7 #include "ros/msg.h"
akashvibhute 0:30537dec6e0b 8 #include "ros/time.h"
akashvibhute 0:30537dec6e0b 9 #include "ros/duration.h"
akashvibhute 0:30537dec6e0b 10
akashvibhute 0:30537dec6e0b 11 namespace pr2_mechanism_msgs
akashvibhute 0:30537dec6e0b 12 {
akashvibhute 0:30537dec6e0b 13
akashvibhute 0:30537dec6e0b 14 class ControllerStatistics : public ros::Msg
akashvibhute 0:30537dec6e0b 15 {
akashvibhute 0:30537dec6e0b 16 public:
akashvibhute 0:30537dec6e0b 17 const char* name;
akashvibhute 0:30537dec6e0b 18 ros::Time timestamp;
akashvibhute 0:30537dec6e0b 19 bool running;
akashvibhute 0:30537dec6e0b 20 ros::Duration max_time;
akashvibhute 0:30537dec6e0b 21 ros::Duration mean_time;
akashvibhute 0:30537dec6e0b 22 ros::Duration variance_time;
akashvibhute 0:30537dec6e0b 23 int32_t num_control_loop_overruns;
akashvibhute 0:30537dec6e0b 24 ros::Time time_last_control_loop_overrun;
akashvibhute 0:30537dec6e0b 25
akashvibhute 0:30537dec6e0b 26 ControllerStatistics():
akashvibhute 0:30537dec6e0b 27 name(""),
akashvibhute 0:30537dec6e0b 28 timestamp(),
akashvibhute 0:30537dec6e0b 29 running(0),
akashvibhute 0:30537dec6e0b 30 max_time(),
akashvibhute 0:30537dec6e0b 31 mean_time(),
akashvibhute 0:30537dec6e0b 32 variance_time(),
akashvibhute 0:30537dec6e0b 33 num_control_loop_overruns(0),
akashvibhute 0:30537dec6e0b 34 time_last_control_loop_overrun()
akashvibhute 0:30537dec6e0b 35 {
akashvibhute 0:30537dec6e0b 36 }
akashvibhute 0:30537dec6e0b 37
akashvibhute 0:30537dec6e0b 38 virtual int serialize(unsigned char *outbuffer) const
akashvibhute 0:30537dec6e0b 39 {
akashvibhute 0:30537dec6e0b 40 int offset = 0;
akashvibhute 0:30537dec6e0b 41 uint32_t length_name = strlen(this->name);
akashvibhute 0:30537dec6e0b 42 memcpy(outbuffer + offset, &length_name, sizeof(uint32_t));
akashvibhute 0:30537dec6e0b 43 offset += 4;
akashvibhute 0:30537dec6e0b 44 memcpy(outbuffer + offset, this->name, length_name);
akashvibhute 0:30537dec6e0b 45 offset += length_name;
akashvibhute 0:30537dec6e0b 46 *(outbuffer + offset + 0) = (this->timestamp.sec >> (8 * 0)) & 0xFF;
akashvibhute 0:30537dec6e0b 47 *(outbuffer + offset + 1) = (this->timestamp.sec >> (8 * 1)) & 0xFF;
akashvibhute 0:30537dec6e0b 48 *(outbuffer + offset + 2) = (this->timestamp.sec >> (8 * 2)) & 0xFF;
akashvibhute 0:30537dec6e0b 49 *(outbuffer + offset + 3) = (this->timestamp.sec >> (8 * 3)) & 0xFF;
akashvibhute 0:30537dec6e0b 50 offset += sizeof(this->timestamp.sec);
akashvibhute 0:30537dec6e0b 51 *(outbuffer + offset + 0) = (this->timestamp.nsec >> (8 * 0)) & 0xFF;
akashvibhute 0:30537dec6e0b 52 *(outbuffer + offset + 1) = (this->timestamp.nsec >> (8 * 1)) & 0xFF;
akashvibhute 0:30537dec6e0b 53 *(outbuffer + offset + 2) = (this->timestamp.nsec >> (8 * 2)) & 0xFF;
akashvibhute 0:30537dec6e0b 54 *(outbuffer + offset + 3) = (this->timestamp.nsec >> (8 * 3)) & 0xFF;
akashvibhute 0:30537dec6e0b 55 offset += sizeof(this->timestamp.nsec);
akashvibhute 0:30537dec6e0b 56 union {
akashvibhute 0:30537dec6e0b 57 bool real;
akashvibhute 0:30537dec6e0b 58 uint8_t base;
akashvibhute 0:30537dec6e0b 59 } u_running;
akashvibhute 0:30537dec6e0b 60 u_running.real = this->running;
akashvibhute 0:30537dec6e0b 61 *(outbuffer + offset + 0) = (u_running.base >> (8 * 0)) & 0xFF;
akashvibhute 0:30537dec6e0b 62 offset += sizeof(this->running);
akashvibhute 0:30537dec6e0b 63 *(outbuffer + offset + 0) = (this->max_time.sec >> (8 * 0)) & 0xFF;
akashvibhute 0:30537dec6e0b 64 *(outbuffer + offset + 1) = (this->max_time.sec >> (8 * 1)) & 0xFF;
akashvibhute 0:30537dec6e0b 65 *(outbuffer + offset + 2) = (this->max_time.sec >> (8 * 2)) & 0xFF;
akashvibhute 0:30537dec6e0b 66 *(outbuffer + offset + 3) = (this->max_time.sec >> (8 * 3)) & 0xFF;
akashvibhute 0:30537dec6e0b 67 offset += sizeof(this->max_time.sec);
akashvibhute 0:30537dec6e0b 68 *(outbuffer + offset + 0) = (this->max_time.nsec >> (8 * 0)) & 0xFF;
akashvibhute 0:30537dec6e0b 69 *(outbuffer + offset + 1) = (this->max_time.nsec >> (8 * 1)) & 0xFF;
akashvibhute 0:30537dec6e0b 70 *(outbuffer + offset + 2) = (this->max_time.nsec >> (8 * 2)) & 0xFF;
akashvibhute 0:30537dec6e0b 71 *(outbuffer + offset + 3) = (this->max_time.nsec >> (8 * 3)) & 0xFF;
akashvibhute 0:30537dec6e0b 72 offset += sizeof(this->max_time.nsec);
akashvibhute 0:30537dec6e0b 73 *(outbuffer + offset + 0) = (this->mean_time.sec >> (8 * 0)) & 0xFF;
akashvibhute 0:30537dec6e0b 74 *(outbuffer + offset + 1) = (this->mean_time.sec >> (8 * 1)) & 0xFF;
akashvibhute 0:30537dec6e0b 75 *(outbuffer + offset + 2) = (this->mean_time.sec >> (8 * 2)) & 0xFF;
akashvibhute 0:30537dec6e0b 76 *(outbuffer + offset + 3) = (this->mean_time.sec >> (8 * 3)) & 0xFF;
akashvibhute 0:30537dec6e0b 77 offset += sizeof(this->mean_time.sec);
akashvibhute 0:30537dec6e0b 78 *(outbuffer + offset + 0) = (this->mean_time.nsec >> (8 * 0)) & 0xFF;
akashvibhute 0:30537dec6e0b 79 *(outbuffer + offset + 1) = (this->mean_time.nsec >> (8 * 1)) & 0xFF;
akashvibhute 0:30537dec6e0b 80 *(outbuffer + offset + 2) = (this->mean_time.nsec >> (8 * 2)) & 0xFF;
akashvibhute 0:30537dec6e0b 81 *(outbuffer + offset + 3) = (this->mean_time.nsec >> (8 * 3)) & 0xFF;
akashvibhute 0:30537dec6e0b 82 offset += sizeof(this->mean_time.nsec);
akashvibhute 0:30537dec6e0b 83 *(outbuffer + offset + 0) = (this->variance_time.sec >> (8 * 0)) & 0xFF;
akashvibhute 0:30537dec6e0b 84 *(outbuffer + offset + 1) = (this->variance_time.sec >> (8 * 1)) & 0xFF;
akashvibhute 0:30537dec6e0b 85 *(outbuffer + offset + 2) = (this->variance_time.sec >> (8 * 2)) & 0xFF;
akashvibhute 0:30537dec6e0b 86 *(outbuffer + offset + 3) = (this->variance_time.sec >> (8 * 3)) & 0xFF;
akashvibhute 0:30537dec6e0b 87 offset += sizeof(this->variance_time.sec);
akashvibhute 0:30537dec6e0b 88 *(outbuffer + offset + 0) = (this->variance_time.nsec >> (8 * 0)) & 0xFF;
akashvibhute 0:30537dec6e0b 89 *(outbuffer + offset + 1) = (this->variance_time.nsec >> (8 * 1)) & 0xFF;
akashvibhute 0:30537dec6e0b 90 *(outbuffer + offset + 2) = (this->variance_time.nsec >> (8 * 2)) & 0xFF;
akashvibhute 0:30537dec6e0b 91 *(outbuffer + offset + 3) = (this->variance_time.nsec >> (8 * 3)) & 0xFF;
akashvibhute 0:30537dec6e0b 92 offset += sizeof(this->variance_time.nsec);
akashvibhute 0:30537dec6e0b 93 union {
akashvibhute 0:30537dec6e0b 94 int32_t real;
akashvibhute 0:30537dec6e0b 95 uint32_t base;
akashvibhute 0:30537dec6e0b 96 } u_num_control_loop_overruns;
akashvibhute 0:30537dec6e0b 97 u_num_control_loop_overruns.real = this->num_control_loop_overruns;
akashvibhute 0:30537dec6e0b 98 *(outbuffer + offset + 0) = (u_num_control_loop_overruns.base >> (8 * 0)) & 0xFF;
akashvibhute 0:30537dec6e0b 99 *(outbuffer + offset + 1) = (u_num_control_loop_overruns.base >> (8 * 1)) & 0xFF;
akashvibhute 0:30537dec6e0b 100 *(outbuffer + offset + 2) = (u_num_control_loop_overruns.base >> (8 * 2)) & 0xFF;
akashvibhute 0:30537dec6e0b 101 *(outbuffer + offset + 3) = (u_num_control_loop_overruns.base >> (8 * 3)) & 0xFF;
akashvibhute 0:30537dec6e0b 102 offset += sizeof(this->num_control_loop_overruns);
akashvibhute 0:30537dec6e0b 103 *(outbuffer + offset + 0) = (this->time_last_control_loop_overrun.sec >> (8 * 0)) & 0xFF;
akashvibhute 0:30537dec6e0b 104 *(outbuffer + offset + 1) = (this->time_last_control_loop_overrun.sec >> (8 * 1)) & 0xFF;
akashvibhute 0:30537dec6e0b 105 *(outbuffer + offset + 2) = (this->time_last_control_loop_overrun.sec >> (8 * 2)) & 0xFF;
akashvibhute 0:30537dec6e0b 106 *(outbuffer + offset + 3) = (this->time_last_control_loop_overrun.sec >> (8 * 3)) & 0xFF;
akashvibhute 0:30537dec6e0b 107 offset += sizeof(this->time_last_control_loop_overrun.sec);
akashvibhute 0:30537dec6e0b 108 *(outbuffer + offset + 0) = (this->time_last_control_loop_overrun.nsec >> (8 * 0)) & 0xFF;
akashvibhute 0:30537dec6e0b 109 *(outbuffer + offset + 1) = (this->time_last_control_loop_overrun.nsec >> (8 * 1)) & 0xFF;
akashvibhute 0:30537dec6e0b 110 *(outbuffer + offset + 2) = (this->time_last_control_loop_overrun.nsec >> (8 * 2)) & 0xFF;
akashvibhute 0:30537dec6e0b 111 *(outbuffer + offset + 3) = (this->time_last_control_loop_overrun.nsec >> (8 * 3)) & 0xFF;
akashvibhute 0:30537dec6e0b 112 offset += sizeof(this->time_last_control_loop_overrun.nsec);
akashvibhute 0:30537dec6e0b 113 return offset;
akashvibhute 0:30537dec6e0b 114 }
akashvibhute 0:30537dec6e0b 115
akashvibhute 0:30537dec6e0b 116 virtual int deserialize(unsigned char *inbuffer)
akashvibhute 0:30537dec6e0b 117 {
akashvibhute 0:30537dec6e0b 118 int offset = 0;
akashvibhute 0:30537dec6e0b 119 uint32_t length_name;
akashvibhute 0:30537dec6e0b 120 memcpy(&length_name, (inbuffer + offset), sizeof(uint32_t));
akashvibhute 0:30537dec6e0b 121 offset += 4;
akashvibhute 0:30537dec6e0b 122 for(unsigned int k= offset; k< offset+length_name; ++k){
akashvibhute 0:30537dec6e0b 123 inbuffer[k-1]=inbuffer[k];
akashvibhute 0:30537dec6e0b 124 }
akashvibhute 0:30537dec6e0b 125 inbuffer[offset+length_name-1]=0;
akashvibhute 0:30537dec6e0b 126 this->name = (char *)(inbuffer + offset-1);
akashvibhute 0:30537dec6e0b 127 offset += length_name;
akashvibhute 0:30537dec6e0b 128 this->timestamp.sec = ((uint32_t) (*(inbuffer + offset)));
akashvibhute 0:30537dec6e0b 129 this->timestamp.sec |= ((uint32_t) (*(inbuffer + offset + 1))) << (8 * 1);
akashvibhute 0:30537dec6e0b 130 this->timestamp.sec |= ((uint32_t) (*(inbuffer + offset + 2))) << (8 * 2);
akashvibhute 0:30537dec6e0b 131 this->timestamp.sec |= ((uint32_t) (*(inbuffer + offset + 3))) << (8 * 3);
akashvibhute 0:30537dec6e0b 132 offset += sizeof(this->timestamp.sec);
akashvibhute 0:30537dec6e0b 133 this->timestamp.nsec = ((uint32_t) (*(inbuffer + offset)));
akashvibhute 0:30537dec6e0b 134 this->timestamp.nsec |= ((uint32_t) (*(inbuffer + offset + 1))) << (8 * 1);
akashvibhute 0:30537dec6e0b 135 this->timestamp.nsec |= ((uint32_t) (*(inbuffer + offset + 2))) << (8 * 2);
akashvibhute 0:30537dec6e0b 136 this->timestamp.nsec |= ((uint32_t) (*(inbuffer + offset + 3))) << (8 * 3);
akashvibhute 0:30537dec6e0b 137 offset += sizeof(this->timestamp.nsec);
akashvibhute 0:30537dec6e0b 138 union {
akashvibhute 0:30537dec6e0b 139 bool real;
akashvibhute 0:30537dec6e0b 140 uint8_t base;
akashvibhute 0:30537dec6e0b 141 } u_running;
akashvibhute 0:30537dec6e0b 142 u_running.base = 0;
akashvibhute 0:30537dec6e0b 143 u_running.base |= ((uint8_t) (*(inbuffer + offset + 0))) << (8 * 0);
akashvibhute 0:30537dec6e0b 144 this->running = u_running.real;
akashvibhute 0:30537dec6e0b 145 offset += sizeof(this->running);
akashvibhute 0:30537dec6e0b 146 this->max_time.sec = ((uint32_t) (*(inbuffer + offset)));
akashvibhute 0:30537dec6e0b 147 this->max_time.sec |= ((uint32_t) (*(inbuffer + offset + 1))) << (8 * 1);
akashvibhute 0:30537dec6e0b 148 this->max_time.sec |= ((uint32_t) (*(inbuffer + offset + 2))) << (8 * 2);
akashvibhute 0:30537dec6e0b 149 this->max_time.sec |= ((uint32_t) (*(inbuffer + offset + 3))) << (8 * 3);
akashvibhute 0:30537dec6e0b 150 offset += sizeof(this->max_time.sec);
akashvibhute 0:30537dec6e0b 151 this->max_time.nsec = ((uint32_t) (*(inbuffer + offset)));
akashvibhute 0:30537dec6e0b 152 this->max_time.nsec |= ((uint32_t) (*(inbuffer + offset + 1))) << (8 * 1);
akashvibhute 0:30537dec6e0b 153 this->max_time.nsec |= ((uint32_t) (*(inbuffer + offset + 2))) << (8 * 2);
akashvibhute 0:30537dec6e0b 154 this->max_time.nsec |= ((uint32_t) (*(inbuffer + offset + 3))) << (8 * 3);
akashvibhute 0:30537dec6e0b 155 offset += sizeof(this->max_time.nsec);
akashvibhute 0:30537dec6e0b 156 this->mean_time.sec = ((uint32_t) (*(inbuffer + offset)));
akashvibhute 0:30537dec6e0b 157 this->mean_time.sec |= ((uint32_t) (*(inbuffer + offset + 1))) << (8 * 1);
akashvibhute 0:30537dec6e0b 158 this->mean_time.sec |= ((uint32_t) (*(inbuffer + offset + 2))) << (8 * 2);
akashvibhute 0:30537dec6e0b 159 this->mean_time.sec |= ((uint32_t) (*(inbuffer + offset + 3))) << (8 * 3);
akashvibhute 0:30537dec6e0b 160 offset += sizeof(this->mean_time.sec);
akashvibhute 0:30537dec6e0b 161 this->mean_time.nsec = ((uint32_t) (*(inbuffer + offset)));
akashvibhute 0:30537dec6e0b 162 this->mean_time.nsec |= ((uint32_t) (*(inbuffer + offset + 1))) << (8 * 1);
akashvibhute 0:30537dec6e0b 163 this->mean_time.nsec |= ((uint32_t) (*(inbuffer + offset + 2))) << (8 * 2);
akashvibhute 0:30537dec6e0b 164 this->mean_time.nsec |= ((uint32_t) (*(inbuffer + offset + 3))) << (8 * 3);
akashvibhute 0:30537dec6e0b 165 offset += sizeof(this->mean_time.nsec);
akashvibhute 0:30537dec6e0b 166 this->variance_time.sec = ((uint32_t) (*(inbuffer + offset)));
akashvibhute 0:30537dec6e0b 167 this->variance_time.sec |= ((uint32_t) (*(inbuffer + offset + 1))) << (8 * 1);
akashvibhute 0:30537dec6e0b 168 this->variance_time.sec |= ((uint32_t) (*(inbuffer + offset + 2))) << (8 * 2);
akashvibhute 0:30537dec6e0b 169 this->variance_time.sec |= ((uint32_t) (*(inbuffer + offset + 3))) << (8 * 3);
akashvibhute 0:30537dec6e0b 170 offset += sizeof(this->variance_time.sec);
akashvibhute 0:30537dec6e0b 171 this->variance_time.nsec = ((uint32_t) (*(inbuffer + offset)));
akashvibhute 0:30537dec6e0b 172 this->variance_time.nsec |= ((uint32_t) (*(inbuffer + offset + 1))) << (8 * 1);
akashvibhute 0:30537dec6e0b 173 this->variance_time.nsec |= ((uint32_t) (*(inbuffer + offset + 2))) << (8 * 2);
akashvibhute 0:30537dec6e0b 174 this->variance_time.nsec |= ((uint32_t) (*(inbuffer + offset + 3))) << (8 * 3);
akashvibhute 0:30537dec6e0b 175 offset += sizeof(this->variance_time.nsec);
akashvibhute 0:30537dec6e0b 176 union {
akashvibhute 0:30537dec6e0b 177 int32_t real;
akashvibhute 0:30537dec6e0b 178 uint32_t base;
akashvibhute 0:30537dec6e0b 179 } u_num_control_loop_overruns;
akashvibhute 0:30537dec6e0b 180 u_num_control_loop_overruns.base = 0;
akashvibhute 0:30537dec6e0b 181 u_num_control_loop_overruns.base |= ((uint32_t) (*(inbuffer + offset + 0))) << (8 * 0);
akashvibhute 0:30537dec6e0b 182 u_num_control_loop_overruns.base |= ((uint32_t) (*(inbuffer + offset + 1))) << (8 * 1);
akashvibhute 0:30537dec6e0b 183 u_num_control_loop_overruns.base |= ((uint32_t) (*(inbuffer + offset + 2))) << (8 * 2);
akashvibhute 0:30537dec6e0b 184 u_num_control_loop_overruns.base |= ((uint32_t) (*(inbuffer + offset + 3))) << (8 * 3);
akashvibhute 0:30537dec6e0b 185 this->num_control_loop_overruns = u_num_control_loop_overruns.real;
akashvibhute 0:30537dec6e0b 186 offset += sizeof(this->num_control_loop_overruns);
akashvibhute 0:30537dec6e0b 187 this->time_last_control_loop_overrun.sec = ((uint32_t) (*(inbuffer + offset)));
akashvibhute 0:30537dec6e0b 188 this->time_last_control_loop_overrun.sec |= ((uint32_t) (*(inbuffer + offset + 1))) << (8 * 1);
akashvibhute 0:30537dec6e0b 189 this->time_last_control_loop_overrun.sec |= ((uint32_t) (*(inbuffer + offset + 2))) << (8 * 2);
akashvibhute 0:30537dec6e0b 190 this->time_last_control_loop_overrun.sec |= ((uint32_t) (*(inbuffer + offset + 3))) << (8 * 3);
akashvibhute 0:30537dec6e0b 191 offset += sizeof(this->time_last_control_loop_overrun.sec);
akashvibhute 0:30537dec6e0b 192 this->time_last_control_loop_overrun.nsec = ((uint32_t) (*(inbuffer + offset)));
akashvibhute 0:30537dec6e0b 193 this->time_last_control_loop_overrun.nsec |= ((uint32_t) (*(inbuffer + offset + 1))) << (8 * 1);
akashvibhute 0:30537dec6e0b 194 this->time_last_control_loop_overrun.nsec |= ((uint32_t) (*(inbuffer + offset + 2))) << (8 * 2);
akashvibhute 0:30537dec6e0b 195 this->time_last_control_loop_overrun.nsec |= ((uint32_t) (*(inbuffer + offset + 3))) << (8 * 3);
akashvibhute 0:30537dec6e0b 196 offset += sizeof(this->time_last_control_loop_overrun.nsec);
akashvibhute 0:30537dec6e0b 197 return offset;
akashvibhute 0:30537dec6e0b 198 }
akashvibhute 0:30537dec6e0b 199
akashvibhute 0:30537dec6e0b 200 const char * getType(){ return "pr2_mechanism_msgs/ControllerStatistics"; };
akashvibhute 0:30537dec6e0b 201 const char * getMD5(){ return "6d15d137eea402018e3c7c8dbecd4b95"; };
akashvibhute 0:30537dec6e0b 202
akashvibhute 0:30537dec6e0b 203 };
akashvibhute 0:30537dec6e0b 204
akashvibhute 0:30537dec6e0b 205 }
akashvibhute 0:30537dec6e0b 206 #endif