ROS Serial library for Mbed platforms for ROS Indigo Igloo. Check http://wiki.ros.org/rosserial_mbed/ for more information

Dependencies:   BufferedSerial

Dependents:   rosserial_mbed_hello_world_publisher rtos_base_control rosserial_mbed_F64MA ROS-RTOS ... more

Embed: (wiki syntax)

« Back to documentation index

Show/hide line numbers JointTolerance.h Source File

JointTolerance.h

00001 #ifndef _ROS_control_msgs_JointTolerance_h
00002 #define _ROS_control_msgs_JointTolerance_h
00003 
00004 #include <stdint.h>
00005 #include <string.h>
00006 #include <stdlib.h>
00007 #include "ros/msg.h"
00008 
00009 namespace control_msgs
00010 {
00011 
00012   class JointTolerance : public ros::Msg
00013   {
00014     public:
00015       const char* name;
00016       double position;
00017       double velocity;
00018       double acceleration;
00019 
00020     JointTolerance():
00021       name(""),
00022       position(0),
00023       velocity(0),
00024       acceleration(0)
00025     {
00026     }
00027 
00028     virtual int serialize(unsigned char *outbuffer) const
00029     {
00030       int offset = 0;
00031       uint32_t length_name = strlen(this->name);
00032       memcpy(outbuffer + offset, &length_name, sizeof(uint32_t));
00033       offset += 4;
00034       memcpy(outbuffer + offset, this->name, length_name);
00035       offset += length_name;
00036       union {
00037         double real;
00038         uint64_t base;
00039       } u_position;
00040       u_position.real = this->position;
00041       *(outbuffer + offset + 0) = (u_position.base >> (8 * 0)) & 0xFF;
00042       *(outbuffer + offset + 1) = (u_position.base >> (8 * 1)) & 0xFF;
00043       *(outbuffer + offset + 2) = (u_position.base >> (8 * 2)) & 0xFF;
00044       *(outbuffer + offset + 3) = (u_position.base >> (8 * 3)) & 0xFF;
00045       *(outbuffer + offset + 4) = (u_position.base >> (8 * 4)) & 0xFF;
00046       *(outbuffer + offset + 5) = (u_position.base >> (8 * 5)) & 0xFF;
00047       *(outbuffer + offset + 6) = (u_position.base >> (8 * 6)) & 0xFF;
00048       *(outbuffer + offset + 7) = (u_position.base >> (8 * 7)) & 0xFF;
00049       offset += sizeof(this->position);
00050       union {
00051         double real;
00052         uint64_t base;
00053       } u_velocity;
00054       u_velocity.real = this->velocity;
00055       *(outbuffer + offset + 0) = (u_velocity.base >> (8 * 0)) & 0xFF;
00056       *(outbuffer + offset + 1) = (u_velocity.base >> (8 * 1)) & 0xFF;
00057       *(outbuffer + offset + 2) = (u_velocity.base >> (8 * 2)) & 0xFF;
00058       *(outbuffer + offset + 3) = (u_velocity.base >> (8 * 3)) & 0xFF;
00059       *(outbuffer + offset + 4) = (u_velocity.base >> (8 * 4)) & 0xFF;
00060       *(outbuffer + offset + 5) = (u_velocity.base >> (8 * 5)) & 0xFF;
00061       *(outbuffer + offset + 6) = (u_velocity.base >> (8 * 6)) & 0xFF;
00062       *(outbuffer + offset + 7) = (u_velocity.base >> (8 * 7)) & 0xFF;
00063       offset += sizeof(this->velocity);
00064       union {
00065         double real;
00066         uint64_t base;
00067       } u_acceleration;
00068       u_acceleration.real = this->acceleration;
00069       *(outbuffer + offset + 0) = (u_acceleration.base >> (8 * 0)) & 0xFF;
00070       *(outbuffer + offset + 1) = (u_acceleration.base >> (8 * 1)) & 0xFF;
00071       *(outbuffer + offset + 2) = (u_acceleration.base >> (8 * 2)) & 0xFF;
00072       *(outbuffer + offset + 3) = (u_acceleration.base >> (8 * 3)) & 0xFF;
00073       *(outbuffer + offset + 4) = (u_acceleration.base >> (8 * 4)) & 0xFF;
00074       *(outbuffer + offset + 5) = (u_acceleration.base >> (8 * 5)) & 0xFF;
00075       *(outbuffer + offset + 6) = (u_acceleration.base >> (8 * 6)) & 0xFF;
00076       *(outbuffer + offset + 7) = (u_acceleration.base >> (8 * 7)) & 0xFF;
00077       offset += sizeof(this->acceleration);
00078       return offset;
00079     }
00080 
00081     virtual int deserialize(unsigned char *inbuffer)
00082     {
00083       int offset = 0;
00084       uint32_t length_name;
00085       memcpy(&length_name, (inbuffer + offset), sizeof(uint32_t));
00086       offset += 4;
00087       for(unsigned int k= offset; k< offset+length_name; ++k){
00088           inbuffer[k-1]=inbuffer[k];
00089       }
00090       inbuffer[offset+length_name-1]=0;
00091       this->name = (char *)(inbuffer + offset-1);
00092       offset += length_name;
00093       union {
00094         double real;
00095         uint64_t base;
00096       } u_position;
00097       u_position.base = 0;
00098       u_position.base |= ((uint64_t) (*(inbuffer + offset + 0))) << (8 * 0);
00099       u_position.base |= ((uint64_t) (*(inbuffer + offset + 1))) << (8 * 1);
00100       u_position.base |= ((uint64_t) (*(inbuffer + offset + 2))) << (8 * 2);
00101       u_position.base |= ((uint64_t) (*(inbuffer + offset + 3))) << (8 * 3);
00102       u_position.base |= ((uint64_t) (*(inbuffer + offset + 4))) << (8 * 4);
00103       u_position.base |= ((uint64_t) (*(inbuffer + offset + 5))) << (8 * 5);
00104       u_position.base |= ((uint64_t) (*(inbuffer + offset + 6))) << (8 * 6);
00105       u_position.base |= ((uint64_t) (*(inbuffer + offset + 7))) << (8 * 7);
00106       this->position = u_position.real;
00107       offset += sizeof(this->position);
00108       union {
00109         double real;
00110         uint64_t base;
00111       } u_velocity;
00112       u_velocity.base = 0;
00113       u_velocity.base |= ((uint64_t) (*(inbuffer + offset + 0))) << (8 * 0);
00114       u_velocity.base |= ((uint64_t) (*(inbuffer + offset + 1))) << (8 * 1);
00115       u_velocity.base |= ((uint64_t) (*(inbuffer + offset + 2))) << (8 * 2);
00116       u_velocity.base |= ((uint64_t) (*(inbuffer + offset + 3))) << (8 * 3);
00117       u_velocity.base |= ((uint64_t) (*(inbuffer + offset + 4))) << (8 * 4);
00118       u_velocity.base |= ((uint64_t) (*(inbuffer + offset + 5))) << (8 * 5);
00119       u_velocity.base |= ((uint64_t) (*(inbuffer + offset + 6))) << (8 * 6);
00120       u_velocity.base |= ((uint64_t) (*(inbuffer + offset + 7))) << (8 * 7);
00121       this->velocity = u_velocity.real;
00122       offset += sizeof(this->velocity);
00123       union {
00124         double real;
00125         uint64_t base;
00126       } u_acceleration;
00127       u_acceleration.base = 0;
00128       u_acceleration.base |= ((uint64_t) (*(inbuffer + offset + 0))) << (8 * 0);
00129       u_acceleration.base |= ((uint64_t) (*(inbuffer + offset + 1))) << (8 * 1);
00130       u_acceleration.base |= ((uint64_t) (*(inbuffer + offset + 2))) << (8 * 2);
00131       u_acceleration.base |= ((uint64_t) (*(inbuffer + offset + 3))) << (8 * 3);
00132       u_acceleration.base |= ((uint64_t) (*(inbuffer + offset + 4))) << (8 * 4);
00133       u_acceleration.base |= ((uint64_t) (*(inbuffer + offset + 5))) << (8 * 5);
00134       u_acceleration.base |= ((uint64_t) (*(inbuffer + offset + 6))) << (8 * 6);
00135       u_acceleration.base |= ((uint64_t) (*(inbuffer + offset + 7))) << (8 * 7);
00136       this->acceleration = u_acceleration.real;
00137       offset += sizeof(this->acceleration);
00138      return offset;
00139     }
00140 
00141     const char * getType(){ return "control_msgs/JointTolerance"; };
00142     const char * getMD5(){ return "f544fe9c16cf04547e135dd6063ff5be"; };
00143 
00144   };
00145 
00146 }
00147 #endif