MotorState.h
Go to the documentation of this file.
00001 #ifndef _ROS_dynamixel_msgs_MotorState_h
00002 #define _ROS_dynamixel_msgs_MotorState_h
00003 
00004 #include <stdint.h>
00005 #include <string.h>
00006 #include <stdlib.h>
00007 #include "ros/msg.h"
00008 
00009 namespace dynamixel_msgs
00010 {
00011 
00012   class MotorState : public ros::Msg
00013   {
00014     public:
00015       float timestamp;
00016       int32_t id;
00017       int32_t goal;
00018       int32_t position;
00019       int32_t error;
00020       int32_t speed;
00021       float load;
00022       float voltage;
00023       int32_t temperature;
00024       bool moving;
00025 
00026     virtual int serialize(unsigned char *outbuffer) const
00027     {
00028       int offset = 0;
00029       int32_t * val_timestamp = (int32_t *) &(this->timestamp);
00030       int32_t exp_timestamp = (((*val_timestamp)>>23)&255);
00031       if(exp_timestamp != 0)
00032         exp_timestamp += 1023-127;
00033       int32_t sig_timestamp = *val_timestamp;
00034       *(outbuffer + offset++) = 0;
00035       *(outbuffer + offset++) = 0;
00036       *(outbuffer + offset++) = 0;
00037       *(outbuffer + offset++) = (sig_timestamp<<5) & 0xff;
00038       *(outbuffer + offset++) = (sig_timestamp>>3) & 0xff;
00039       *(outbuffer + offset++) = (sig_timestamp>>11) & 0xff;
00040       *(outbuffer + offset++) = ((exp_timestamp<<4) & 0xF0) | ((sig_timestamp>>19)&0x0F);
00041       *(outbuffer + offset++) = (exp_timestamp>>4) & 0x7F;
00042       if(this->timestamp < 0) *(outbuffer + offset -1) |= 0x80;
00043       union {
00044         int32_t real;
00045         uint32_t base;
00046       } u_id;
00047       u_id.real = this->id;
00048       *(outbuffer + offset + 0) = (u_id.base >> (8 * 0)) & 0xFF;
00049       *(outbuffer + offset + 1) = (u_id.base >> (8 * 1)) & 0xFF;
00050       *(outbuffer + offset + 2) = (u_id.base >> (8 * 2)) & 0xFF;
00051       *(outbuffer + offset + 3) = (u_id.base >> (8 * 3)) & 0xFF;
00052       offset += sizeof(this->id);
00053       union {
00054         int32_t real;
00055         uint32_t base;
00056       } u_goal;
00057       u_goal.real = this->goal;
00058       *(outbuffer + offset + 0) = (u_goal.base >> (8 * 0)) & 0xFF;
00059       *(outbuffer + offset + 1) = (u_goal.base >> (8 * 1)) & 0xFF;
00060       *(outbuffer + offset + 2) = (u_goal.base >> (8 * 2)) & 0xFF;
00061       *(outbuffer + offset + 3) = (u_goal.base >> (8 * 3)) & 0xFF;
00062       offset += sizeof(this->goal);
00063       union {
00064         int32_t real;
00065         uint32_t base;
00066       } u_position;
00067       u_position.real = this->position;
00068       *(outbuffer + offset + 0) = (u_position.base >> (8 * 0)) & 0xFF;
00069       *(outbuffer + offset + 1) = (u_position.base >> (8 * 1)) & 0xFF;
00070       *(outbuffer + offset + 2) = (u_position.base >> (8 * 2)) & 0xFF;
00071       *(outbuffer + offset + 3) = (u_position.base >> (8 * 3)) & 0xFF;
00072       offset += sizeof(this->position);
00073       union {
00074         int32_t real;
00075         uint32_t base;
00076       } u_error;
00077       u_error.real = this->error;
00078       *(outbuffer + offset + 0) = (u_error.base >> (8 * 0)) & 0xFF;
00079       *(outbuffer + offset + 1) = (u_error.base >> (8 * 1)) & 0xFF;
00080       *(outbuffer + offset + 2) = (u_error.base >> (8 * 2)) & 0xFF;
00081       *(outbuffer + offset + 3) = (u_error.base >> (8 * 3)) & 0xFF;
00082       offset += sizeof(this->error);
00083       union {
00084         int32_t real;
00085         uint32_t base;
00086       } u_speed;
00087       u_speed.real = this->speed;
00088       *(outbuffer + offset + 0) = (u_speed.base >> (8 * 0)) & 0xFF;
00089       *(outbuffer + offset + 1) = (u_speed.base >> (8 * 1)) & 0xFF;
00090       *(outbuffer + offset + 2) = (u_speed.base >> (8 * 2)) & 0xFF;
00091       *(outbuffer + offset + 3) = (u_speed.base >> (8 * 3)) & 0xFF;
00092       offset += sizeof(this->speed);
00093       int32_t * val_load = (int32_t *) &(this->load);
00094       int32_t exp_load = (((*val_load)>>23)&255);
00095       if(exp_load != 0)
00096         exp_load += 1023-127;
00097       int32_t sig_load = *val_load;
00098       *(outbuffer + offset++) = 0;
00099       *(outbuffer + offset++) = 0;
00100       *(outbuffer + offset++) = 0;
00101       *(outbuffer + offset++) = (sig_load<<5) & 0xff;
00102       *(outbuffer + offset++) = (sig_load>>3) & 0xff;
00103       *(outbuffer + offset++) = (sig_load>>11) & 0xff;
00104       *(outbuffer + offset++) = ((exp_load<<4) & 0xF0) | ((sig_load>>19)&0x0F);
00105       *(outbuffer + offset++) = (exp_load>>4) & 0x7F;
00106       if(this->load < 0) *(outbuffer + offset -1) |= 0x80;
00107       int32_t * val_voltage = (int32_t *) &(this->voltage);
00108       int32_t exp_voltage = (((*val_voltage)>>23)&255);
00109       if(exp_voltage != 0)
00110         exp_voltage += 1023-127;
00111       int32_t sig_voltage = *val_voltage;
00112       *(outbuffer + offset++) = 0;
00113       *(outbuffer + offset++) = 0;
00114       *(outbuffer + offset++) = 0;
00115       *(outbuffer + offset++) = (sig_voltage<<5) & 0xff;
00116       *(outbuffer + offset++) = (sig_voltage>>3) & 0xff;
00117       *(outbuffer + offset++) = (sig_voltage>>11) & 0xff;
00118       *(outbuffer + offset++) = ((exp_voltage<<4) & 0xF0) | ((sig_voltage>>19)&0x0F);
00119       *(outbuffer + offset++) = (exp_voltage>>4) & 0x7F;
00120       if(this->voltage < 0) *(outbuffer + offset -1) |= 0x80;
00121       union {
00122         int32_t real;
00123         uint32_t base;
00124       } u_temperature;
00125       u_temperature.real = this->temperature;
00126       *(outbuffer + offset + 0) = (u_temperature.base >> (8 * 0)) & 0xFF;
00127       *(outbuffer + offset + 1) = (u_temperature.base >> (8 * 1)) & 0xFF;
00128       *(outbuffer + offset + 2) = (u_temperature.base >> (8 * 2)) & 0xFF;
00129       *(outbuffer + offset + 3) = (u_temperature.base >> (8 * 3)) & 0xFF;
00130       offset += sizeof(this->temperature);
00131       union {
00132         bool real;
00133         uint8_t base;
00134       } u_moving;
00135       u_moving.real = this->moving;
00136       *(outbuffer + offset + 0) = (u_moving.base >> (8 * 0)) & 0xFF;
00137       offset += sizeof(this->moving);
00138       return offset;
00139     }
00140 
00141     virtual int deserialize(unsigned char *inbuffer)
00142     {
00143       int offset = 0;
00144       uint32_t * val_timestamp = (uint32_t*) &(this->timestamp);
00145       offset += 3;
00146       *val_timestamp = ((uint32_t)(*(inbuffer + offset++))>>5 & 0x07);
00147       *val_timestamp |= ((uint32_t)(*(inbuffer + offset++)) & 0xff)<<3;
00148       *val_timestamp |= ((uint32_t)(*(inbuffer + offset++)) & 0xff)<<11;
00149       *val_timestamp |= ((uint32_t)(*(inbuffer + offset)) & 0x0f)<<19;
00150       uint32_t exp_timestamp = ((uint32_t)(*(inbuffer + offset++))&0xf0)>>4;
00151       exp_timestamp |= ((uint32_t)(*(inbuffer + offset)) & 0x7f)<<4;
00152       if(exp_timestamp !=0)
00153         *val_timestamp |= ((exp_timestamp)-1023+127)<<23;
00154       if( ((*(inbuffer+offset++)) & 0x80) > 0) this->timestamp = -this->timestamp;
00155       union {
00156         int32_t real;
00157         uint32_t base;
00158       } u_id;
00159       u_id.base = 0;
00160       u_id.base |= ((uint32_t) (*(inbuffer + offset + 0))) << (8 * 0);
00161       u_id.base |= ((uint32_t) (*(inbuffer + offset + 1))) << (8 * 1);
00162       u_id.base |= ((uint32_t) (*(inbuffer + offset + 2))) << (8 * 2);
00163       u_id.base |= ((uint32_t) (*(inbuffer + offset + 3))) << (8 * 3);
00164       this->id = u_id.real;
00165       offset += sizeof(this->id);
00166       union {
00167         int32_t real;
00168         uint32_t base;
00169       } u_goal;
00170       u_goal.base = 0;
00171       u_goal.base |= ((uint32_t) (*(inbuffer + offset + 0))) << (8 * 0);
00172       u_goal.base |= ((uint32_t) (*(inbuffer + offset + 1))) << (8 * 1);
00173       u_goal.base |= ((uint32_t) (*(inbuffer + offset + 2))) << (8 * 2);
00174       u_goal.base |= ((uint32_t) (*(inbuffer + offset + 3))) << (8 * 3);
00175       this->goal = u_goal.real;
00176       offset += sizeof(this->goal);
00177       union {
00178         int32_t real;
00179         uint32_t base;
00180       } u_position;
00181       u_position.base = 0;
00182       u_position.base |= ((uint32_t) (*(inbuffer + offset + 0))) << (8 * 0);
00183       u_position.base |= ((uint32_t) (*(inbuffer + offset + 1))) << (8 * 1);
00184       u_position.base |= ((uint32_t) (*(inbuffer + offset + 2))) << (8 * 2);
00185       u_position.base |= ((uint32_t) (*(inbuffer + offset + 3))) << (8 * 3);
00186       this->position = u_position.real;
00187       offset += sizeof(this->position);
00188       union {
00189         int32_t real;
00190         uint32_t base;
00191       } u_error;
00192       u_error.base = 0;
00193       u_error.base |= ((uint32_t) (*(inbuffer + offset + 0))) << (8 * 0);
00194       u_error.base |= ((uint32_t) (*(inbuffer + offset + 1))) << (8 * 1);
00195       u_error.base |= ((uint32_t) (*(inbuffer + offset + 2))) << (8 * 2);
00196       u_error.base |= ((uint32_t) (*(inbuffer + offset + 3))) << (8 * 3);
00197       this->error = u_error.real;
00198       offset += sizeof(this->error);
00199       union {
00200         int32_t real;
00201         uint32_t base;
00202       } u_speed;
00203       u_speed.base = 0;
00204       u_speed.base |= ((uint32_t) (*(inbuffer + offset + 0))) << (8 * 0);
00205       u_speed.base |= ((uint32_t) (*(inbuffer + offset + 1))) << (8 * 1);
00206       u_speed.base |= ((uint32_t) (*(inbuffer + offset + 2))) << (8 * 2);
00207       u_speed.base |= ((uint32_t) (*(inbuffer + offset + 3))) << (8 * 3);
00208       this->speed = u_speed.real;
00209       offset += sizeof(this->speed);
00210       uint32_t * val_load = (uint32_t*) &(this->load);
00211       offset += 3;
00212       *val_load = ((uint32_t)(*(inbuffer + offset++))>>5 & 0x07);
00213       *val_load |= ((uint32_t)(*(inbuffer + offset++)) & 0xff)<<3;
00214       *val_load |= ((uint32_t)(*(inbuffer + offset++)) & 0xff)<<11;
00215       *val_load |= ((uint32_t)(*(inbuffer + offset)) & 0x0f)<<19;
00216       uint32_t exp_load = ((uint32_t)(*(inbuffer + offset++))&0xf0)>>4;
00217       exp_load |= ((uint32_t)(*(inbuffer + offset)) & 0x7f)<<4;
00218       if(exp_load !=0)
00219         *val_load |= ((exp_load)-1023+127)<<23;
00220       if( ((*(inbuffer+offset++)) & 0x80) > 0) this->load = -this->load;
00221       uint32_t * val_voltage = (uint32_t*) &(this->voltage);
00222       offset += 3;
00223       *val_voltage = ((uint32_t)(*(inbuffer + offset++))>>5 & 0x07);
00224       *val_voltage |= ((uint32_t)(*(inbuffer + offset++)) & 0xff)<<3;
00225       *val_voltage |= ((uint32_t)(*(inbuffer + offset++)) & 0xff)<<11;
00226       *val_voltage |= ((uint32_t)(*(inbuffer + offset)) & 0x0f)<<19;
00227       uint32_t exp_voltage = ((uint32_t)(*(inbuffer + offset++))&0xf0)>>4;
00228       exp_voltage |= ((uint32_t)(*(inbuffer + offset)) & 0x7f)<<4;
00229       if(exp_voltage !=0)
00230         *val_voltage |= ((exp_voltage)-1023+127)<<23;
00231       if( ((*(inbuffer+offset++)) & 0x80) > 0) this->voltage = -this->voltage;
00232       union {
00233         int32_t real;
00234         uint32_t base;
00235       } u_temperature;
00236       u_temperature.base = 0;
00237       u_temperature.base |= ((uint32_t) (*(inbuffer + offset + 0))) << (8 * 0);
00238       u_temperature.base |= ((uint32_t) (*(inbuffer + offset + 1))) << (8 * 1);
00239       u_temperature.base |= ((uint32_t) (*(inbuffer + offset + 2))) << (8 * 2);
00240       u_temperature.base |= ((uint32_t) (*(inbuffer + offset + 3))) << (8 * 3);
00241       this->temperature = u_temperature.real;
00242       offset += sizeof(this->temperature);
00243       union {
00244         bool real;
00245         uint8_t base;
00246       } u_moving;
00247       u_moving.base = 0;
00248       u_moving.base |= ((uint8_t) (*(inbuffer + offset + 0))) << (8 * 0);
00249       this->moving = u_moving.real;
00250       offset += sizeof(this->moving);
00251      return offset;
00252     }
00253 
00254     const char * getType(){ return "dynamixel_msgs/MotorState"; };
00255     const char * getMD5(){ return "1cefdc3ff0c7d52e475886024476b74d"; };
00256 
00257   };
00258 
00259 }
00260 #endif


ric_mc
Author(s): RoboTiCan
autogenerated on Thu Aug 27 2015 14:39:49