gestion de servomoteur individuelement, et du message ROS associe
Dependents: stm32_actuator_gobeur
Manche_a_air.h@5:04d111f63a0f, 2021-07-08 (annotated)
- Committer:
- kyxstark
- Date:
- Thu Jul 08 22:46:14 2021 +0000
- Revision:
- 5:04d111f63a0f
- Parent:
- 4:de7ca80dbe4b
peut de modif
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
kyxstark | 3:40988c59e571 | 1 | #ifndef _ROS_stm32_manche_a_air_Manche_a_air_h |
kyxstark | 3:40988c59e571 | 2 | #define _ROS_stm32_manche_a_air_Manche_a_air_h |
kyxstark | 3:40988c59e571 | 3 | |
kyxstark | 3:40988c59e571 | 4 | #include <stdint.h> |
kyxstark | 3:40988c59e571 | 5 | #include <string.h> |
kyxstark | 3:40988c59e571 | 6 | #include <stdlib.h> |
kyxstark | 3:40988c59e571 | 7 | #include <Servo.h> |
kyxstark | 3:40988c59e571 | 8 | #include "../actuators.h" |
kyxstark | 3:40988c59e571 | 9 | #include "ros/msg.h" |
kyxstark | 3:40988c59e571 | 10 | |
kyxstark | 3:40988c59e571 | 11 | |
kyxstark | 3:40988c59e571 | 12 | #define MAA_CLOSING_TIMEOUT 1 |
kyxstark | 3:40988c59e571 | 13 | #define MAA_OPENING_TIMEOUT 1 |
kyxstark | 3:40988c59e571 | 14 | #define MAA_PAUSE_TIMEOUT 1 |
kyxstark | 3:40988c59e571 | 15 | |
kyxstark | 3:40988c59e571 | 16 | |
kyxstark | 3:40988c59e571 | 17 | |
kyxstark | 5:04d111f63a0f | 18 | namespace stm32_actuators_node |
kyxstark | 3:40988c59e571 | 19 | { |
kyxstark | 3:40988c59e571 | 20 | |
kyxstark | 3:40988c59e571 | 21 | class Manche_a_air_msg : public ros::Msg |
kyxstark | 3:40988c59e571 | 22 | { |
kyxstark | 3:40988c59e571 | 23 | public: |
kyxstark | 3:40988c59e571 | 24 | typedef uint8_t _index_manche_a_air_type; |
kyxstark | 3:40988c59e571 | 25 | _index_manche_a_air_type index_manche_a_air; |
kyxstark | 3:40988c59e571 | 26 | typedef uint8_t _manche_a_air_order_type; |
kyxstark | 3:40988c59e571 | 27 | _manche_a_air_order_type manche_a_air_order; |
kyxstark | 3:40988c59e571 | 28 | |
kyxstark | 3:40988c59e571 | 29 | Manche_a_air_msg(): |
kyxstark | 3:40988c59e571 | 30 | index_manche_a_air(0), |
kyxstark | 3:40988c59e571 | 31 | manche_a_air_order(0) |
kyxstark | 3:40988c59e571 | 32 | { |
kyxstark | 3:40988c59e571 | 33 | } |
kyxstark | 3:40988c59e571 | 34 | |
kyxstark | 3:40988c59e571 | 35 | virtual int serialize(unsigned char *outbuffer) const |
kyxstark | 3:40988c59e571 | 36 | { |
kyxstark | 3:40988c59e571 | 37 | int offset = 0; |
kyxstark | 3:40988c59e571 | 38 | *(outbuffer + offset + 0) = (this->index_manche_a_air >> (8 * 0)) & 0xFF; |
kyxstark | 3:40988c59e571 | 39 | offset += sizeof(this->index_manche_a_air); |
kyxstark | 3:40988c59e571 | 40 | *(outbuffer + offset + 0) = (this->manche_a_air_order >> (8 * 0)) & 0xFF; |
kyxstark | 3:40988c59e571 | 41 | offset += sizeof(this->manche_a_air_order); |
kyxstark | 3:40988c59e571 | 42 | return offset; |
kyxstark | 3:40988c59e571 | 43 | } |
kyxstark | 3:40988c59e571 | 44 | |
kyxstark | 3:40988c59e571 | 45 | virtual int deserialize(unsigned char *inbuffer) |
kyxstark | 3:40988c59e571 | 46 | { |
kyxstark | 3:40988c59e571 | 47 | int offset = 0; |
kyxstark | 3:40988c59e571 | 48 | this->index_manche_a_air = ((uint8_t) (*(inbuffer + offset))); |
kyxstark | 3:40988c59e571 | 49 | offset += sizeof(this->index_manche_a_air); |
kyxstark | 3:40988c59e571 | 50 | this->manche_a_air_order = ((uint8_t) (*(inbuffer + offset))); |
kyxstark | 3:40988c59e571 | 51 | offset += sizeof(this->manche_a_air_order); |
kyxstark | 3:40988c59e571 | 52 | return offset; |
kyxstark | 3:40988c59e571 | 53 | } |
kyxstark | 3:40988c59e571 | 54 | |
kyxstark | 5:04d111f63a0f | 55 | const char * getType(){ return "stm32_actuators/Manche_a_air_msg"; }; |
kyxstark | 4:de7ca80dbe4b | 56 | const char * getMD5(){ return "33a9b4e076016e58fe35593be08a2827"; }; |
kyxstark | 3:40988c59e571 | 57 | |
kyxstark | 3:40988c59e571 | 58 | }; |
kyxstark | 3:40988c59e571 | 59 | |
kyxstark | 3:40988c59e571 | 60 | } |
kyxstark | 3:40988c59e571 | 61 | |
kyxstark | 3:40988c59e571 | 62 | |
kyxstark | 5:04d111f63a0f | 63 | void maa_trait_msg(const stm32_actuators_node::Manche_a_air_msg& manche_a_air_msg); |
kyxstark | 3:40988c59e571 | 64 | |
kyxstark | 3:40988c59e571 | 65 | |
kyxstark | 3:40988c59e571 | 66 | |
kyxstark | 3:40988c59e571 | 67 | class Manche_a_air |
kyxstark | 3:40988c59e571 | 68 | { |
kyxstark | 3:40988c59e571 | 69 | public: |
kyxstark | 3:40988c59e571 | 70 | |
kyxstark | 4:de7ca80dbe4b | 71 | typedef enum |
kyxstark | 3:40988c59e571 | 72 | {closed, opening, opened, closing} |
kyxstark | 3:40988c59e571 | 73 | state_manche_a_air_t; |
kyxstark | 3:40988c59e571 | 74 | |
kyxstark | 3:40988c59e571 | 75 | typedef enum |
kyxstark | 3:40988c59e571 | 76 | {close, open} |
kyxstark | 3:40988c59e571 | 77 | manche_a_air_order_t; |
kyxstark | 3:40988c59e571 | 78 | |
kyxstark | 3:40988c59e571 | 79 | Manche_a_air(PinName pin_servo, float servo_open, float servo_close); |
kyxstark | 3:40988c59e571 | 80 | |
kyxstark | 3:40988c59e571 | 81 | void update_order(int order); |
kyxstark | 3:40988c59e571 | 82 | void automate(void); |
kyxstark | 3:40988c59e571 | 83 | |
kyxstark | 3:40988c59e571 | 84 | manche_a_air_order_t _order; |
kyxstark | 3:40988c59e571 | 85 | state_manche_a_air_t _state; |
kyxstark | 3:40988c59e571 | 86 | Servo* _servo; |
kyxstark | 3:40988c59e571 | 87 | |
kyxstark | 3:40988c59e571 | 88 | float _servo_open; |
kyxstark | 3:40988c59e571 | 89 | float _servo_close; |
kyxstark | 3:40988c59e571 | 90 | |
kyxstark | 3:40988c59e571 | 91 | float _time; |
kyxstark | 3:40988c59e571 | 92 | |
kyxstark | 3:40988c59e571 | 93 | int _flag_auto_open; |
kyxstark | 3:40988c59e571 | 94 | int _flag_auto_close; |
kyxstark | 3:40988c59e571 | 95 | float _timeout_auto_open; |
kyxstark | 3:40988c59e571 | 96 | float _timeout_auto_close; |
kyxstark | 3:40988c59e571 | 97 | |
kyxstark | 3:40988c59e571 | 98 | void set_auto_open(int flag, float timeout); |
kyxstark | 3:40988c59e571 | 99 | void set_auto_close(int flag, float timeout); |
kyxstark | 3:40988c59e571 | 100 | |
kyxstark | 3:40988c59e571 | 101 | }; |
kyxstark | 3:40988c59e571 | 102 | #endif |