ros melodic library with custom message

Dependents:   Robot_team1_QEI_Douglas Robot_team1

Committer:
scarter1
Date:
Wed Oct 30 14:59:49 2019 +0000
Revision:
0:020db18a476d
melodic library;

Who changed what in which revision?

UserRevisionLine numberNew contents of line
scarter1 0:020db18a476d 1 #ifndef _ROS_gazebo_msgs_ModelState_h
scarter1 0:020db18a476d 2 #define _ROS_gazebo_msgs_ModelState_h
scarter1 0:020db18a476d 3
scarter1 0:020db18a476d 4 #include <stdint.h>
scarter1 0:020db18a476d 5 #include <string.h>
scarter1 0:020db18a476d 6 #include <stdlib.h>
scarter1 0:020db18a476d 7 #include "ros/msg.h"
scarter1 0:020db18a476d 8 #include "geometry_msgs/Pose.h"
scarter1 0:020db18a476d 9 #include "geometry_msgs/Twist.h"
scarter1 0:020db18a476d 10
scarter1 0:020db18a476d 11 namespace gazebo_msgs
scarter1 0:020db18a476d 12 {
scarter1 0:020db18a476d 13
scarter1 0:020db18a476d 14 class ModelState : public ros::Msg
scarter1 0:020db18a476d 15 {
scarter1 0:020db18a476d 16 public:
scarter1 0:020db18a476d 17 typedef const char* _model_name_type;
scarter1 0:020db18a476d 18 _model_name_type model_name;
scarter1 0:020db18a476d 19 typedef geometry_msgs::Pose _pose_type;
scarter1 0:020db18a476d 20 _pose_type pose;
scarter1 0:020db18a476d 21 typedef geometry_msgs::Twist _twist_type;
scarter1 0:020db18a476d 22 _twist_type twist;
scarter1 0:020db18a476d 23 typedef const char* _reference_frame_type;
scarter1 0:020db18a476d 24 _reference_frame_type reference_frame;
scarter1 0:020db18a476d 25
scarter1 0:020db18a476d 26 ModelState():
scarter1 0:020db18a476d 27 model_name(""),
scarter1 0:020db18a476d 28 pose(),
scarter1 0:020db18a476d 29 twist(),
scarter1 0:020db18a476d 30 reference_frame("")
scarter1 0:020db18a476d 31 {
scarter1 0:020db18a476d 32 }
scarter1 0:020db18a476d 33
scarter1 0:020db18a476d 34 virtual int serialize(unsigned char *outbuffer) const
scarter1 0:020db18a476d 35 {
scarter1 0:020db18a476d 36 int offset = 0;
scarter1 0:020db18a476d 37 uint32_t length_model_name = strlen(this->model_name);
scarter1 0:020db18a476d 38 varToArr(outbuffer + offset, length_model_name);
scarter1 0:020db18a476d 39 offset += 4;
scarter1 0:020db18a476d 40 memcpy(outbuffer + offset, this->model_name, length_model_name);
scarter1 0:020db18a476d 41 offset += length_model_name;
scarter1 0:020db18a476d 42 offset += this->pose.serialize(outbuffer + offset);
scarter1 0:020db18a476d 43 offset += this->twist.serialize(outbuffer + offset);
scarter1 0:020db18a476d 44 uint32_t length_reference_frame = strlen(this->reference_frame);
scarter1 0:020db18a476d 45 varToArr(outbuffer + offset, length_reference_frame);
scarter1 0:020db18a476d 46 offset += 4;
scarter1 0:020db18a476d 47 memcpy(outbuffer + offset, this->reference_frame, length_reference_frame);
scarter1 0:020db18a476d 48 offset += length_reference_frame;
scarter1 0:020db18a476d 49 return offset;
scarter1 0:020db18a476d 50 }
scarter1 0:020db18a476d 51
scarter1 0:020db18a476d 52 virtual int deserialize(unsigned char *inbuffer)
scarter1 0:020db18a476d 53 {
scarter1 0:020db18a476d 54 int offset = 0;
scarter1 0:020db18a476d 55 uint32_t length_model_name;
scarter1 0:020db18a476d 56 arrToVar(length_model_name, (inbuffer + offset));
scarter1 0:020db18a476d 57 offset += 4;
scarter1 0:020db18a476d 58 for(unsigned int k= offset; k< offset+length_model_name; ++k){
scarter1 0:020db18a476d 59 inbuffer[k-1]=inbuffer[k];
scarter1 0:020db18a476d 60 }
scarter1 0:020db18a476d 61 inbuffer[offset+length_model_name-1]=0;
scarter1 0:020db18a476d 62 this->model_name = (char *)(inbuffer + offset-1);
scarter1 0:020db18a476d 63 offset += length_model_name;
scarter1 0:020db18a476d 64 offset += this->pose.deserialize(inbuffer + offset);
scarter1 0:020db18a476d 65 offset += this->twist.deserialize(inbuffer + offset);
scarter1 0:020db18a476d 66 uint32_t length_reference_frame;
scarter1 0:020db18a476d 67 arrToVar(length_reference_frame, (inbuffer + offset));
scarter1 0:020db18a476d 68 offset += 4;
scarter1 0:020db18a476d 69 for(unsigned int k= offset; k< offset+length_reference_frame; ++k){
scarter1 0:020db18a476d 70 inbuffer[k-1]=inbuffer[k];
scarter1 0:020db18a476d 71 }
scarter1 0:020db18a476d 72 inbuffer[offset+length_reference_frame-1]=0;
scarter1 0:020db18a476d 73 this->reference_frame = (char *)(inbuffer + offset-1);
scarter1 0:020db18a476d 74 offset += length_reference_frame;
scarter1 0:020db18a476d 75 return offset;
scarter1 0:020db18a476d 76 }
scarter1 0:020db18a476d 77
scarter1 0:020db18a476d 78 const char * getType(){ return "gazebo_msgs/ModelState"; };
scarter1 0:020db18a476d 79 const char * getMD5(){ return "9330fd35f2fcd82d457e54bd54e10593"; };
scarter1 0:020db18a476d 80
scarter1 0:020db18a476d 81 };
scarter1 0:020db18a476d 82
scarter1 0:020db18a476d 83 }
scarter1 0:020db18a476d 84 #endif