complete motor

Dependencies:   BufferedSerial motor_sn7544

Committer:
Jeonghoon
Date:
Thu Jun 27 04:58:29 2019 +0000
Revision:
7:13dd93a0efe8
combine motor with ROS

Who changed what in which revision?

UserRevisionLine numberNew contents of line
Jeonghoon 7:13dd93a0efe8 1 #ifndef _ROS_SERVICE_RequestServiceInfo_h
Jeonghoon 7:13dd93a0efe8 2 #define _ROS_SERVICE_RequestServiceInfo_h
Jeonghoon 7:13dd93a0efe8 3 #include <stdint.h>
Jeonghoon 7:13dd93a0efe8 4 #include <string.h>
Jeonghoon 7:13dd93a0efe8 5 #include <stdlib.h>
Jeonghoon 7:13dd93a0efe8 6 #include "ros/msg.h"
Jeonghoon 7:13dd93a0efe8 7
Jeonghoon 7:13dd93a0efe8 8 namespace rosserial_msgs
Jeonghoon 7:13dd93a0efe8 9 {
Jeonghoon 7:13dd93a0efe8 10
Jeonghoon 7:13dd93a0efe8 11 static const char REQUESTSERVICEINFO[] = "rosserial_msgs/RequestServiceInfo";
Jeonghoon 7:13dd93a0efe8 12
Jeonghoon 7:13dd93a0efe8 13 class RequestServiceInfoRequest : public ros::Msg
Jeonghoon 7:13dd93a0efe8 14 {
Jeonghoon 7:13dd93a0efe8 15 public:
Jeonghoon 7:13dd93a0efe8 16 typedef const char* _service_type;
Jeonghoon 7:13dd93a0efe8 17 _service_type service;
Jeonghoon 7:13dd93a0efe8 18
Jeonghoon 7:13dd93a0efe8 19 RequestServiceInfoRequest():
Jeonghoon 7:13dd93a0efe8 20 service("")
Jeonghoon 7:13dd93a0efe8 21 {
Jeonghoon 7:13dd93a0efe8 22 }
Jeonghoon 7:13dd93a0efe8 23
Jeonghoon 7:13dd93a0efe8 24 virtual int serialize(unsigned char *outbuffer) const
Jeonghoon 7:13dd93a0efe8 25 {
Jeonghoon 7:13dd93a0efe8 26 int offset = 0;
Jeonghoon 7:13dd93a0efe8 27 uint32_t length_service = strlen(this->service);
Jeonghoon 7:13dd93a0efe8 28 varToArr(outbuffer + offset, length_service);
Jeonghoon 7:13dd93a0efe8 29 offset += 4;
Jeonghoon 7:13dd93a0efe8 30 memcpy(outbuffer + offset, this->service, length_service);
Jeonghoon 7:13dd93a0efe8 31 offset += length_service;
Jeonghoon 7:13dd93a0efe8 32 return offset;
Jeonghoon 7:13dd93a0efe8 33 }
Jeonghoon 7:13dd93a0efe8 34
Jeonghoon 7:13dd93a0efe8 35 virtual int deserialize(unsigned char *inbuffer)
Jeonghoon 7:13dd93a0efe8 36 {
Jeonghoon 7:13dd93a0efe8 37 int offset = 0;
Jeonghoon 7:13dd93a0efe8 38 uint32_t length_service;
Jeonghoon 7:13dd93a0efe8 39 arrToVar(length_service, (inbuffer + offset));
Jeonghoon 7:13dd93a0efe8 40 offset += 4;
Jeonghoon 7:13dd93a0efe8 41 for(unsigned int k= offset; k< offset+length_service; ++k){
Jeonghoon 7:13dd93a0efe8 42 inbuffer[k-1]=inbuffer[k];
Jeonghoon 7:13dd93a0efe8 43 }
Jeonghoon 7:13dd93a0efe8 44 inbuffer[offset+length_service-1]=0;
Jeonghoon 7:13dd93a0efe8 45 this->service = (char *)(inbuffer + offset-1);
Jeonghoon 7:13dd93a0efe8 46 offset += length_service;
Jeonghoon 7:13dd93a0efe8 47 return offset;
Jeonghoon 7:13dd93a0efe8 48 }
Jeonghoon 7:13dd93a0efe8 49
Jeonghoon 7:13dd93a0efe8 50 const char * getType(){ return REQUESTSERVICEINFO; };
Jeonghoon 7:13dd93a0efe8 51 const char * getMD5(){ return "1cbcfa13b08f6d36710b9af8741e6112"; };
Jeonghoon 7:13dd93a0efe8 52
Jeonghoon 7:13dd93a0efe8 53 };
Jeonghoon 7:13dd93a0efe8 54
Jeonghoon 7:13dd93a0efe8 55 class RequestServiceInfoResponse : public ros::Msg
Jeonghoon 7:13dd93a0efe8 56 {
Jeonghoon 7:13dd93a0efe8 57 public:
Jeonghoon 7:13dd93a0efe8 58 typedef const char* _service_md5_type;
Jeonghoon 7:13dd93a0efe8 59 _service_md5_type service_md5;
Jeonghoon 7:13dd93a0efe8 60 typedef const char* _request_md5_type;
Jeonghoon 7:13dd93a0efe8 61 _request_md5_type request_md5;
Jeonghoon 7:13dd93a0efe8 62 typedef const char* _response_md5_type;
Jeonghoon 7:13dd93a0efe8 63 _response_md5_type response_md5;
Jeonghoon 7:13dd93a0efe8 64
Jeonghoon 7:13dd93a0efe8 65 RequestServiceInfoResponse():
Jeonghoon 7:13dd93a0efe8 66 service_md5(""),
Jeonghoon 7:13dd93a0efe8 67 request_md5(""),
Jeonghoon 7:13dd93a0efe8 68 response_md5("")
Jeonghoon 7:13dd93a0efe8 69 {
Jeonghoon 7:13dd93a0efe8 70 }
Jeonghoon 7:13dd93a0efe8 71
Jeonghoon 7:13dd93a0efe8 72 virtual int serialize(unsigned char *outbuffer) const
Jeonghoon 7:13dd93a0efe8 73 {
Jeonghoon 7:13dd93a0efe8 74 int offset = 0;
Jeonghoon 7:13dd93a0efe8 75 uint32_t length_service_md5 = strlen(this->service_md5);
Jeonghoon 7:13dd93a0efe8 76 varToArr(outbuffer + offset, length_service_md5);
Jeonghoon 7:13dd93a0efe8 77 offset += 4;
Jeonghoon 7:13dd93a0efe8 78 memcpy(outbuffer + offset, this->service_md5, length_service_md5);
Jeonghoon 7:13dd93a0efe8 79 offset += length_service_md5;
Jeonghoon 7:13dd93a0efe8 80 uint32_t length_request_md5 = strlen(this->request_md5);
Jeonghoon 7:13dd93a0efe8 81 varToArr(outbuffer + offset, length_request_md5);
Jeonghoon 7:13dd93a0efe8 82 offset += 4;
Jeonghoon 7:13dd93a0efe8 83 memcpy(outbuffer + offset, this->request_md5, length_request_md5);
Jeonghoon 7:13dd93a0efe8 84 offset += length_request_md5;
Jeonghoon 7:13dd93a0efe8 85 uint32_t length_response_md5 = strlen(this->response_md5);
Jeonghoon 7:13dd93a0efe8 86 varToArr(outbuffer + offset, length_response_md5);
Jeonghoon 7:13dd93a0efe8 87 offset += 4;
Jeonghoon 7:13dd93a0efe8 88 memcpy(outbuffer + offset, this->response_md5, length_response_md5);
Jeonghoon 7:13dd93a0efe8 89 offset += length_response_md5;
Jeonghoon 7:13dd93a0efe8 90 return offset;
Jeonghoon 7:13dd93a0efe8 91 }
Jeonghoon 7:13dd93a0efe8 92
Jeonghoon 7:13dd93a0efe8 93 virtual int deserialize(unsigned char *inbuffer)
Jeonghoon 7:13dd93a0efe8 94 {
Jeonghoon 7:13dd93a0efe8 95 int offset = 0;
Jeonghoon 7:13dd93a0efe8 96 uint32_t length_service_md5;
Jeonghoon 7:13dd93a0efe8 97 arrToVar(length_service_md5, (inbuffer + offset));
Jeonghoon 7:13dd93a0efe8 98 offset += 4;
Jeonghoon 7:13dd93a0efe8 99 for(unsigned int k= offset; k< offset+length_service_md5; ++k){
Jeonghoon 7:13dd93a0efe8 100 inbuffer[k-1]=inbuffer[k];
Jeonghoon 7:13dd93a0efe8 101 }
Jeonghoon 7:13dd93a0efe8 102 inbuffer[offset+length_service_md5-1]=0;
Jeonghoon 7:13dd93a0efe8 103 this->service_md5 = (char *)(inbuffer + offset-1);
Jeonghoon 7:13dd93a0efe8 104 offset += length_service_md5;
Jeonghoon 7:13dd93a0efe8 105 uint32_t length_request_md5;
Jeonghoon 7:13dd93a0efe8 106 arrToVar(length_request_md5, (inbuffer + offset));
Jeonghoon 7:13dd93a0efe8 107 offset += 4;
Jeonghoon 7:13dd93a0efe8 108 for(unsigned int k= offset; k< offset+length_request_md5; ++k){
Jeonghoon 7:13dd93a0efe8 109 inbuffer[k-1]=inbuffer[k];
Jeonghoon 7:13dd93a0efe8 110 }
Jeonghoon 7:13dd93a0efe8 111 inbuffer[offset+length_request_md5-1]=0;
Jeonghoon 7:13dd93a0efe8 112 this->request_md5 = (char *)(inbuffer + offset-1);
Jeonghoon 7:13dd93a0efe8 113 offset += length_request_md5;
Jeonghoon 7:13dd93a0efe8 114 uint32_t length_response_md5;
Jeonghoon 7:13dd93a0efe8 115 arrToVar(length_response_md5, (inbuffer + offset));
Jeonghoon 7:13dd93a0efe8 116 offset += 4;
Jeonghoon 7:13dd93a0efe8 117 for(unsigned int k= offset; k< offset+length_response_md5; ++k){
Jeonghoon 7:13dd93a0efe8 118 inbuffer[k-1]=inbuffer[k];
Jeonghoon 7:13dd93a0efe8 119 }
Jeonghoon 7:13dd93a0efe8 120 inbuffer[offset+length_response_md5-1]=0;
Jeonghoon 7:13dd93a0efe8 121 this->response_md5 = (char *)(inbuffer + offset-1);
Jeonghoon 7:13dd93a0efe8 122 offset += length_response_md5;
Jeonghoon 7:13dd93a0efe8 123 return offset;
Jeonghoon 7:13dd93a0efe8 124 }
Jeonghoon 7:13dd93a0efe8 125
Jeonghoon 7:13dd93a0efe8 126 const char * getType(){ return REQUESTSERVICEINFO; };
Jeonghoon 7:13dd93a0efe8 127 const char * getMD5(){ return "c3d6dd25b909596479fbbc6559fa6874"; };
Jeonghoon 7:13dd93a0efe8 128
Jeonghoon 7:13dd93a0efe8 129 };
Jeonghoon 7:13dd93a0efe8 130
Jeonghoon 7:13dd93a0efe8 131 class RequestServiceInfo {
Jeonghoon 7:13dd93a0efe8 132 public:
Jeonghoon 7:13dd93a0efe8 133 typedef RequestServiceInfoRequest Request;
Jeonghoon 7:13dd93a0efe8 134 typedef RequestServiceInfoResponse Response;
Jeonghoon 7:13dd93a0efe8 135 };
Jeonghoon 7:13dd93a0efe8 136
Jeonghoon 7:13dd93a0efe8 137 }
Jeonghoon 7:13dd93a0efe8 138 #endif