Working towards recieving twists

Dependencies:   BufferedSerial

Fork of ros_lib_kinetic by Gary Servin

Embed: (wiki syntax)

« Back to documentation index

Show/hide line numbers PointHeadGoal.h Source File

PointHeadGoal.h

00001 #ifndef _ROS_control_msgs_PointHeadGoal_h
00002 #define _ROS_control_msgs_PointHeadGoal_h
00003 
00004 #include <stdint.h>
00005 #include <string.h>
00006 #include <stdlib.h>
00007 #include "ros/msg.h"
00008 #include "geometry_msgs/PointStamped.h"
00009 #include "geometry_msgs/Vector3.h"
00010 #include "ros/duration.h"
00011 
00012 namespace control_msgs
00013 {
00014 
00015   class PointHeadGoal : public ros::Msg
00016   {
00017     public:
00018       typedef geometry_msgs::PointStamped _target_type;
00019       _target_type target;
00020       typedef geometry_msgs::Vector3 _pointing_axis_type;
00021       _pointing_axis_type pointing_axis;
00022       typedef const char* _pointing_frame_type;
00023       _pointing_frame_type pointing_frame;
00024       typedef ros::Duration _min_duration_type;
00025       _min_duration_type min_duration;
00026       typedef double _max_velocity_type;
00027       _max_velocity_type max_velocity;
00028 
00029     PointHeadGoal():
00030       target(),
00031       pointing_axis(),
00032       pointing_frame(""),
00033       min_duration(),
00034       max_velocity(0)
00035     {
00036     }
00037 
00038     virtual int serialize(unsigned char *outbuffer) const
00039     {
00040       int offset = 0;
00041       offset += this->target.serialize(outbuffer + offset);
00042       offset += this->pointing_axis.serialize(outbuffer + offset);
00043       uint32_t length_pointing_frame = strlen(this->pointing_frame);
00044       varToArr(outbuffer + offset, length_pointing_frame);
00045       offset += 4;
00046       memcpy(outbuffer + offset, this->pointing_frame, length_pointing_frame);
00047       offset += length_pointing_frame;
00048       *(outbuffer + offset + 0) = (this->min_duration.sec >> (8 * 0)) & 0xFF;
00049       *(outbuffer + offset + 1) = (this->min_duration.sec >> (8 * 1)) & 0xFF;
00050       *(outbuffer + offset + 2) = (this->min_duration.sec >> (8 * 2)) & 0xFF;
00051       *(outbuffer + offset + 3) = (this->min_duration.sec >> (8 * 3)) & 0xFF;
00052       offset += sizeof(this->min_duration.sec);
00053       *(outbuffer + offset + 0) = (this->min_duration.nsec >> (8 * 0)) & 0xFF;
00054       *(outbuffer + offset + 1) = (this->min_duration.nsec >> (8 * 1)) & 0xFF;
00055       *(outbuffer + offset + 2) = (this->min_duration.nsec >> (8 * 2)) & 0xFF;
00056       *(outbuffer + offset + 3) = (this->min_duration.nsec >> (8 * 3)) & 0xFF;
00057       offset += sizeof(this->min_duration.nsec);
00058       union {
00059         double real;
00060         uint64_t base;
00061       } u_max_velocity;
00062       u_max_velocity.real = this->max_velocity;
00063       *(outbuffer + offset + 0) = (u_max_velocity.base >> (8 * 0)) & 0xFF;
00064       *(outbuffer + offset + 1) = (u_max_velocity.base >> (8 * 1)) & 0xFF;
00065       *(outbuffer + offset + 2) = (u_max_velocity.base >> (8 * 2)) & 0xFF;
00066       *(outbuffer + offset + 3) = (u_max_velocity.base >> (8 * 3)) & 0xFF;
00067       *(outbuffer + offset + 4) = (u_max_velocity.base >> (8 * 4)) & 0xFF;
00068       *(outbuffer + offset + 5) = (u_max_velocity.base >> (8 * 5)) & 0xFF;
00069       *(outbuffer + offset + 6) = (u_max_velocity.base >> (8 * 6)) & 0xFF;
00070       *(outbuffer + offset + 7) = (u_max_velocity.base >> (8 * 7)) & 0xFF;
00071       offset += sizeof(this->max_velocity);
00072       return offset;
00073     }
00074 
00075     virtual int deserialize(unsigned char *inbuffer)
00076     {
00077       int offset = 0;
00078       offset += this->target.deserialize(inbuffer + offset);
00079       offset += this->pointing_axis.deserialize(inbuffer + offset);
00080       uint32_t length_pointing_frame;
00081       arrToVar(length_pointing_frame, (inbuffer + offset));
00082       offset += 4;
00083       for(unsigned int k= offset; k< offset+length_pointing_frame; ++k){
00084           inbuffer[k-1]=inbuffer[k];
00085       }
00086       inbuffer[offset+length_pointing_frame-1]=0;
00087       this->pointing_frame = (char *)(inbuffer + offset-1);
00088       offset += length_pointing_frame;
00089       this->min_duration.sec =  ((uint32_t) (*(inbuffer + offset)));
00090       this->min_duration.sec |= ((uint32_t) (*(inbuffer + offset + 1))) << (8 * 1);
00091       this->min_duration.sec |= ((uint32_t) (*(inbuffer + offset + 2))) << (8 * 2);
00092       this->min_duration.sec |= ((uint32_t) (*(inbuffer + offset + 3))) << (8 * 3);
00093       offset += sizeof(this->min_duration.sec);
00094       this->min_duration.nsec =  ((uint32_t) (*(inbuffer + offset)));
00095       this->min_duration.nsec |= ((uint32_t) (*(inbuffer + offset + 1))) << (8 * 1);
00096       this->min_duration.nsec |= ((uint32_t) (*(inbuffer + offset + 2))) << (8 * 2);
00097       this->min_duration.nsec |= ((uint32_t) (*(inbuffer + offset + 3))) << (8 * 3);
00098       offset += sizeof(this->min_duration.nsec);
00099       union {
00100         double real;
00101         uint64_t base;
00102       } u_max_velocity;
00103       u_max_velocity.base = 0;
00104       u_max_velocity.base |= ((uint64_t) (*(inbuffer + offset + 0))) << (8 * 0);
00105       u_max_velocity.base |= ((uint64_t) (*(inbuffer + offset + 1))) << (8 * 1);
00106       u_max_velocity.base |= ((uint64_t) (*(inbuffer + offset + 2))) << (8 * 2);
00107       u_max_velocity.base |= ((uint64_t) (*(inbuffer + offset + 3))) << (8 * 3);
00108       u_max_velocity.base |= ((uint64_t) (*(inbuffer + offset + 4))) << (8 * 4);
00109       u_max_velocity.base |= ((uint64_t) (*(inbuffer + offset + 5))) << (8 * 5);
00110       u_max_velocity.base |= ((uint64_t) (*(inbuffer + offset + 6))) << (8 * 6);
00111       u_max_velocity.base |= ((uint64_t) (*(inbuffer + offset + 7))) << (8 * 7);
00112       this->max_velocity = u_max_velocity.real;
00113       offset += sizeof(this->max_velocity);
00114      return offset;
00115     }
00116 
00117     const char * getType(){ return "control_msgs/PointHeadGoal"; };
00118     const char * getMD5(){ return "8b92b1cd5e06c8a94c917dc3209a4c1d"; };
00119 
00120   };
00121 
00122 }
00123 #endif