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

JointTrajectoryPoint.h

00001 #ifndef _ROS_trajectory_msgs_JointTrajectoryPoint_h
00002 #define _ROS_trajectory_msgs_JointTrajectoryPoint_h
00003 
00004 #include <stdint.h>
00005 #include <string.h>
00006 #include <stdlib.h>
00007 #include "ros/msg.h"
00008 #include "ros/duration.h"
00009 
00010 namespace trajectory_msgs
00011 {
00012 
00013   class JointTrajectoryPoint : public ros::Msg
00014   {
00015     public:
00016       uint32_t positions_length;
00017       typedef double _positions_type;
00018       _positions_type st_positions;
00019       _positions_type * positions;
00020       uint32_t velocities_length;
00021       typedef double _velocities_type;
00022       _velocities_type st_velocities;
00023       _velocities_type * velocities;
00024       uint32_t accelerations_length;
00025       typedef double _accelerations_type;
00026       _accelerations_type st_accelerations;
00027       _accelerations_type * accelerations;
00028       uint32_t effort_length;
00029       typedef double _effort_type;
00030       _effort_type st_effort;
00031       _effort_type * effort;
00032       typedef ros::Duration _time_from_start_type;
00033       _time_from_start_type time_from_start;
00034 
00035     JointTrajectoryPoint():
00036       positions_length(0), positions(NULL),
00037       velocities_length(0), velocities(NULL),
00038       accelerations_length(0), accelerations(NULL),
00039       effort_length(0), effort(NULL),
00040       time_from_start()
00041     {
00042     }
00043 
00044     virtual int serialize(unsigned char *outbuffer) const
00045     {
00046       int offset = 0;
00047       *(outbuffer + offset + 0) = (this->positions_length >> (8 * 0)) & 0xFF;
00048       *(outbuffer + offset + 1) = (this->positions_length >> (8 * 1)) & 0xFF;
00049       *(outbuffer + offset + 2) = (this->positions_length >> (8 * 2)) & 0xFF;
00050       *(outbuffer + offset + 3) = (this->positions_length >> (8 * 3)) & 0xFF;
00051       offset += sizeof(this->positions_length);
00052       for( uint32_t i = 0; i < positions_length; i++){
00053       union {
00054         double real;
00055         uint64_t base;
00056       } u_positionsi;
00057       u_positionsi.real = this->positions[i];
00058       *(outbuffer + offset + 0) = (u_positionsi.base >> (8 * 0)) & 0xFF;
00059       *(outbuffer + offset + 1) = (u_positionsi.base >> (8 * 1)) & 0xFF;
00060       *(outbuffer + offset + 2) = (u_positionsi.base >> (8 * 2)) & 0xFF;
00061       *(outbuffer + offset + 3) = (u_positionsi.base >> (8 * 3)) & 0xFF;
00062       *(outbuffer + offset + 4) = (u_positionsi.base >> (8 * 4)) & 0xFF;
00063       *(outbuffer + offset + 5) = (u_positionsi.base >> (8 * 5)) & 0xFF;
00064       *(outbuffer + offset + 6) = (u_positionsi.base >> (8 * 6)) & 0xFF;
00065       *(outbuffer + offset + 7) = (u_positionsi.base >> (8 * 7)) & 0xFF;
00066       offset += sizeof(this->positions[i]);
00067       }
00068       *(outbuffer + offset + 0) = (this->velocities_length >> (8 * 0)) & 0xFF;
00069       *(outbuffer + offset + 1) = (this->velocities_length >> (8 * 1)) & 0xFF;
00070       *(outbuffer + offset + 2) = (this->velocities_length >> (8 * 2)) & 0xFF;
00071       *(outbuffer + offset + 3) = (this->velocities_length >> (8 * 3)) & 0xFF;
00072       offset += sizeof(this->velocities_length);
00073       for( uint32_t i = 0; i < velocities_length; i++){
00074       union {
00075         double real;
00076         uint64_t base;
00077       } u_velocitiesi;
00078       u_velocitiesi.real = this->velocities[i];
00079       *(outbuffer + offset + 0) = (u_velocitiesi.base >> (8 * 0)) & 0xFF;
00080       *(outbuffer + offset + 1) = (u_velocitiesi.base >> (8 * 1)) & 0xFF;
00081       *(outbuffer + offset + 2) = (u_velocitiesi.base >> (8 * 2)) & 0xFF;
00082       *(outbuffer + offset + 3) = (u_velocitiesi.base >> (8 * 3)) & 0xFF;
00083       *(outbuffer + offset + 4) = (u_velocitiesi.base >> (8 * 4)) & 0xFF;
00084       *(outbuffer + offset + 5) = (u_velocitiesi.base >> (8 * 5)) & 0xFF;
00085       *(outbuffer + offset + 6) = (u_velocitiesi.base >> (8 * 6)) & 0xFF;
00086       *(outbuffer + offset + 7) = (u_velocitiesi.base >> (8 * 7)) & 0xFF;
00087       offset += sizeof(this->velocities[i]);
00088       }
00089       *(outbuffer + offset + 0) = (this->accelerations_length >> (8 * 0)) & 0xFF;
00090       *(outbuffer + offset + 1) = (this->accelerations_length >> (8 * 1)) & 0xFF;
00091       *(outbuffer + offset + 2) = (this->accelerations_length >> (8 * 2)) & 0xFF;
00092       *(outbuffer + offset + 3) = (this->accelerations_length >> (8 * 3)) & 0xFF;
00093       offset += sizeof(this->accelerations_length);
00094       for( uint32_t i = 0; i < accelerations_length; i++){
00095       union {
00096         double real;
00097         uint64_t base;
00098       } u_accelerationsi;
00099       u_accelerationsi.real = this->accelerations[i];
00100       *(outbuffer + offset + 0) = (u_accelerationsi.base >> (8 * 0)) & 0xFF;
00101       *(outbuffer + offset + 1) = (u_accelerationsi.base >> (8 * 1)) & 0xFF;
00102       *(outbuffer + offset + 2) = (u_accelerationsi.base >> (8 * 2)) & 0xFF;
00103       *(outbuffer + offset + 3) = (u_accelerationsi.base >> (8 * 3)) & 0xFF;
00104       *(outbuffer + offset + 4) = (u_accelerationsi.base >> (8 * 4)) & 0xFF;
00105       *(outbuffer + offset + 5) = (u_accelerationsi.base >> (8 * 5)) & 0xFF;
00106       *(outbuffer + offset + 6) = (u_accelerationsi.base >> (8 * 6)) & 0xFF;
00107       *(outbuffer + offset + 7) = (u_accelerationsi.base >> (8 * 7)) & 0xFF;
00108       offset += sizeof(this->accelerations[i]);
00109       }
00110       *(outbuffer + offset + 0) = (this->effort_length >> (8 * 0)) & 0xFF;
00111       *(outbuffer + offset + 1) = (this->effort_length >> (8 * 1)) & 0xFF;
00112       *(outbuffer + offset + 2) = (this->effort_length >> (8 * 2)) & 0xFF;
00113       *(outbuffer + offset + 3) = (this->effort_length >> (8 * 3)) & 0xFF;
00114       offset += sizeof(this->effort_length);
00115       for( uint32_t i = 0; i < effort_length; i++){
00116       union {
00117         double real;
00118         uint64_t base;
00119       } u_efforti;
00120       u_efforti.real = this->effort[i];
00121       *(outbuffer + offset + 0) = (u_efforti.base >> (8 * 0)) & 0xFF;
00122       *(outbuffer + offset + 1) = (u_efforti.base >> (8 * 1)) & 0xFF;
00123       *(outbuffer + offset + 2) = (u_efforti.base >> (8 * 2)) & 0xFF;
00124       *(outbuffer + offset + 3) = (u_efforti.base >> (8 * 3)) & 0xFF;
00125       *(outbuffer + offset + 4) = (u_efforti.base >> (8 * 4)) & 0xFF;
00126       *(outbuffer + offset + 5) = (u_efforti.base >> (8 * 5)) & 0xFF;
00127       *(outbuffer + offset + 6) = (u_efforti.base >> (8 * 6)) & 0xFF;
00128       *(outbuffer + offset + 7) = (u_efforti.base >> (8 * 7)) & 0xFF;
00129       offset += sizeof(this->effort[i]);
00130       }
00131       *(outbuffer + offset + 0) = (this->time_from_start.sec >> (8 * 0)) & 0xFF;
00132       *(outbuffer + offset + 1) = (this->time_from_start.sec >> (8 * 1)) & 0xFF;
00133       *(outbuffer + offset + 2) = (this->time_from_start.sec >> (8 * 2)) & 0xFF;
00134       *(outbuffer + offset + 3) = (this->time_from_start.sec >> (8 * 3)) & 0xFF;
00135       offset += sizeof(this->time_from_start.sec);
00136       *(outbuffer + offset + 0) = (this->time_from_start.nsec >> (8 * 0)) & 0xFF;
00137       *(outbuffer + offset + 1) = (this->time_from_start.nsec >> (8 * 1)) & 0xFF;
00138       *(outbuffer + offset + 2) = (this->time_from_start.nsec >> (8 * 2)) & 0xFF;
00139       *(outbuffer + offset + 3) = (this->time_from_start.nsec >> (8 * 3)) & 0xFF;
00140       offset += sizeof(this->time_from_start.nsec);
00141       return offset;
00142     }
00143 
00144     virtual int deserialize(unsigned char *inbuffer)
00145     {
00146       int offset = 0;
00147       uint32_t positions_lengthT = ((uint32_t) (*(inbuffer + offset))); 
00148       positions_lengthT |= ((uint32_t) (*(inbuffer + offset + 1))) << (8 * 1); 
00149       positions_lengthT |= ((uint32_t) (*(inbuffer + offset + 2))) << (8 * 2); 
00150       positions_lengthT |= ((uint32_t) (*(inbuffer + offset + 3))) << (8 * 3); 
00151       offset += sizeof(this->positions_length);
00152       if(positions_lengthT > positions_length)
00153         this->positions = (double*)realloc(this->positions, positions_lengthT * sizeof(double));
00154       positions_length = positions_lengthT;
00155       for( uint32_t i = 0; i < positions_length; i++){
00156       union {
00157         double real;
00158         uint64_t base;
00159       } u_st_positions;
00160       u_st_positions.base = 0;
00161       u_st_positions.base |= ((uint64_t) (*(inbuffer + offset + 0))) << (8 * 0);
00162       u_st_positions.base |= ((uint64_t) (*(inbuffer + offset + 1))) << (8 * 1);
00163       u_st_positions.base |= ((uint64_t) (*(inbuffer + offset + 2))) << (8 * 2);
00164       u_st_positions.base |= ((uint64_t) (*(inbuffer + offset + 3))) << (8 * 3);
00165       u_st_positions.base |= ((uint64_t) (*(inbuffer + offset + 4))) << (8 * 4);
00166       u_st_positions.base |= ((uint64_t) (*(inbuffer + offset + 5))) << (8 * 5);
00167       u_st_positions.base |= ((uint64_t) (*(inbuffer + offset + 6))) << (8 * 6);
00168       u_st_positions.base |= ((uint64_t) (*(inbuffer + offset + 7))) << (8 * 7);
00169       this->st_positions = u_st_positions.real;
00170       offset += sizeof(this->st_positions);
00171         memcpy( &(this->positions[i]), &(this->st_positions), sizeof(double));
00172       }
00173       uint32_t velocities_lengthT = ((uint32_t) (*(inbuffer + offset))); 
00174       velocities_lengthT |= ((uint32_t) (*(inbuffer + offset + 1))) << (8 * 1); 
00175       velocities_lengthT |= ((uint32_t) (*(inbuffer + offset + 2))) << (8 * 2); 
00176       velocities_lengthT |= ((uint32_t) (*(inbuffer + offset + 3))) << (8 * 3); 
00177       offset += sizeof(this->velocities_length);
00178       if(velocities_lengthT > velocities_length)
00179         this->velocities = (double*)realloc(this->velocities, velocities_lengthT * sizeof(double));
00180       velocities_length = velocities_lengthT;
00181       for( uint32_t i = 0; i < velocities_length; i++){
00182       union {
00183         double real;
00184         uint64_t base;
00185       } u_st_velocities;
00186       u_st_velocities.base = 0;
00187       u_st_velocities.base |= ((uint64_t) (*(inbuffer + offset + 0))) << (8 * 0);
00188       u_st_velocities.base |= ((uint64_t) (*(inbuffer + offset + 1))) << (8 * 1);
00189       u_st_velocities.base |= ((uint64_t) (*(inbuffer + offset + 2))) << (8 * 2);
00190       u_st_velocities.base |= ((uint64_t) (*(inbuffer + offset + 3))) << (8 * 3);
00191       u_st_velocities.base |= ((uint64_t) (*(inbuffer + offset + 4))) << (8 * 4);
00192       u_st_velocities.base |= ((uint64_t) (*(inbuffer + offset + 5))) << (8 * 5);
00193       u_st_velocities.base |= ((uint64_t) (*(inbuffer + offset + 6))) << (8 * 6);
00194       u_st_velocities.base |= ((uint64_t) (*(inbuffer + offset + 7))) << (8 * 7);
00195       this->st_velocities = u_st_velocities.real;
00196       offset += sizeof(this->st_velocities);
00197         memcpy( &(this->velocities[i]), &(this->st_velocities), sizeof(double));
00198       }
00199       uint32_t accelerations_lengthT = ((uint32_t) (*(inbuffer + offset))); 
00200       accelerations_lengthT |= ((uint32_t) (*(inbuffer + offset + 1))) << (8 * 1); 
00201       accelerations_lengthT |= ((uint32_t) (*(inbuffer + offset + 2))) << (8 * 2); 
00202       accelerations_lengthT |= ((uint32_t) (*(inbuffer + offset + 3))) << (8 * 3); 
00203       offset += sizeof(this->accelerations_length);
00204       if(accelerations_lengthT > accelerations_length)
00205         this->accelerations = (double*)realloc(this->accelerations, accelerations_lengthT * sizeof(double));
00206       accelerations_length = accelerations_lengthT;
00207       for( uint32_t i = 0; i < accelerations_length; i++){
00208       union {
00209         double real;
00210         uint64_t base;
00211       } u_st_accelerations;
00212       u_st_accelerations.base = 0;
00213       u_st_accelerations.base |= ((uint64_t) (*(inbuffer + offset + 0))) << (8 * 0);
00214       u_st_accelerations.base |= ((uint64_t) (*(inbuffer + offset + 1))) << (8 * 1);
00215       u_st_accelerations.base |= ((uint64_t) (*(inbuffer + offset + 2))) << (8 * 2);
00216       u_st_accelerations.base |= ((uint64_t) (*(inbuffer + offset + 3))) << (8 * 3);
00217       u_st_accelerations.base |= ((uint64_t) (*(inbuffer + offset + 4))) << (8 * 4);
00218       u_st_accelerations.base |= ((uint64_t) (*(inbuffer + offset + 5))) << (8 * 5);
00219       u_st_accelerations.base |= ((uint64_t) (*(inbuffer + offset + 6))) << (8 * 6);
00220       u_st_accelerations.base |= ((uint64_t) (*(inbuffer + offset + 7))) << (8 * 7);
00221       this->st_accelerations = u_st_accelerations.real;
00222       offset += sizeof(this->st_accelerations);
00223         memcpy( &(this->accelerations[i]), &(this->st_accelerations), sizeof(double));
00224       }
00225       uint32_t effort_lengthT = ((uint32_t) (*(inbuffer + offset))); 
00226       effort_lengthT |= ((uint32_t) (*(inbuffer + offset + 1))) << (8 * 1); 
00227       effort_lengthT |= ((uint32_t) (*(inbuffer + offset + 2))) << (8 * 2); 
00228       effort_lengthT |= ((uint32_t) (*(inbuffer + offset + 3))) << (8 * 3); 
00229       offset += sizeof(this->effort_length);
00230       if(effort_lengthT > effort_length)
00231         this->effort = (double*)realloc(this->effort, effort_lengthT * sizeof(double));
00232       effort_length = effort_lengthT;
00233       for( uint32_t i = 0; i < effort_length; i++){
00234       union {
00235         double real;
00236         uint64_t base;
00237       } u_st_effort;
00238       u_st_effort.base = 0;
00239       u_st_effort.base |= ((uint64_t) (*(inbuffer + offset + 0))) << (8 * 0);
00240       u_st_effort.base |= ((uint64_t) (*(inbuffer + offset + 1))) << (8 * 1);
00241       u_st_effort.base |= ((uint64_t) (*(inbuffer + offset + 2))) << (8 * 2);
00242       u_st_effort.base |= ((uint64_t) (*(inbuffer + offset + 3))) << (8 * 3);
00243       u_st_effort.base |= ((uint64_t) (*(inbuffer + offset + 4))) << (8 * 4);
00244       u_st_effort.base |= ((uint64_t) (*(inbuffer + offset + 5))) << (8 * 5);
00245       u_st_effort.base |= ((uint64_t) (*(inbuffer + offset + 6))) << (8 * 6);
00246       u_st_effort.base |= ((uint64_t) (*(inbuffer + offset + 7))) << (8 * 7);
00247       this->st_effort = u_st_effort.real;
00248       offset += sizeof(this->st_effort);
00249         memcpy( &(this->effort[i]), &(this->st_effort), sizeof(double));
00250       }
00251       this->time_from_start.sec =  ((uint32_t) (*(inbuffer + offset)));
00252       this->time_from_start.sec |= ((uint32_t) (*(inbuffer + offset + 1))) << (8 * 1);
00253       this->time_from_start.sec |= ((uint32_t) (*(inbuffer + offset + 2))) << (8 * 2);
00254       this->time_from_start.sec |= ((uint32_t) (*(inbuffer + offset + 3))) << (8 * 3);
00255       offset += sizeof(this->time_from_start.sec);
00256       this->time_from_start.nsec =  ((uint32_t) (*(inbuffer + offset)));
00257       this->time_from_start.nsec |= ((uint32_t) (*(inbuffer + offset + 1))) << (8 * 1);
00258       this->time_from_start.nsec |= ((uint32_t) (*(inbuffer + offset + 2))) << (8 * 2);
00259       this->time_from_start.nsec |= ((uint32_t) (*(inbuffer + offset + 3))) << (8 * 3);
00260       offset += sizeof(this->time_from_start.nsec);
00261      return offset;
00262     }
00263 
00264     const char * getType(){ return "trajectory_msgs/JointTrajectoryPoint"; };
00265     const char * getMD5(){ return "f3cd1e1c4d320c79d6985c904ae5dcd3"; };
00266 
00267   };
00268 
00269 }
00270 #endif