add custom ros messages

Dependents:   stm32_actuator_gobeur

Committer:
kyxstark
Date:
Thu Jul 08 17:14:33 2021 +0000
Revision:
0:49ecb29f2afc
Child:
1:60f7c46cc24c
implement custom ros messages to be subscriable; ; - game_manager/game_status added

Who changed what in which revision?

UserRevisionLine numberNew contents of line
kyxstark 0:49ecb29f2afc 1 #ifndef _ROS_stm32_game_manager_game_status_h
kyxstark 0:49ecb29f2afc 2 #define _ROS_stm32_game_manager_game_status_h
kyxstark 0:49ecb29f2afc 3
kyxstark 0:49ecb29f2afc 4 #include <stdint.h>
kyxstark 0:49ecb29f2afc 5 #include <string.h>
kyxstark 0:49ecb29f2afc 6 #include <stdlib.h>
kyxstark 0:49ecb29f2afc 7 #include "ros/msg.h"
kyxstark 0:49ecb29f2afc 8
kyxstark 0:49ecb29f2afc 9
kyxstark 0:49ecb29f2afc 10 namespace game_manager_node
kyxstark 0:49ecb29f2afc 11 {
kyxstark 0:49ecb29f2afc 12
kyxstark 0:49ecb29f2afc 13 class game_status_msg : public ros::Msg
kyxstark 0:49ecb29f2afc 14 {
kyxstark 0:49ecb29f2afc 15 public:
kyxstark 0:49ecb29f2afc 16 typedef uint8_t _game_status_type;
kyxstark 0:49ecb29f2afc 17 _game_status_type game_status;
kyxstark 0:49ecb29f2afc 18 typedef uint8_t _init_status_type;
kyxstark 0:49ecb29f2afc 19 _init_status_type init_status;
kyxstark 0:49ecb29f2afc 20
kyxstark 0:49ecb29f2afc 21 game_status_msg():
kyxstark 0:49ecb29f2afc 22 game_status(0),
kyxstark 0:49ecb29f2afc 23 init_status(0)
kyxstark 0:49ecb29f2afc 24 {
kyxstark 0:49ecb29f2afc 25 }
kyxstark 0:49ecb29f2afc 26
kyxstark 0:49ecb29f2afc 27 virtual int serialize(unsigned char *outbuffer) const
kyxstark 0:49ecb29f2afc 28 {
kyxstark 0:49ecb29f2afc 29 int offset = 0;
kyxstark 0:49ecb29f2afc 30 *(outbuffer + offset + 0) = (this->game_status >> (8 * 0)) & 0xFF;
kyxstark 0:49ecb29f2afc 31 offset += sizeof(this->game_status);
kyxstark 0:49ecb29f2afc 32 *(outbuffer + offset + 0) = (this->init_status >> (8 * 0)) & 0xFF;
kyxstark 0:49ecb29f2afc 33 offset += sizeof(this->init_status);
kyxstark 0:49ecb29f2afc 34 return offset;
kyxstark 0:49ecb29f2afc 35 }
kyxstark 0:49ecb29f2afc 36
kyxstark 0:49ecb29f2afc 37 virtual int deserialize(unsigned char *inbuffer)
kyxstark 0:49ecb29f2afc 38 {
kyxstark 0:49ecb29f2afc 39 int offset = 0;
kyxstark 0:49ecb29f2afc 40 this->game_status = ((uint8_t) (*(inbuffer + offset)));
kyxstark 0:49ecb29f2afc 41 offset += sizeof(this->game_status);
kyxstark 0:49ecb29f2afc 42 this->init_status = ((uint8_t) (*(inbuffer + offset)));
kyxstark 0:49ecb29f2afc 43 offset += sizeof(this->init_status);
kyxstark 0:49ecb29f2afc 44 return offset;
kyxstark 0:49ecb29f2afc 45 }
kyxstark 0:49ecb29f2afc 46
kyxstark 0:49ecb29f2afc 47 const char * getType(){ return "game_manager/GameStatus"; };
kyxstark 0:49ecb29f2afc 48 const char * getMD5(){ return "33a9b4e076016e58fe35593be08a2827"; };
kyxstark 0:49ecb29f2afc 49
kyxstark 0:49ecb29f2afc 50 };
kyxstark 0:49ecb29f2afc 51
kyxstark 0:49ecb29f2afc 52 }
kyxstark 0:49ecb29f2afc 53
kyxstark 0:49ecb29f2afc 54
kyxstark 0:49ecb29f2afc 55 #endif