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 ApplyBodyWrench.h Source File

ApplyBodyWrench.h

00001 #ifndef _ROS_SERVICE_ApplyBodyWrench_h
00002 #define _ROS_SERVICE_ApplyBodyWrench_h
00003 #include <stdint.h>
00004 #include <string.h>
00005 #include <stdlib.h>
00006 #include "ros/msg.h"
00007 #include "ros/duration.h"
00008 #include "geometry_msgs/Wrench.h"
00009 #include "ros/time.h"
00010 #include "geometry_msgs/Point.h"
00011 
00012 namespace gazebo_msgs
00013 {
00014 
00015 static const char APPLYBODYWRENCH[] = "gazebo_msgs/ApplyBodyWrench";
00016 
00017   class ApplyBodyWrenchRequest : public ros::Msg
00018   {
00019     public:
00020       const char* body_name;
00021       const char* reference_frame;
00022       geometry_msgs::Point reference_point;
00023       geometry_msgs::Wrench wrench;
00024       ros::Time start_time;
00025       ros::Duration duration;
00026 
00027     ApplyBodyWrenchRequest():
00028       body_name(""),
00029       reference_frame(""),
00030       reference_point(),
00031       wrench(),
00032       start_time(),
00033       duration()
00034     {
00035     }
00036 
00037     virtual int serialize(unsigned char *outbuffer) const
00038     {
00039       int offset = 0;
00040       uint32_t length_body_name = strlen(this->body_name);
00041       memcpy(outbuffer + offset, &length_body_name, sizeof(uint32_t));
00042       offset += 4;
00043       memcpy(outbuffer + offset, this->body_name, length_body_name);
00044       offset += length_body_name;
00045       uint32_t length_reference_frame = strlen(this->reference_frame);
00046       memcpy(outbuffer + offset, &length_reference_frame, sizeof(uint32_t));
00047       offset += 4;
00048       memcpy(outbuffer + offset, this->reference_frame, length_reference_frame);
00049       offset += length_reference_frame;
00050       offset += this->reference_point.serialize(outbuffer + offset);
00051       offset += this->wrench.serialize(outbuffer + offset);
00052       *(outbuffer + offset + 0) = (this->start_time.sec >> (8 * 0)) & 0xFF;
00053       *(outbuffer + offset + 1) = (this->start_time.sec >> (8 * 1)) & 0xFF;
00054       *(outbuffer + offset + 2) = (this->start_time.sec >> (8 * 2)) & 0xFF;
00055       *(outbuffer + offset + 3) = (this->start_time.sec >> (8 * 3)) & 0xFF;
00056       offset += sizeof(this->start_time.sec);
00057       *(outbuffer + offset + 0) = (this->start_time.nsec >> (8 * 0)) & 0xFF;
00058       *(outbuffer + offset + 1) = (this->start_time.nsec >> (8 * 1)) & 0xFF;
00059       *(outbuffer + offset + 2) = (this->start_time.nsec >> (8 * 2)) & 0xFF;
00060       *(outbuffer + offset + 3) = (this->start_time.nsec >> (8 * 3)) & 0xFF;
00061       offset += sizeof(this->start_time.nsec);
00062       *(outbuffer + offset + 0) = (this->duration.sec >> (8 * 0)) & 0xFF;
00063       *(outbuffer + offset + 1) = (this->duration.sec >> (8 * 1)) & 0xFF;
00064       *(outbuffer + offset + 2) = (this->duration.sec >> (8 * 2)) & 0xFF;
00065       *(outbuffer + offset + 3) = (this->duration.sec >> (8 * 3)) & 0xFF;
00066       offset += sizeof(this->duration.sec);
00067       *(outbuffer + offset + 0) = (this->duration.nsec >> (8 * 0)) & 0xFF;
00068       *(outbuffer + offset + 1) = (this->duration.nsec >> (8 * 1)) & 0xFF;
00069       *(outbuffer + offset + 2) = (this->duration.nsec >> (8 * 2)) & 0xFF;
00070       *(outbuffer + offset + 3) = (this->duration.nsec >> (8 * 3)) & 0xFF;
00071       offset += sizeof(this->duration.nsec);
00072       return offset;
00073     }
00074 
00075     virtual int deserialize(unsigned char *inbuffer)
00076     {
00077       int offset = 0;
00078       uint32_t length_body_name;
00079       memcpy(&length_body_name, (inbuffer + offset), sizeof(uint32_t));
00080       offset += 4;
00081       for(unsigned int k= offset; k< offset+length_body_name; ++k){
00082           inbuffer[k-1]=inbuffer[k];
00083       }
00084       inbuffer[offset+length_body_name-1]=0;
00085       this->body_name = (char *)(inbuffer + offset-1);
00086       offset += length_body_name;
00087       uint32_t length_reference_frame;
00088       memcpy(&length_reference_frame, (inbuffer + offset), sizeof(uint32_t));
00089       offset += 4;
00090       for(unsigned int k= offset; k< offset+length_reference_frame; ++k){
00091           inbuffer[k-1]=inbuffer[k];
00092       }
00093       inbuffer[offset+length_reference_frame-1]=0;
00094       this->reference_frame = (char *)(inbuffer + offset-1);
00095       offset += length_reference_frame;
00096       offset += this->reference_point.deserialize(inbuffer + offset);
00097       offset += this->wrench.deserialize(inbuffer + offset);
00098       this->start_time.sec =  ((uint32_t) (*(inbuffer + offset)));
00099       this->start_time.sec |= ((uint32_t) (*(inbuffer + offset + 1))) << (8 * 1);
00100       this->start_time.sec |= ((uint32_t) (*(inbuffer + offset + 2))) << (8 * 2);
00101       this->start_time.sec |= ((uint32_t) (*(inbuffer + offset + 3))) << (8 * 3);
00102       offset += sizeof(this->start_time.sec);
00103       this->start_time.nsec =  ((uint32_t) (*(inbuffer + offset)));
00104       this->start_time.nsec |= ((uint32_t) (*(inbuffer + offset + 1))) << (8 * 1);
00105       this->start_time.nsec |= ((uint32_t) (*(inbuffer + offset + 2))) << (8 * 2);
00106       this->start_time.nsec |= ((uint32_t) (*(inbuffer + offset + 3))) << (8 * 3);
00107       offset += sizeof(this->start_time.nsec);
00108       this->duration.sec =  ((uint32_t) (*(inbuffer + offset)));
00109       this->duration.sec |= ((uint32_t) (*(inbuffer + offset + 1))) << (8 * 1);
00110       this->duration.sec |= ((uint32_t) (*(inbuffer + offset + 2))) << (8 * 2);
00111       this->duration.sec |= ((uint32_t) (*(inbuffer + offset + 3))) << (8 * 3);
00112       offset += sizeof(this->duration.sec);
00113       this->duration.nsec =  ((uint32_t) (*(inbuffer + offset)));
00114       this->duration.nsec |= ((uint32_t) (*(inbuffer + offset + 1))) << (8 * 1);
00115       this->duration.nsec |= ((uint32_t) (*(inbuffer + offset + 2))) << (8 * 2);
00116       this->duration.nsec |= ((uint32_t) (*(inbuffer + offset + 3))) << (8 * 3);
00117       offset += sizeof(this->duration.nsec);
00118      return offset;
00119     }
00120 
00121     const char * getType(){ return APPLYBODYWRENCH; };
00122     const char * getMD5(){ return "e37e6adf97eba5095baa77dffb71e5bd"; };
00123 
00124   };
00125 
00126   class ApplyBodyWrenchResponse : public ros::Msg
00127   {
00128     public:
00129       bool success;
00130       const char* status_message;
00131 
00132     ApplyBodyWrenchResponse():
00133       success(0),
00134       status_message("")
00135     {
00136     }
00137 
00138     virtual int serialize(unsigned char *outbuffer) const
00139     {
00140       int offset = 0;
00141       union {
00142         bool real;
00143         uint8_t base;
00144       } u_success;
00145       u_success.real = this->success;
00146       *(outbuffer + offset + 0) = (u_success.base >> (8 * 0)) & 0xFF;
00147       offset += sizeof(this->success);
00148       uint32_t length_status_message = strlen(this->status_message);
00149       memcpy(outbuffer + offset, &length_status_message, sizeof(uint32_t));
00150       offset += 4;
00151       memcpy(outbuffer + offset, this->status_message, length_status_message);
00152       offset += length_status_message;
00153       return offset;
00154     }
00155 
00156     virtual int deserialize(unsigned char *inbuffer)
00157     {
00158       int offset = 0;
00159       union {
00160         bool real;
00161         uint8_t base;
00162       } u_success;
00163       u_success.base = 0;
00164       u_success.base |= ((uint8_t) (*(inbuffer + offset + 0))) << (8 * 0);
00165       this->success = u_success.real;
00166       offset += sizeof(this->success);
00167       uint32_t length_status_message;
00168       memcpy(&length_status_message, (inbuffer + offset), sizeof(uint32_t));
00169       offset += 4;
00170       for(unsigned int k= offset; k< offset+length_status_message; ++k){
00171           inbuffer[k-1]=inbuffer[k];
00172       }
00173       inbuffer[offset+length_status_message-1]=0;
00174       this->status_message = (char *)(inbuffer + offset-1);
00175       offset += length_status_message;
00176      return offset;
00177     }
00178 
00179     const char * getType(){ return APPLYBODYWRENCH; };
00180     const char * getMD5(){ return "2ec6f3eff0161f4257b808b12bc830c2"; };
00181 
00182   };
00183 
00184   class ApplyBodyWrench {
00185     public:
00186     typedef ApplyBodyWrenchRequest Request;
00187     typedef ApplyBodyWrenchResponse Response;
00188   };
00189 
00190 }
00191 #endif