mirror of
https://github.com/modelec/connectors.git
synced 2026-01-18 16:57:21 +01:00
63 lines
1.2 KiB
C++
63 lines
1.2 KiB
C++
#pragma once
|
|
|
|
#include <Modelec/TCPClient.h>
|
|
#include <Modelec/Utils.h>
|
|
|
|
#include <vector>
|
|
|
|
#include "serialib.h"
|
|
|
|
#define SERIAL_PORT "/dev/ttyACM0"
|
|
#define MAX_MESSAGE_LEN 1048
|
|
#define BAUDS 115200 //vitesse des données (bit/sec)
|
|
#define TIME_OUT 500
|
|
|
|
class MyTCPClient : public TCPClient {
|
|
|
|
public:
|
|
explicit MyTCPClient(const char* ip = "127.0.0.1", int port = 8080);
|
|
|
|
void handleMessage(const std::string &message) override;
|
|
|
|
void handleMessageFromArduino(const std::string& message);
|
|
|
|
void init();
|
|
|
|
void start() override;
|
|
|
|
void stop() override;
|
|
|
|
int write_2_arduino(const std::string& message);
|
|
|
|
void read_from_arduino();
|
|
|
|
private:
|
|
std::string serialPort = SERIAL_PORT;
|
|
int bauds = BAUDS;
|
|
int maxMessageLenght = MAX_MESSAGE_LEN;
|
|
int timeOut = TIME_OUT;
|
|
char buffer[MAX_MESSAGE_LEN] = "";
|
|
|
|
bool waitForResponse = false;
|
|
bool waitForPong = false;
|
|
|
|
bool isDoingSomething = false;
|
|
|
|
serialib serial;
|
|
|
|
struct Position {
|
|
struct {
|
|
int x;
|
|
int y;
|
|
} pos;
|
|
float theta;
|
|
} robotPose;
|
|
|
|
struct Transit {
|
|
int x;
|
|
int y;
|
|
int endSPeed;
|
|
bool waitingFor2 = false;
|
|
} transitMode;
|
|
};
|