hidaka sato / UsusamaSerial

Dependents:   ususama_serial_demo WRS2021_mecanum_driver

Revision:
1:33d6c6f43306
Child:
2:92e2ae1b1886
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/ususama_protocol.hpp	Mon Aug 23 17:02:24 2021 +0000
@@ -0,0 +1,63 @@
+#ifndef USUSAMA_PROTOCOL_H
+#define USUSAMA_PROTOCOL_H
+
+#include "mecanum_controller.hpp"
+//#include <vector>
+//#include <optional>
+
+static class UsusamaProtocol
+{
+    public:
+    struct MoveCommand_t
+    {
+        int x;
+        int y;
+        int theta;
+        bool enable;
+    };
+    struct MoveReply_t
+    {
+        bool valid;
+    };
+    struct StopCommand_t
+    {
+        bool stop;
+    };
+    struct StopReply_t
+    {
+        Pose2D pose;
+        bool is_stop;
+    };
+    
+    UsusamaProtocol()
+    {
+    }
+    
+    static int encode_float2int(float val)
+    {
+      return (int)(val * 1000);
+    }
+    static float decode_int2float(int val)
+    {
+      return (float)val / 1000;
+    }
+    
+    public:
+    static const uint8_t COMMAND_MOVE =        0x04;
+    static const uint8_t COMMAND_POSE_X =      0x05;
+    static const uint8_t COMMAND_POSE_Y =      0x06;
+    static const uint8_t COMMAND_POSE_THETA =  0x07;
+    
+    static const uint8_t COMMAND_STOP =        0x08;
+    
+    static const uint8_t REPLY_MOVE =          0x04;
+    static const uint8_t REPLY_POSE_X =        0x05;
+    static const uint8_t REPLY_POSE_Y =        0x06;
+    static const uint8_t REPLY_POSE_THETA =    0x07;
+    static const uint8_t REPLY_STOP =          0x08;
+    static const uint8_t REPLY_STATE_X = 0x010;
+    static const uint8_t REPLY_STATE_Y = 0x011;
+    static const uint8_t REPLY_STATE_THETA = 0x12;
+};
+
+#endif
\ No newline at end of file