capstone_finish

Dependencies:   BufferedSerial motor_sn7544

Committer:
Jeonghoon
Date:
Tue Nov 26 15:30:27 2019 +0000
Revision:
10:ca4e4062701a
Parent:
3:2a3664dc6634
capstone finish

Who changed what in which revision?

UserRevisionLine numberNew contents of line
Jeonghoon 3:2a3664dc6634 1 #ifndef _ROS_sensor_msgs_JoyFeedback_h
Jeonghoon 3:2a3664dc6634 2 #define _ROS_sensor_msgs_JoyFeedback_h
Jeonghoon 3:2a3664dc6634 3
Jeonghoon 3:2a3664dc6634 4 #include <stdint.h>
Jeonghoon 3:2a3664dc6634 5 #include <string.h>
Jeonghoon 3:2a3664dc6634 6 #include <stdlib.h>
Jeonghoon 3:2a3664dc6634 7 #include "ros/msg.h"
Jeonghoon 3:2a3664dc6634 8
Jeonghoon 3:2a3664dc6634 9 namespace sensor_msgs
Jeonghoon 3:2a3664dc6634 10 {
Jeonghoon 3:2a3664dc6634 11
Jeonghoon 3:2a3664dc6634 12 class JoyFeedback : public ros::Msg
Jeonghoon 3:2a3664dc6634 13 {
Jeonghoon 3:2a3664dc6634 14 public:
Jeonghoon 3:2a3664dc6634 15 typedef uint8_t _type_type;
Jeonghoon 3:2a3664dc6634 16 _type_type type;
Jeonghoon 3:2a3664dc6634 17 typedef uint8_t _id_type;
Jeonghoon 3:2a3664dc6634 18 _id_type id;
Jeonghoon 3:2a3664dc6634 19 typedef float _intensity_type;
Jeonghoon 3:2a3664dc6634 20 _intensity_type intensity;
Jeonghoon 3:2a3664dc6634 21 enum { TYPE_LED = 0 };
Jeonghoon 3:2a3664dc6634 22 enum { TYPE_RUMBLE = 1 };
Jeonghoon 3:2a3664dc6634 23 enum { TYPE_BUZZER = 2 };
Jeonghoon 3:2a3664dc6634 24
Jeonghoon 3:2a3664dc6634 25 JoyFeedback():
Jeonghoon 3:2a3664dc6634 26 type(0),
Jeonghoon 3:2a3664dc6634 27 id(0),
Jeonghoon 3:2a3664dc6634 28 intensity(0)
Jeonghoon 3:2a3664dc6634 29 {
Jeonghoon 3:2a3664dc6634 30 }
Jeonghoon 3:2a3664dc6634 31
Jeonghoon 3:2a3664dc6634 32 virtual int serialize(unsigned char *outbuffer) const
Jeonghoon 3:2a3664dc6634 33 {
Jeonghoon 3:2a3664dc6634 34 int offset = 0;
Jeonghoon 3:2a3664dc6634 35 *(outbuffer + offset + 0) = (this->type >> (8 * 0)) & 0xFF;
Jeonghoon 3:2a3664dc6634 36 offset += sizeof(this->type);
Jeonghoon 3:2a3664dc6634 37 *(outbuffer + offset + 0) = (this->id >> (8 * 0)) & 0xFF;
Jeonghoon 3:2a3664dc6634 38 offset += sizeof(this->id);
Jeonghoon 3:2a3664dc6634 39 union {
Jeonghoon 3:2a3664dc6634 40 float real;
Jeonghoon 3:2a3664dc6634 41 uint32_t base;
Jeonghoon 3:2a3664dc6634 42 } u_intensity;
Jeonghoon 3:2a3664dc6634 43 u_intensity.real = this->intensity;
Jeonghoon 3:2a3664dc6634 44 *(outbuffer + offset + 0) = (u_intensity.base >> (8 * 0)) & 0xFF;
Jeonghoon 3:2a3664dc6634 45 *(outbuffer + offset + 1) = (u_intensity.base >> (8 * 1)) & 0xFF;
Jeonghoon 3:2a3664dc6634 46 *(outbuffer + offset + 2) = (u_intensity.base >> (8 * 2)) & 0xFF;
Jeonghoon 3:2a3664dc6634 47 *(outbuffer + offset + 3) = (u_intensity.base >> (8 * 3)) & 0xFF;
Jeonghoon 3:2a3664dc6634 48 offset += sizeof(this->intensity);
Jeonghoon 3:2a3664dc6634 49 return offset;
Jeonghoon 3:2a3664dc6634 50 }
Jeonghoon 3:2a3664dc6634 51
Jeonghoon 3:2a3664dc6634 52 virtual int deserialize(unsigned char *inbuffer)
Jeonghoon 3:2a3664dc6634 53 {
Jeonghoon 3:2a3664dc6634 54 int offset = 0;
Jeonghoon 3:2a3664dc6634 55 this->type = ((uint8_t) (*(inbuffer + offset)));
Jeonghoon 3:2a3664dc6634 56 offset += sizeof(this->type);
Jeonghoon 3:2a3664dc6634 57 this->id = ((uint8_t) (*(inbuffer + offset)));
Jeonghoon 3:2a3664dc6634 58 offset += sizeof(this->id);
Jeonghoon 3:2a3664dc6634 59 union {
Jeonghoon 3:2a3664dc6634 60 float real;
Jeonghoon 3:2a3664dc6634 61 uint32_t base;
Jeonghoon 3:2a3664dc6634 62 } u_intensity;
Jeonghoon 3:2a3664dc6634 63 u_intensity.base = 0;
Jeonghoon 3:2a3664dc6634 64 u_intensity.base |= ((uint32_t) (*(inbuffer + offset + 0))) << (8 * 0);
Jeonghoon 3:2a3664dc6634 65 u_intensity.base |= ((uint32_t) (*(inbuffer + offset + 1))) << (8 * 1);
Jeonghoon 3:2a3664dc6634 66 u_intensity.base |= ((uint32_t) (*(inbuffer + offset + 2))) << (8 * 2);
Jeonghoon 3:2a3664dc6634 67 u_intensity.base |= ((uint32_t) (*(inbuffer + offset + 3))) << (8 * 3);
Jeonghoon 3:2a3664dc6634 68 this->intensity = u_intensity.real;
Jeonghoon 3:2a3664dc6634 69 offset += sizeof(this->intensity);
Jeonghoon 3:2a3664dc6634 70 return offset;
Jeonghoon 3:2a3664dc6634 71 }
Jeonghoon 3:2a3664dc6634 72
Jeonghoon 3:2a3664dc6634 73 const char * getType(){ return "sensor_msgs/JoyFeedback"; };
Jeonghoon 3:2a3664dc6634 74 const char * getMD5(){ return "f4dcd73460360d98f36e55ee7f2e46f1"; };
Jeonghoon 3:2a3664dc6634 75
Jeonghoon 3:2a3664dc6634 76 };
Jeonghoon 3:2a3664dc6634 77
Jeonghoon 3:2a3664dc6634 78 }
Jeonghoon 3:2a3664dc6634 79 #endif