Irfan Tito Kurniawan / ros_lib
Embed: (wiki syntax)

« Back to documentation index

Show/hide line numbers Trajectory.h Source File

Trajectory.h

00001 #ifndef _ROS_mavros_msgs_Trajectory_h
00002 #define _ROS_mavros_msgs_Trajectory_h
00003 
00004 #include <stdint.h>
00005 #include <string.h>
00006 #include <stdlib.h>
00007 #include "ros/msg.h"
00008 #include "std_msgs/Header.h"
00009 #include "mavros_msgs/PositionTarget.h"
00010 
00011 namespace mavros_msgs
00012 {
00013 
00014   class Trajectory : public ros::Msg
00015   {
00016     public:
00017       typedef std_msgs::Header _header_type;
00018       _header_type header;
00019       typedef uint8_t _type_type;
00020       _type_type type;
00021       typedef mavros_msgs::PositionTarget _point_1_type;
00022       _point_1_type point_1;
00023       typedef mavros_msgs::PositionTarget _point_2_type;
00024       _point_2_type point_2;
00025       typedef mavros_msgs::PositionTarget _point_3_type;
00026       _point_3_type point_3;
00027       typedef mavros_msgs::PositionTarget _point_4_type;
00028       _point_4_type point_4;
00029       typedef mavros_msgs::PositionTarget _point_5_type;
00030       _point_5_type point_5;
00031       uint8_t point_valid[5];
00032       uint16_t command[5];
00033       float time_horizon[5];
00034       enum { MAV_TRAJECTORY_REPRESENTATION_WAYPOINTS =  0 };
00035       enum { MAV_TRAJECTORY_REPRESENTATION_BEZIER =  1 };
00036 
00037     Trajectory():
00038       header(),
00039       type(0),
00040       point_1(),
00041       point_2(),
00042       point_3(),
00043       point_4(),
00044       point_5(),
00045       point_valid(),
00046       command(),
00047       time_horizon()
00048     {
00049     }
00050 
00051     virtual int serialize(unsigned char *outbuffer) const
00052     {
00053       int offset = 0;
00054       offset += this->header.serialize(outbuffer + offset);
00055       *(outbuffer + offset + 0) = (this->type >> (8 * 0)) & 0xFF;
00056       offset += sizeof(this->type);
00057       offset += this->point_1.serialize(outbuffer + offset);
00058       offset += this->point_2.serialize(outbuffer + offset);
00059       offset += this->point_3.serialize(outbuffer + offset);
00060       offset += this->point_4.serialize(outbuffer + offset);
00061       offset += this->point_5.serialize(outbuffer + offset);
00062       for( uint32_t i = 0; i < 5; i++){
00063       *(outbuffer + offset + 0) = (this->point_valid[i] >> (8 * 0)) & 0xFF;
00064       offset += sizeof(this->point_valid[i]);
00065       }
00066       for( uint32_t i = 0; i < 5; i++){
00067       *(outbuffer + offset + 0) = (this->command[i] >> (8 * 0)) & 0xFF;
00068       *(outbuffer + offset + 1) = (this->command[i] >> (8 * 1)) & 0xFF;
00069       offset += sizeof(this->command[i]);
00070       }
00071       for( uint32_t i = 0; i < 5; i++){
00072       union {
00073         float real;
00074         uint32_t base;
00075       } u_time_horizoni;
00076       u_time_horizoni.real = this->time_horizon[i];
00077       *(outbuffer + offset + 0) = (u_time_horizoni.base >> (8 * 0)) & 0xFF;
00078       *(outbuffer + offset + 1) = (u_time_horizoni.base >> (8 * 1)) & 0xFF;
00079       *(outbuffer + offset + 2) = (u_time_horizoni.base >> (8 * 2)) & 0xFF;
00080       *(outbuffer + offset + 3) = (u_time_horizoni.base >> (8 * 3)) & 0xFF;
00081       offset += sizeof(this->time_horizon[i]);
00082       }
00083       return offset;
00084     }
00085 
00086     virtual int deserialize(unsigned char *inbuffer)
00087     {
00088       int offset = 0;
00089       offset += this->header.deserialize(inbuffer + offset);
00090       this->type =  ((uint8_t) (*(inbuffer + offset)));
00091       offset += sizeof(this->type);
00092       offset += this->point_1.deserialize(inbuffer + offset);
00093       offset += this->point_2.deserialize(inbuffer + offset);
00094       offset += this->point_3.deserialize(inbuffer + offset);
00095       offset += this->point_4.deserialize(inbuffer + offset);
00096       offset += this->point_5.deserialize(inbuffer + offset);
00097       for( uint32_t i = 0; i < 5; i++){
00098       this->point_valid[i] =  ((uint8_t) (*(inbuffer + offset)));
00099       offset += sizeof(this->point_valid[i]);
00100       }
00101       for( uint32_t i = 0; i < 5; i++){
00102       this->command[i] =  ((uint16_t) (*(inbuffer + offset)));
00103       this->command[i] |= ((uint16_t) (*(inbuffer + offset + 1))) << (8 * 1);
00104       offset += sizeof(this->command[i]);
00105       }
00106       for( uint32_t i = 0; i < 5; i++){
00107       union {
00108         float real;
00109         uint32_t base;
00110       } u_time_horizoni;
00111       u_time_horizoni.base = 0;
00112       u_time_horizoni.base |= ((uint32_t) (*(inbuffer + offset + 0))) << (8 * 0);
00113       u_time_horizoni.base |= ((uint32_t) (*(inbuffer + offset + 1))) << (8 * 1);
00114       u_time_horizoni.base |= ((uint32_t) (*(inbuffer + offset + 2))) << (8 * 2);
00115       u_time_horizoni.base |= ((uint32_t) (*(inbuffer + offset + 3))) << (8 * 3);
00116       this->time_horizon[i] = u_time_horizoni.real;
00117       offset += sizeof(this->time_horizon[i]);
00118       }
00119      return offset;
00120     }
00121 
00122     const char * getType(){ return "mavros_msgs/Trajectory"; };
00123     const char * getMD5(){ return "477b47a103394ad6be940e5705f338e8"; };
00124 
00125   };
00126 
00127 }
00128 #endif