-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathMyTCPClient.h
66 lines (44 loc) · 1.34 KB
/
MyTCPClient.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
#pragma once
#include "TCPSocket/TCPClient.hpp"
#include "TCPSocket/TCPUtils.hpp"
// #include "servo_motor.h"
#include <PiPCA9685/PCA9685.h>
#include <unistd.h>
#define SERVO_MIN 82 // 0.02*4096
#define SERVO_MAX 492 // 0.12*4096
#define PANO_HAUT 25
#define PANO_BAS 5
enum BrasState {
BRAS_BAS,
BRAS_HAUT,
BRAS_TRANSPORT
};
typedef struct {
int servo4;
int servo5;
}angleBras;
class MyTCPClient : public TCPClient {
public:
explicit MyTCPClient(const char* serverIP = "127.0.0.1", int port = 8080);
void handleMessage(const std::string &message) override;
void pwm_setFrequency(float freq);
void pwm_init();
void pwm_setServoPosition(int servo, int position);
// void baisser_bras(bool force = false);
void baisser_bras();
void transport_bras();
// void lever_bras(bool force = false);
void lever_bras();
void fermer_pince(int pince, bool force = false);
void ouvrir_pince(int pince, bool force = false);
void check_panneau(int quelBras);
void uncheck_panneau(int quelBras);
void pwm_clear();
private:
PiPCA9685::PCA9685 pca;
BrasState positionBras = BRAS_BAS;
bool pinceOuverte[3] = {true, true, true};
angleBras angleBrasBas = {180, 0};
angleBras angleBrasTransport = {168, 12};
angleBras angleBrasHaut = {53, 127};//78, 102
};