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_JointStatistics_h
akashvibhute 0:30537dec6e0b 2 #define _ROS_pr2_mechanism_msgs_JointStatistics_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
akashvibhute 0:30537dec6e0b 10 namespace pr2_mechanism_msgs
akashvibhute 0:30537dec6e0b 11 {
akashvibhute 0:30537dec6e0b 12
akashvibhute 0:30537dec6e0b 13 class JointStatistics : public ros::Msg
akashvibhute 0:30537dec6e0b 14 {
akashvibhute 0:30537dec6e0b 15 public:
akashvibhute 0:30537dec6e0b 16 const char* name;
akashvibhute 0:30537dec6e0b 17 ros::Time timestamp;
akashvibhute 0:30537dec6e0b 18 float position;
akashvibhute 0:30537dec6e0b 19 float velocity;
akashvibhute 0:30537dec6e0b 20 float measured_effort;
akashvibhute 0:30537dec6e0b 21 float commanded_effort;
akashvibhute 0:30537dec6e0b 22 bool is_calibrated;
akashvibhute 0:30537dec6e0b 23 bool violated_limits;
akashvibhute 0:30537dec6e0b 24 float odometer;
akashvibhute 0:30537dec6e0b 25 float min_position;
akashvibhute 0:30537dec6e0b 26 float max_position;
akashvibhute 0:30537dec6e0b 27 float max_abs_velocity;
akashvibhute 0:30537dec6e0b 28 float max_abs_effort;
akashvibhute 0:30537dec6e0b 29
akashvibhute 0:30537dec6e0b 30 JointStatistics():
akashvibhute 0:30537dec6e0b 31 name(""),
akashvibhute 0:30537dec6e0b 32 timestamp(),
akashvibhute 0:30537dec6e0b 33 position(0),
akashvibhute 0:30537dec6e0b 34 velocity(0),
akashvibhute 0:30537dec6e0b 35 measured_effort(0),
akashvibhute 0:30537dec6e0b 36 commanded_effort(0),
akashvibhute 0:30537dec6e0b 37 is_calibrated(0),
akashvibhute 0:30537dec6e0b 38 violated_limits(0),
akashvibhute 0:30537dec6e0b 39 odometer(0),
akashvibhute 0:30537dec6e0b 40 min_position(0),
akashvibhute 0:30537dec6e0b 41 max_position(0),
akashvibhute 0:30537dec6e0b 42 max_abs_velocity(0),
akashvibhute 0:30537dec6e0b 43 max_abs_effort(0)
akashvibhute 0:30537dec6e0b 44 {
akashvibhute 0:30537dec6e0b 45 }
akashvibhute 0:30537dec6e0b 46
akashvibhute 0:30537dec6e0b 47 virtual int serialize(unsigned char *outbuffer) const
akashvibhute 0:30537dec6e0b 48 {
akashvibhute 0:30537dec6e0b 49 int offset = 0;
akashvibhute 0:30537dec6e0b 50 uint32_t length_name = strlen(this->name);
akashvibhute 0:30537dec6e0b 51 memcpy(outbuffer + offset, &length_name, sizeof(uint32_t));
akashvibhute 0:30537dec6e0b 52 offset += 4;
akashvibhute 0:30537dec6e0b 53 memcpy(outbuffer + offset, this->name, length_name);
akashvibhute 0:30537dec6e0b 54 offset += length_name;
akashvibhute 0:30537dec6e0b 55 *(outbuffer + offset + 0) = (this->timestamp.sec >> (8 * 0)) & 0xFF;
akashvibhute 0:30537dec6e0b 56 *(outbuffer + offset + 1) = (this->timestamp.sec >> (8 * 1)) & 0xFF;
akashvibhute 0:30537dec6e0b 57 *(outbuffer + offset + 2) = (this->timestamp.sec >> (8 * 2)) & 0xFF;
akashvibhute 0:30537dec6e0b 58 *(outbuffer + offset + 3) = (this->timestamp.sec >> (8 * 3)) & 0xFF;
akashvibhute 0:30537dec6e0b 59 offset += sizeof(this->timestamp.sec);
akashvibhute 0:30537dec6e0b 60 *(outbuffer + offset + 0) = (this->timestamp.nsec >> (8 * 0)) & 0xFF;
akashvibhute 0:30537dec6e0b 61 *(outbuffer + offset + 1) = (this->timestamp.nsec >> (8 * 1)) & 0xFF;
akashvibhute 0:30537dec6e0b 62 *(outbuffer + offset + 2) = (this->timestamp.nsec >> (8 * 2)) & 0xFF;
akashvibhute 0:30537dec6e0b 63 *(outbuffer + offset + 3) = (this->timestamp.nsec >> (8 * 3)) & 0xFF;
akashvibhute 0:30537dec6e0b 64 offset += sizeof(this->timestamp.nsec);
akashvibhute 0:30537dec6e0b 65 offset += serializeAvrFloat64(outbuffer + offset, this->position);
akashvibhute 0:30537dec6e0b 66 offset += serializeAvrFloat64(outbuffer + offset, this->velocity);
akashvibhute 0:30537dec6e0b 67 offset += serializeAvrFloat64(outbuffer + offset, this->measured_effort);
akashvibhute 0:30537dec6e0b 68 offset += serializeAvrFloat64(outbuffer + offset, this->commanded_effort);
akashvibhute 0:30537dec6e0b 69 union {
akashvibhute 0:30537dec6e0b 70 bool real;
akashvibhute 0:30537dec6e0b 71 uint8_t base;
akashvibhute 0:30537dec6e0b 72 } u_is_calibrated;
akashvibhute 0:30537dec6e0b 73 u_is_calibrated.real = this->is_calibrated;
akashvibhute 0:30537dec6e0b 74 *(outbuffer + offset + 0) = (u_is_calibrated.base >> (8 * 0)) & 0xFF;
akashvibhute 0:30537dec6e0b 75 offset += sizeof(this->is_calibrated);
akashvibhute 0:30537dec6e0b 76 union {
akashvibhute 0:30537dec6e0b 77 bool real;
akashvibhute 0:30537dec6e0b 78 uint8_t base;
akashvibhute 0:30537dec6e0b 79 } u_violated_limits;
akashvibhute 0:30537dec6e0b 80 u_violated_limits.real = this->violated_limits;
akashvibhute 0:30537dec6e0b 81 *(outbuffer + offset + 0) = (u_violated_limits.base >> (8 * 0)) & 0xFF;
akashvibhute 0:30537dec6e0b 82 offset += sizeof(this->violated_limits);
akashvibhute 0:30537dec6e0b 83 offset += serializeAvrFloat64(outbuffer + offset, this->odometer);
akashvibhute 0:30537dec6e0b 84 offset += serializeAvrFloat64(outbuffer + offset, this->min_position);
akashvibhute 0:30537dec6e0b 85 offset += serializeAvrFloat64(outbuffer + offset, this->max_position);
akashvibhute 0:30537dec6e0b 86 offset += serializeAvrFloat64(outbuffer + offset, this->max_abs_velocity);
akashvibhute 0:30537dec6e0b 87 offset += serializeAvrFloat64(outbuffer + offset, this->max_abs_effort);
akashvibhute 0:30537dec6e0b 88 return offset;
akashvibhute 0:30537dec6e0b 89 }
akashvibhute 0:30537dec6e0b 90
akashvibhute 0:30537dec6e0b 91 virtual int deserialize(unsigned char *inbuffer)
akashvibhute 0:30537dec6e0b 92 {
akashvibhute 0:30537dec6e0b 93 int offset = 0;
akashvibhute 0:30537dec6e0b 94 uint32_t length_name;
akashvibhute 0:30537dec6e0b 95 memcpy(&length_name, (inbuffer + offset), sizeof(uint32_t));
akashvibhute 0:30537dec6e0b 96 offset += 4;
akashvibhute 0:30537dec6e0b 97 for(unsigned int k= offset; k< offset+length_name; ++k){
akashvibhute 0:30537dec6e0b 98 inbuffer[k-1]=inbuffer[k];
akashvibhute 0:30537dec6e0b 99 }
akashvibhute 0:30537dec6e0b 100 inbuffer[offset+length_name-1]=0;
akashvibhute 0:30537dec6e0b 101 this->name = (char *)(inbuffer + offset-1);
akashvibhute 0:30537dec6e0b 102 offset += length_name;
akashvibhute 0:30537dec6e0b 103 this->timestamp.sec = ((uint32_t) (*(inbuffer + offset)));
akashvibhute 0:30537dec6e0b 104 this->timestamp.sec |= ((uint32_t) (*(inbuffer + offset + 1))) << (8 * 1);
akashvibhute 0:30537dec6e0b 105 this->timestamp.sec |= ((uint32_t) (*(inbuffer + offset + 2))) << (8 * 2);
akashvibhute 0:30537dec6e0b 106 this->timestamp.sec |= ((uint32_t) (*(inbuffer + offset + 3))) << (8 * 3);
akashvibhute 0:30537dec6e0b 107 offset += sizeof(this->timestamp.sec);
akashvibhute 0:30537dec6e0b 108 this->timestamp.nsec = ((uint32_t) (*(inbuffer + offset)));
akashvibhute 0:30537dec6e0b 109 this->timestamp.nsec |= ((uint32_t) (*(inbuffer + offset + 1))) << (8 * 1);
akashvibhute 0:30537dec6e0b 110 this->timestamp.nsec |= ((uint32_t) (*(inbuffer + offset + 2))) << (8 * 2);
akashvibhute 0:30537dec6e0b 111 this->timestamp.nsec |= ((uint32_t) (*(inbuffer + offset + 3))) << (8 * 3);
akashvibhute 0:30537dec6e0b 112 offset += sizeof(this->timestamp.nsec);
akashvibhute 0:30537dec6e0b 113 offset += deserializeAvrFloat64(inbuffer + offset, &(this->position));
akashvibhute 0:30537dec6e0b 114 offset += deserializeAvrFloat64(inbuffer + offset, &(this->velocity));
akashvibhute 0:30537dec6e0b 115 offset += deserializeAvrFloat64(inbuffer + offset, &(this->measured_effort));
akashvibhute 0:30537dec6e0b 116 offset += deserializeAvrFloat64(inbuffer + offset, &(this->commanded_effort));
akashvibhute 0:30537dec6e0b 117 union {
akashvibhute 0:30537dec6e0b 118 bool real;
akashvibhute 0:30537dec6e0b 119 uint8_t base;
akashvibhute 0:30537dec6e0b 120 } u_is_calibrated;
akashvibhute 0:30537dec6e0b 121 u_is_calibrated.base = 0;
akashvibhute 0:30537dec6e0b 122 u_is_calibrated.base |= ((uint8_t) (*(inbuffer + offset + 0))) << (8 * 0);
akashvibhute 0:30537dec6e0b 123 this->is_calibrated = u_is_calibrated.real;
akashvibhute 0:30537dec6e0b 124 offset += sizeof(this->is_calibrated);
akashvibhute 0:30537dec6e0b 125 union {
akashvibhute 0:30537dec6e0b 126 bool real;
akashvibhute 0:30537dec6e0b 127 uint8_t base;
akashvibhute 0:30537dec6e0b 128 } u_violated_limits;
akashvibhute 0:30537dec6e0b 129 u_violated_limits.base = 0;
akashvibhute 0:30537dec6e0b 130 u_violated_limits.base |= ((uint8_t) (*(inbuffer + offset + 0))) << (8 * 0);
akashvibhute 0:30537dec6e0b 131 this->violated_limits = u_violated_limits.real;
akashvibhute 0:30537dec6e0b 132 offset += sizeof(this->violated_limits);
akashvibhute 0:30537dec6e0b 133 offset += deserializeAvrFloat64(inbuffer + offset, &(this->odometer));
akashvibhute 0:30537dec6e0b 134 offset += deserializeAvrFloat64(inbuffer + offset, &(this->min_position));
akashvibhute 0:30537dec6e0b 135 offset += deserializeAvrFloat64(inbuffer + offset, &(this->max_position));
akashvibhute 0:30537dec6e0b 136 offset += deserializeAvrFloat64(inbuffer + offset, &(this->max_abs_velocity));
akashvibhute 0:30537dec6e0b 137 offset += deserializeAvrFloat64(inbuffer + offset, &(this->max_abs_effort));
akashvibhute 0:30537dec6e0b 138 return offset;
akashvibhute 0:30537dec6e0b 139 }
akashvibhute 0:30537dec6e0b 140
akashvibhute 0:30537dec6e0b 141 const char * getType(){ return "pr2_mechanism_msgs/JointStatistics"; };
akashvibhute 0:30537dec6e0b 142 const char * getMD5(){ return "90fdc8acbce5bc783d8b4aec49af6590"; };
akashvibhute 0:30537dec6e0b 143
akashvibhute 0:30537dec6e0b 144 };
akashvibhute 0:30537dec6e0b 145
akashvibhute 0:30537dec6e0b 146 }
akashvibhute 0:30537dec6e0b 147 #endif