library for omnidirectional planar positioning system

Dependents:   measuring_wheel 2018NHK_gakugaku_robo 2018NHK_gaku_ver2

Committer:
takeuchi
Date:
Fri Aug 24 14:40:25 2018 +0900
Revision:
6:f8dbbe93bc7b
Parent:
5:f8c3aeb4e65f
Child:
7:73e542a88106
fix buffering

Who changed what in which revision?

UserRevisionLine numberNew contents of line
UCHITAKE 0:58910ef3f2b0 1 #ifndef OMNI_POSITION_H
UCHITAKE 0:58910ef3f2b0 2 #define OMNI_POSITION_H
UCHITAKE 0:58910ef3f2b0 3
UCHITAKE 0:58910ef3f2b0 4 #include "mbed.h"
takeuchi 6:f8dbbe93bc7b 5 #include <vector>
UCHITAKE 0:58910ef3f2b0 6
takeuchi 6:f8dbbe93bc7b 7 #define OP_SERIAL_BUFFER_SIZE 8
takeuchi 5:f8c3aeb4e65f 8 #define OP_HEADER_FIRST_BYTE 72
takeuchi 5:f8c3aeb4e65f 9 #define OP_HEADER_SECOND_BYTE 42
takeuchi 5:f8c3aeb4e65f 10 #define OP_RECEIVE_FREQ 0.05
takeuchi 5:f8c3aeb4e65f 11 #define OP_SEND_FREQ 0.1
takeuchi 5:f8c3aeb4e65f 12 #define OP_DEFAULT_BAUD 115200
takeuchi 1:0229fc98a26f 13
takeuchi 1:0229fc98a26f 14 class OmniPosition : public RawSerial {
UCHITAKE 0:58910ef3f2b0 15 public :
takeuchi 1:0229fc98a26f 16 OmniPosition(PinName serialTX, PinName serialRX);
takeuchi 2:edd33d3ad0fd 17
takeuchi 6:f8dbbe93bc7b 18 int16_t getX();
takeuchi 6:f8dbbe93bc7b 19 int16_t getY();
takeuchi 6:f8dbbe93bc7b 20 float getTheta();
takeuchi 2:edd33d3ad0fd 21
takeuchi 2:edd33d3ad0fd 22 void reset();
takeuchi 2:edd33d3ad0fd 23
UCHITAKE 0:58910ef3f2b0 24 private :
takeuchi 6:f8dbbe93bc7b 25 void receiveByte();
takeuchi 6:f8dbbe93bc7b 26 void assembleLoop();
takeuchi 1:0229fc98a26f 27 void assemble();
takeuchi 2:edd33d3ad0fd 28 void send();
takeuchi 1:0229fc98a26f 29
takeuchi 6:f8dbbe93bc7b 30 Thread thread;
takeuchi 6:f8dbbe93bc7b 31 std::vector<unsigned char> buf;
takeuchi 2:edd33d3ad0fd 32 Ticker sendTicker;
takeuchi 2:edd33d3ad0fd 33
takeuchi 6:f8dbbe93bc7b 34 int16_t X;
takeuchi 6:f8dbbe93bc7b 35 int16_t Y;
takeuchi 6:f8dbbe93bc7b 36 int16_t theta;
takeuchi 1:0229fc98a26f 37
takeuchi 2:edd33d3ad0fd 38 bool resetSend;
UCHITAKE 0:58910ef3f2b0 39 };
UCHITAKE 0:58910ef3f2b0 40
takeuchi 1:0229fc98a26f 41 #endif
takeuchi 4:fc4c88fffef8 42