hairo

Dependencies:   mbed BufferedSerial

Committer:
tknara
Date:
Tue Dec 04 00:14:32 2018 +0000
Revision:
4:bcdd99711326
Parent:
0:9e9b7db60fd5
test

Who changed what in which revision?

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