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_std_msgs_Header_h
Jeonghoon 7:13dd93a0efe8 2 #define _ROS_std_msgs_Header_h
Jeonghoon 7:13dd93a0efe8 3
Jeonghoon 7:13dd93a0efe8 4 #include <stdint.h>
Jeonghoon 7:13dd93a0efe8 5 #include <string.h>
Jeonghoon 7:13dd93a0efe8 6 #include <stdlib.h>
Jeonghoon 7:13dd93a0efe8 7 #include "ros/msg.h"
Jeonghoon 7:13dd93a0efe8 8 #include "ros/time.h"
Jeonghoon 7:13dd93a0efe8 9
Jeonghoon 7:13dd93a0efe8 10 namespace std_msgs
Jeonghoon 7:13dd93a0efe8 11 {
Jeonghoon 7:13dd93a0efe8 12
Jeonghoon 7:13dd93a0efe8 13 class Header : public ros::Msg
Jeonghoon 7:13dd93a0efe8 14 {
Jeonghoon 7:13dd93a0efe8 15 public:
Jeonghoon 7:13dd93a0efe8 16 typedef uint32_t _seq_type;
Jeonghoon 7:13dd93a0efe8 17 _seq_type seq;
Jeonghoon 7:13dd93a0efe8 18 typedef ros::Time _stamp_type;
Jeonghoon 7:13dd93a0efe8 19 _stamp_type stamp;
Jeonghoon 7:13dd93a0efe8 20 typedef const char* _frame_id_type;
Jeonghoon 7:13dd93a0efe8 21 _frame_id_type frame_id;
Jeonghoon 7:13dd93a0efe8 22
Jeonghoon 7:13dd93a0efe8 23 Header():
Jeonghoon 7:13dd93a0efe8 24 seq(0),
Jeonghoon 7:13dd93a0efe8 25 stamp(),
Jeonghoon 7:13dd93a0efe8 26 frame_id("")
Jeonghoon 7:13dd93a0efe8 27 {
Jeonghoon 7:13dd93a0efe8 28 }
Jeonghoon 7:13dd93a0efe8 29
Jeonghoon 7:13dd93a0efe8 30 virtual int serialize(unsigned char *outbuffer) const
Jeonghoon 7:13dd93a0efe8 31 {
Jeonghoon 7:13dd93a0efe8 32 int offset = 0;
Jeonghoon 7:13dd93a0efe8 33 *(outbuffer + offset + 0) = (this->seq >> (8 * 0)) & 0xFF;
Jeonghoon 7:13dd93a0efe8 34 *(outbuffer + offset + 1) = (this->seq >> (8 * 1)) & 0xFF;
Jeonghoon 7:13dd93a0efe8 35 *(outbuffer + offset + 2) = (this->seq >> (8 * 2)) & 0xFF;
Jeonghoon 7:13dd93a0efe8 36 *(outbuffer + offset + 3) = (this->seq >> (8 * 3)) & 0xFF;
Jeonghoon 7:13dd93a0efe8 37 offset += sizeof(this->seq);
Jeonghoon 7:13dd93a0efe8 38 *(outbuffer + offset + 0) = (this->stamp.sec >> (8 * 0)) & 0xFF;
Jeonghoon 7:13dd93a0efe8 39 *(outbuffer + offset + 1) = (this->stamp.sec >> (8 * 1)) & 0xFF;
Jeonghoon 7:13dd93a0efe8 40 *(outbuffer + offset + 2) = (this->stamp.sec >> (8 * 2)) & 0xFF;
Jeonghoon 7:13dd93a0efe8 41 *(outbuffer + offset + 3) = (this->stamp.sec >> (8 * 3)) & 0xFF;
Jeonghoon 7:13dd93a0efe8 42 offset += sizeof(this->stamp.sec);
Jeonghoon 7:13dd93a0efe8 43 *(outbuffer + offset + 0) = (this->stamp.nsec >> (8 * 0)) & 0xFF;
Jeonghoon 7:13dd93a0efe8 44 *(outbuffer + offset + 1) = (this->stamp.nsec >> (8 * 1)) & 0xFF;
Jeonghoon 7:13dd93a0efe8 45 *(outbuffer + offset + 2) = (this->stamp.nsec >> (8 * 2)) & 0xFF;
Jeonghoon 7:13dd93a0efe8 46 *(outbuffer + offset + 3) = (this->stamp.nsec >> (8 * 3)) & 0xFF;
Jeonghoon 7:13dd93a0efe8 47 offset += sizeof(this->stamp.nsec);
Jeonghoon 7:13dd93a0efe8 48 uint32_t length_frame_id = strlen(this->frame_id);
Jeonghoon 7:13dd93a0efe8 49 varToArr(outbuffer + offset, length_frame_id);
Jeonghoon 7:13dd93a0efe8 50 offset += 4;
Jeonghoon 7:13dd93a0efe8 51 memcpy(outbuffer + offset, this->frame_id, length_frame_id);
Jeonghoon 7:13dd93a0efe8 52 offset += length_frame_id;
Jeonghoon 7:13dd93a0efe8 53 return offset;
Jeonghoon 7:13dd93a0efe8 54 }
Jeonghoon 7:13dd93a0efe8 55
Jeonghoon 7:13dd93a0efe8 56 virtual int deserialize(unsigned char *inbuffer)
Jeonghoon 7:13dd93a0efe8 57 {
Jeonghoon 7:13dd93a0efe8 58 int offset = 0;
Jeonghoon 7:13dd93a0efe8 59 this->seq = ((uint32_t) (*(inbuffer + offset)));
Jeonghoon 7:13dd93a0efe8 60 this->seq |= ((uint32_t) (*(inbuffer + offset + 1))) << (8 * 1);
Jeonghoon 7:13dd93a0efe8 61 this->seq |= ((uint32_t) (*(inbuffer + offset + 2))) << (8 * 2);
Jeonghoon 7:13dd93a0efe8 62 this->seq |= ((uint32_t) (*(inbuffer + offset + 3))) << (8 * 3);
Jeonghoon 7:13dd93a0efe8 63 offset += sizeof(this->seq);
Jeonghoon 7:13dd93a0efe8 64 this->stamp.sec = ((uint32_t) (*(inbuffer + offset)));
Jeonghoon 7:13dd93a0efe8 65 this->stamp.sec |= ((uint32_t) (*(inbuffer + offset + 1))) << (8 * 1);
Jeonghoon 7:13dd93a0efe8 66 this->stamp.sec |= ((uint32_t) (*(inbuffer + offset + 2))) << (8 * 2);
Jeonghoon 7:13dd93a0efe8 67 this->stamp.sec |= ((uint32_t) (*(inbuffer + offset + 3))) << (8 * 3);
Jeonghoon 7:13dd93a0efe8 68 offset += sizeof(this->stamp.sec);
Jeonghoon 7:13dd93a0efe8 69 this->stamp.nsec = ((uint32_t) (*(inbuffer + offset)));
Jeonghoon 7:13dd93a0efe8 70 this->stamp.nsec |= ((uint32_t) (*(inbuffer + offset + 1))) << (8 * 1);
Jeonghoon 7:13dd93a0efe8 71 this->stamp.nsec |= ((uint32_t) (*(inbuffer + offset + 2))) << (8 * 2);
Jeonghoon 7:13dd93a0efe8 72 this->stamp.nsec |= ((uint32_t) (*(inbuffer + offset + 3))) << (8 * 3);
Jeonghoon 7:13dd93a0efe8 73 offset += sizeof(this->stamp.nsec);
Jeonghoon 7:13dd93a0efe8 74 uint32_t length_frame_id;
Jeonghoon 7:13dd93a0efe8 75 arrToVar(length_frame_id, (inbuffer + offset));
Jeonghoon 7:13dd93a0efe8 76 offset += 4;
Jeonghoon 7:13dd93a0efe8 77 for(unsigned int k= offset; k< offset+length_frame_id; ++k){
Jeonghoon 7:13dd93a0efe8 78 inbuffer[k-1]=inbuffer[k];
Jeonghoon 7:13dd93a0efe8 79 }
Jeonghoon 7:13dd93a0efe8 80 inbuffer[offset+length_frame_id-1]=0;
Jeonghoon 7:13dd93a0efe8 81 this->frame_id = (char *)(inbuffer + offset-1);
Jeonghoon 7:13dd93a0efe8 82 offset += length_frame_id;
Jeonghoon 7:13dd93a0efe8 83 return offset;
Jeonghoon 7:13dd93a0efe8 84 }
Jeonghoon 7:13dd93a0efe8 85
Jeonghoon 7:13dd93a0efe8 86 const char * getType(){ return "std_msgs/Header"; };
Jeonghoon 7:13dd93a0efe8 87 const char * getMD5(){ return "2176decaecbce78abc3b96ef049fabed"; };
Jeonghoon 7:13dd93a0efe8 88
Jeonghoon 7:13dd93a0efe8 89 };
Jeonghoon 7:13dd93a0efe8 90
Jeonghoon 7:13dd93a0efe8 91 }
Jeonghoon 7:13dd93a0efe8 92 #endif