gobeur de gobelets, gestion de la turbine et du servomoteur en automateet du message ROS lié

Dependents:   stm32_actuator_gobeur

Committer:
kyxstark
Date:
Thu Jul 08 22:45:59 2021 +0000
Revision:
5:64a88f154e65
Parent:
4:bc5e3a8e3f92
peut de modif;

Who changed what in which revision?

UserRevisionLine numberNew contents of line
mondiaye 0:7312173b8d5f 1 #ifndef _ROS_stm32_gobeur_Gobeur_h
mondiaye 0:7312173b8d5f 2 #define _ROS_stm32_gobeur_Gobeur_h
mondiaye 0:7312173b8d5f 3
mondiaye 0:7312173b8d5f 4 #include <stdint.h>
mondiaye 0:7312173b8d5f 5 #include <string.h>
mondiaye 0:7312173b8d5f 6 #include <stdlib.h>
kyxstark 3:44a200543540 7 #include <Servo.h>
kyxstark 3:44a200543540 8 #include "../actuators.h"
mondiaye 0:7312173b8d5f 9 #include "ros/msg.h"
mondiaye 0:7312173b8d5f 10
kyxstark 3:44a200543540 11
kyxstark 3:44a200543540 12
kyxstark 3:44a200543540 13 #define GOBEUR_SUCKING_TIMEOUT 1
kyxstark 3:44a200543540 14 #define GOBEUR_CLOSING_TIMEOUT 1
kyxstark 3:44a200543540 15 #define GOBEUR_OPENING_TIMEOUT 1
kyxstark 3:44a200543540 16 #define GOBEUR_PAUSE_TIMEOUT 1
kyxstark 3:44a200543540 17
kyxstark 3:44a200543540 18
kyxstark 3:44a200543540 19
kyxstark 5:64a88f154e65 20 namespace stm32_actuators_node
mondiaye 0:7312173b8d5f 21 {
mondiaye 0:7312173b8d5f 22
kyxstark 3:44a200543540 23 class Gobeur_msg : public ros::Msg
mondiaye 0:7312173b8d5f 24 {
mondiaye 0:7312173b8d5f 25 public:
kyxstark 3:44a200543540 26 typedef uint8_t _index_gobeur_type;
kyxstark 3:44a200543540 27 _index_gobeur_type index_gobeur;
kyxstark 3:44a200543540 28 typedef uint8_t _gobeur_order_type;
kyxstark 3:44a200543540 29 _gobeur_order_type gobeur_order;
mondiaye 0:7312173b8d5f 30
kyxstark 3:44a200543540 31 Gobeur_msg():
kyxstark 3:44a200543540 32 index_gobeur(0),
kyxstark 3:44a200543540 33 gobeur_order(0)
kyxstark 3:44a200543540 34 {
kyxstark 3:44a200543540 35 }
kyxstark 3:44a200543540 36
kyxstark 3:44a200543540 37 virtual int serialize(unsigned char *outbuffer) const
kyxstark 3:44a200543540 38 {
kyxstark 3:44a200543540 39 int offset = 0;
kyxstark 3:44a200543540 40 *(outbuffer + offset + 0) = (this->index_gobeur >> (8 * 0)) & 0xFF;
kyxstark 3:44a200543540 41 offset += sizeof(this->index_gobeur);
kyxstark 3:44a200543540 42 *(outbuffer + offset + 0) = (this->gobeur_order >> (8 * 0)) & 0xFF;
kyxstark 3:44a200543540 43 offset += sizeof(this->gobeur_order);
kyxstark 3:44a200543540 44 return offset;
kyxstark 3:44a200543540 45 }
kyxstark 3:44a200543540 46
kyxstark 3:44a200543540 47 virtual int deserialize(unsigned char *inbuffer)
kyxstark 3:44a200543540 48 {
kyxstark 3:44a200543540 49 int offset = 0;
kyxstark 3:44a200543540 50 this->index_gobeur = ((uint8_t) (*(inbuffer + offset)));
kyxstark 3:44a200543540 51 offset += sizeof(this->index_gobeur);
kyxstark 3:44a200543540 52 this->gobeur_order = ((uint8_t) (*(inbuffer + offset)));
kyxstark 3:44a200543540 53 offset += sizeof(this->gobeur_order);
kyxstark 3:44a200543540 54 return offset;
kyxstark 3:44a200543540 55 }
kyxstark 3:44a200543540 56
kyxstark 5:64a88f154e65 57 const char * getType(){ return "stm32_actuators/Gobeur_msg"; };
kyxstark 5:64a88f154e65 58 const char * getMD5(){ return "02fe53940b821cdd54efe4bd91e2b68b"; };
mondiaye 0:7312173b8d5f 59
mondiaye 0:7312173b8d5f 60 };
mondiaye 0:7312173b8d5f 61
mondiaye 0:7312173b8d5f 62 }
kyxstark 3:44a200543540 63
kyxstark 3:44a200543540 64
kyxstark 5:64a88f154e65 65 void gobeur_trait_msg(const stm32_actuators_node::Gobeur_msg& gobeur_msg);
kyxstark 3:44a200543540 66
kyxstark 3:44a200543540 67
kyxstark 3:44a200543540 68
kyxstark 3:44a200543540 69 class Gobeur
kyxstark 3:44a200543540 70 {
kyxstark 3:44a200543540 71 public:
kyxstark 3:44a200543540 72
kyxstark 3:44a200543540 73 typedef enum
kyxstark 3:44a200543540 74 {released, sucking, closing, ack_sucked, sucked, releasing, ack_released}
kyxstark 3:44a200543540 75 state_gobeur_t;
kyxstark 3:44a200543540 76
kyxstark 3:44a200543540 77 typedef enum
kyxstark 3:44a200543540 78 {suck, release}
kyxstark 3:44a200543540 79 gobeur_order_t;
kyxstark 3:44a200543540 80
kyxstark 3:44a200543540 81 Gobeur(PinName pin_turbine, PinName pin_servo, float turbine_on, float turbine_off, float servo_open, float servo_close);
kyxstark 3:44a200543540 82
kyxstark 3:44a200543540 83 void update_order(int order);
kyxstark 3:44a200543540 84 void automate(void);
kyxstark 3:44a200543540 85
kyxstark 3:44a200543540 86 gobeur_order_t _order;
kyxstark 3:44a200543540 87 state_gobeur_t _state;
kyxstark 3:44a200543540 88 Servo* _turbine;
kyxstark 3:44a200543540 89 Servo* _servo;
kyxstark 3:44a200543540 90
kyxstark 3:44a200543540 91 float _turbine_on;
kyxstark 3:44a200543540 92 float _turbine_off;
kyxstark 3:44a200543540 93 float _servo_open;
kyxstark 3:44a200543540 94 float _servo_close;
kyxstark 3:44a200543540 95
kyxstark 3:44a200543540 96
kyxstark 3:44a200543540 97
kyxstark 3:44a200543540 98 float _time;
kyxstark 3:44a200543540 99 };
mondiaye 0:7312173b8d5f 100 #endif