ros melodic library with custom message

Dependents:   Robot_team1_QEI_Douglas Robot_team1

Committer:
florine_van
Date:
Tue Dec 03 09:39:29 2019 +0000
Revision:
3:b964e3f71102
Parent:
0:020db18a476d
Clean code and remove unused lines

Who changed what in which revision?

UserRevisionLine numberNew contents of line
scarter1 0:020db18a476d 1 #ifndef _ROS_SERVICE_SetPhysicsProperties_h
scarter1 0:020db18a476d 2 #define _ROS_SERVICE_SetPhysicsProperties_h
scarter1 0:020db18a476d 3 #include <stdint.h>
scarter1 0:020db18a476d 4 #include <string.h>
scarter1 0:020db18a476d 5 #include <stdlib.h>
scarter1 0:020db18a476d 6 #include "ros/msg.h"
scarter1 0:020db18a476d 7 #include "geometry_msgs/Vector3.h"
scarter1 0:020db18a476d 8 #include "gazebo_msgs/ODEPhysics.h"
scarter1 0:020db18a476d 9
scarter1 0:020db18a476d 10 namespace gazebo_msgs
scarter1 0:020db18a476d 11 {
scarter1 0:020db18a476d 12
scarter1 0:020db18a476d 13 static const char SETPHYSICSPROPERTIES[] = "gazebo_msgs/SetPhysicsProperties";
scarter1 0:020db18a476d 14
scarter1 0:020db18a476d 15 class SetPhysicsPropertiesRequest : public ros::Msg
scarter1 0:020db18a476d 16 {
scarter1 0:020db18a476d 17 public:
scarter1 0:020db18a476d 18 typedef double _time_step_type;
scarter1 0:020db18a476d 19 _time_step_type time_step;
scarter1 0:020db18a476d 20 typedef double _max_update_rate_type;
scarter1 0:020db18a476d 21 _max_update_rate_type max_update_rate;
scarter1 0:020db18a476d 22 typedef geometry_msgs::Vector3 _gravity_type;
scarter1 0:020db18a476d 23 _gravity_type gravity;
scarter1 0:020db18a476d 24 typedef gazebo_msgs::ODEPhysics _ode_config_type;
scarter1 0:020db18a476d 25 _ode_config_type ode_config;
scarter1 0:020db18a476d 26
scarter1 0:020db18a476d 27 SetPhysicsPropertiesRequest():
scarter1 0:020db18a476d 28 time_step(0),
scarter1 0:020db18a476d 29 max_update_rate(0),
scarter1 0:020db18a476d 30 gravity(),
scarter1 0:020db18a476d 31 ode_config()
scarter1 0:020db18a476d 32 {
scarter1 0:020db18a476d 33 }
scarter1 0:020db18a476d 34
scarter1 0:020db18a476d 35 virtual int serialize(unsigned char *outbuffer) const
scarter1 0:020db18a476d 36 {
scarter1 0:020db18a476d 37 int offset = 0;
scarter1 0:020db18a476d 38 union {
scarter1 0:020db18a476d 39 double real;
scarter1 0:020db18a476d 40 uint64_t base;
scarter1 0:020db18a476d 41 } u_time_step;
scarter1 0:020db18a476d 42 u_time_step.real = this->time_step;
scarter1 0:020db18a476d 43 *(outbuffer + offset + 0) = (u_time_step.base >> (8 * 0)) & 0xFF;
scarter1 0:020db18a476d 44 *(outbuffer + offset + 1) = (u_time_step.base >> (8 * 1)) & 0xFF;
scarter1 0:020db18a476d 45 *(outbuffer + offset + 2) = (u_time_step.base >> (8 * 2)) & 0xFF;
scarter1 0:020db18a476d 46 *(outbuffer + offset + 3) = (u_time_step.base >> (8 * 3)) & 0xFF;
scarter1 0:020db18a476d 47 *(outbuffer + offset + 4) = (u_time_step.base >> (8 * 4)) & 0xFF;
scarter1 0:020db18a476d 48 *(outbuffer + offset + 5) = (u_time_step.base >> (8 * 5)) & 0xFF;
scarter1 0:020db18a476d 49 *(outbuffer + offset + 6) = (u_time_step.base >> (8 * 6)) & 0xFF;
scarter1 0:020db18a476d 50 *(outbuffer + offset + 7) = (u_time_step.base >> (8 * 7)) & 0xFF;
scarter1 0:020db18a476d 51 offset += sizeof(this->time_step);
scarter1 0:020db18a476d 52 union {
scarter1 0:020db18a476d 53 double real;
scarter1 0:020db18a476d 54 uint64_t base;
scarter1 0:020db18a476d 55 } u_max_update_rate;
scarter1 0:020db18a476d 56 u_max_update_rate.real = this->max_update_rate;
scarter1 0:020db18a476d 57 *(outbuffer + offset + 0) = (u_max_update_rate.base >> (8 * 0)) & 0xFF;
scarter1 0:020db18a476d 58 *(outbuffer + offset + 1) = (u_max_update_rate.base >> (8 * 1)) & 0xFF;
scarter1 0:020db18a476d 59 *(outbuffer + offset + 2) = (u_max_update_rate.base >> (8 * 2)) & 0xFF;
scarter1 0:020db18a476d 60 *(outbuffer + offset + 3) = (u_max_update_rate.base >> (8 * 3)) & 0xFF;
scarter1 0:020db18a476d 61 *(outbuffer + offset + 4) = (u_max_update_rate.base >> (8 * 4)) & 0xFF;
scarter1 0:020db18a476d 62 *(outbuffer + offset + 5) = (u_max_update_rate.base >> (8 * 5)) & 0xFF;
scarter1 0:020db18a476d 63 *(outbuffer + offset + 6) = (u_max_update_rate.base >> (8 * 6)) & 0xFF;
scarter1 0:020db18a476d 64 *(outbuffer + offset + 7) = (u_max_update_rate.base >> (8 * 7)) & 0xFF;
scarter1 0:020db18a476d 65 offset += sizeof(this->max_update_rate);
scarter1 0:020db18a476d 66 offset += this->gravity.serialize(outbuffer + offset);
scarter1 0:020db18a476d 67 offset += this->ode_config.serialize(outbuffer + offset);
scarter1 0:020db18a476d 68 return offset;
scarter1 0:020db18a476d 69 }
scarter1 0:020db18a476d 70
scarter1 0:020db18a476d 71 virtual int deserialize(unsigned char *inbuffer)
scarter1 0:020db18a476d 72 {
scarter1 0:020db18a476d 73 int offset = 0;
scarter1 0:020db18a476d 74 union {
scarter1 0:020db18a476d 75 double real;
scarter1 0:020db18a476d 76 uint64_t base;
scarter1 0:020db18a476d 77 } u_time_step;
scarter1 0:020db18a476d 78 u_time_step.base = 0;
scarter1 0:020db18a476d 79 u_time_step.base |= ((uint64_t) (*(inbuffer + offset + 0))) << (8 * 0);
scarter1 0:020db18a476d 80 u_time_step.base |= ((uint64_t) (*(inbuffer + offset + 1))) << (8 * 1);
scarter1 0:020db18a476d 81 u_time_step.base |= ((uint64_t) (*(inbuffer + offset + 2))) << (8 * 2);
scarter1 0:020db18a476d 82 u_time_step.base |= ((uint64_t) (*(inbuffer + offset + 3))) << (8 * 3);
scarter1 0:020db18a476d 83 u_time_step.base |= ((uint64_t) (*(inbuffer + offset + 4))) << (8 * 4);
scarter1 0:020db18a476d 84 u_time_step.base |= ((uint64_t) (*(inbuffer + offset + 5))) << (8 * 5);
scarter1 0:020db18a476d 85 u_time_step.base |= ((uint64_t) (*(inbuffer + offset + 6))) << (8 * 6);
scarter1 0:020db18a476d 86 u_time_step.base |= ((uint64_t) (*(inbuffer + offset + 7))) << (8 * 7);
scarter1 0:020db18a476d 87 this->time_step = u_time_step.real;
scarter1 0:020db18a476d 88 offset += sizeof(this->time_step);
scarter1 0:020db18a476d 89 union {
scarter1 0:020db18a476d 90 double real;
scarter1 0:020db18a476d 91 uint64_t base;
scarter1 0:020db18a476d 92 } u_max_update_rate;
scarter1 0:020db18a476d 93 u_max_update_rate.base = 0;
scarter1 0:020db18a476d 94 u_max_update_rate.base |= ((uint64_t) (*(inbuffer + offset + 0))) << (8 * 0);
scarter1 0:020db18a476d 95 u_max_update_rate.base |= ((uint64_t) (*(inbuffer + offset + 1))) << (8 * 1);
scarter1 0:020db18a476d 96 u_max_update_rate.base |= ((uint64_t) (*(inbuffer + offset + 2))) << (8 * 2);
scarter1 0:020db18a476d 97 u_max_update_rate.base |= ((uint64_t) (*(inbuffer + offset + 3))) << (8 * 3);
scarter1 0:020db18a476d 98 u_max_update_rate.base |= ((uint64_t) (*(inbuffer + offset + 4))) << (8 * 4);
scarter1 0:020db18a476d 99 u_max_update_rate.base |= ((uint64_t) (*(inbuffer + offset + 5))) << (8 * 5);
scarter1 0:020db18a476d 100 u_max_update_rate.base |= ((uint64_t) (*(inbuffer + offset + 6))) << (8 * 6);
scarter1 0:020db18a476d 101 u_max_update_rate.base |= ((uint64_t) (*(inbuffer + offset + 7))) << (8 * 7);
scarter1 0:020db18a476d 102 this->max_update_rate = u_max_update_rate.real;
scarter1 0:020db18a476d 103 offset += sizeof(this->max_update_rate);
scarter1 0:020db18a476d 104 offset += this->gravity.deserialize(inbuffer + offset);
scarter1 0:020db18a476d 105 offset += this->ode_config.deserialize(inbuffer + offset);
scarter1 0:020db18a476d 106 return offset;
scarter1 0:020db18a476d 107 }
scarter1 0:020db18a476d 108
scarter1 0:020db18a476d 109 const char * getType(){ return SETPHYSICSPROPERTIES; };
scarter1 0:020db18a476d 110 const char * getMD5(){ return "abd9f82732b52b92e9d6bb36e6a82452"; };
scarter1 0:020db18a476d 111
scarter1 0:020db18a476d 112 };
scarter1 0:020db18a476d 113
scarter1 0:020db18a476d 114 class SetPhysicsPropertiesResponse : public ros::Msg
scarter1 0:020db18a476d 115 {
scarter1 0:020db18a476d 116 public:
scarter1 0:020db18a476d 117 typedef bool _success_type;
scarter1 0:020db18a476d 118 _success_type success;
scarter1 0:020db18a476d 119 typedef const char* _status_message_type;
scarter1 0:020db18a476d 120 _status_message_type status_message;
scarter1 0:020db18a476d 121
scarter1 0:020db18a476d 122 SetPhysicsPropertiesResponse():
scarter1 0:020db18a476d 123 success(0),
scarter1 0:020db18a476d 124 status_message("")
scarter1 0:020db18a476d 125 {
scarter1 0:020db18a476d 126 }
scarter1 0:020db18a476d 127
scarter1 0:020db18a476d 128 virtual int serialize(unsigned char *outbuffer) const
scarter1 0:020db18a476d 129 {
scarter1 0:020db18a476d 130 int offset = 0;
scarter1 0:020db18a476d 131 union {
scarter1 0:020db18a476d 132 bool real;
scarter1 0:020db18a476d 133 uint8_t base;
scarter1 0:020db18a476d 134 } u_success;
scarter1 0:020db18a476d 135 u_success.real = this->success;
scarter1 0:020db18a476d 136 *(outbuffer + offset + 0) = (u_success.base >> (8 * 0)) & 0xFF;
scarter1 0:020db18a476d 137 offset += sizeof(this->success);
scarter1 0:020db18a476d 138 uint32_t length_status_message = strlen(this->status_message);
scarter1 0:020db18a476d 139 varToArr(outbuffer + offset, length_status_message);
scarter1 0:020db18a476d 140 offset += 4;
scarter1 0:020db18a476d 141 memcpy(outbuffer + offset, this->status_message, length_status_message);
scarter1 0:020db18a476d 142 offset += length_status_message;
scarter1 0:020db18a476d 143 return offset;
scarter1 0:020db18a476d 144 }
scarter1 0:020db18a476d 145
scarter1 0:020db18a476d 146 virtual int deserialize(unsigned char *inbuffer)
scarter1 0:020db18a476d 147 {
scarter1 0:020db18a476d 148 int offset = 0;
scarter1 0:020db18a476d 149 union {
scarter1 0:020db18a476d 150 bool real;
scarter1 0:020db18a476d 151 uint8_t base;
scarter1 0:020db18a476d 152 } u_success;
scarter1 0:020db18a476d 153 u_success.base = 0;
scarter1 0:020db18a476d 154 u_success.base |= ((uint8_t) (*(inbuffer + offset + 0))) << (8 * 0);
scarter1 0:020db18a476d 155 this->success = u_success.real;
scarter1 0:020db18a476d 156 offset += sizeof(this->success);
scarter1 0:020db18a476d 157 uint32_t length_status_message;
scarter1 0:020db18a476d 158 arrToVar(length_status_message, (inbuffer + offset));
scarter1 0:020db18a476d 159 offset += 4;
scarter1 0:020db18a476d 160 for(unsigned int k= offset; k< offset+length_status_message; ++k){
scarter1 0:020db18a476d 161 inbuffer[k-1]=inbuffer[k];
scarter1 0:020db18a476d 162 }
scarter1 0:020db18a476d 163 inbuffer[offset+length_status_message-1]=0;
scarter1 0:020db18a476d 164 this->status_message = (char *)(inbuffer + offset-1);
scarter1 0:020db18a476d 165 offset += length_status_message;
scarter1 0:020db18a476d 166 return offset;
scarter1 0:020db18a476d 167 }
scarter1 0:020db18a476d 168
scarter1 0:020db18a476d 169 const char * getType(){ return SETPHYSICSPROPERTIES; };
scarter1 0:020db18a476d 170 const char * getMD5(){ return "2ec6f3eff0161f4257b808b12bc830c2"; };
scarter1 0:020db18a476d 171
scarter1 0:020db18a476d 172 };
scarter1 0:020db18a476d 173
scarter1 0:020db18a476d 174 class SetPhysicsProperties {
scarter1 0:020db18a476d 175 public:
scarter1 0:020db18a476d 176 typedef SetPhysicsPropertiesRequest Request;
scarter1 0:020db18a476d 177 typedef SetPhysicsPropertiesResponse Response;
scarter1 0:020db18a476d 178 };
scarter1 0:020db18a476d 179
scarter1 0:020db18a476d 180 }
scarter1 0:020db18a476d 181 #endif