Low-Level C++ SDK  v1.1
Loading...
Searching...
No Matches
WeArtMessages.h
Go to the documentation of this file.
1
2#pragma once
3
4#include "WeArtCommon.h"
5#include <string>
6#include <vector>
7#include <cassert>
8
9// Utility Methods, called to serialize/deserialize types
10HandSide StringToHandside(std::string& str);
11
12std::string HandsideToString(HandSide hs);
13
15
17
19
21
22TrackingType StringToTrackingType(const std::string& str);
23
24std::string TrackingTypeToString(TrackingType trackType);
25
28class WeArtMessage {
29public:
32 virtual std::string getID() = 0;
33 virtual std::vector<std::string> getValues() = 0;
34 virtual void setValues(std::vector<std::string>& values) = 0;
35
38 virtual void setHandSide(HandSide hs) = 0;
39
42 virtual void setActuationPoint(ActuationPoint ap) = 0;
43};
44
45
48class WeArtMessageNoParams : public WeArtMessage {
49public:
50 virtual void setHandSide(HandSide hs) override {};
51 virtual void setActuationPoint(ActuationPoint ap) override {};
52
53 // This message carries no values.
54 virtual std::vector<std::string> getValues() override {
55 return std::vector<std::string>();
56 };
57 virtual void setValues(std::vector<std::string>& values) override {};
58};
59
62class WeArtMessageHandSpecific : public WeArtMessage {
63public:
64 HandSide getHand() {
65 return handSide;
66 }
67protected:
68 HandSide handSide;
69public:
70 virtual void setHandSide(HandSide hs) override {
71 handSide = hs;
72 };
73 virtual void setActuationPoint(ActuationPoint ap) override {};
74};
75
78class WeArtMessageObjectSpecific : public WeArtMessage {
79public:
80 HandSide getHand() {
81 return handSide;
82 }
83
84 virtual void setHandSide(HandSide hs) override {
85 handSide = hs;
86 };
87
88 ActuationPoint getActuationPoint() {
89 return actuationPoint;
90 }
91
92 virtual void setActuationPoint(ActuationPoint ap) override {
93 actuationPoint = ap;
94 };
95
96
97protected:
98 HandSide handSide;
99 ActuationPoint actuationPoint;
100};
101
102
104class StartFromClientMessage : public WeArtMessageNoParams {
105public:
106 static constexpr const char* ID = "StartFromClient";
107
108 StartFromClientMessage(TrackingType trackType = TrackingType::WEART_HAND) : _trackType(trackType) {}
109
110 virtual std::string getID() override {
111 return ID;
112 };
113
114 virtual std::vector<std::string> getValues() override;
115 virtual void setValues(std::vector<std::string>& values) override;
116private:
117 TrackingType _trackType;
118};
119
121class StopFromClientMessage : public WeArtMessageNoParams {
122public:
123 static constexpr const char* ID = "StopFromClient";
124
125 virtual std::string getID() override {
126 return ID;
127 };
128};
129
131class StartCalibrationMessage : public WeArtMessageNoParams {
132public:
133 static constexpr const char* ID = "StartCalibration";
134
135 virtual std::string getID() override {
136 return ID;
137 }
138};
139
141class StopCalibrationMessage : public WeArtMessageNoParams {
142public:
143 static constexpr const char* ID = "StopCalibration";
144
145 virtual std::string getID() override {
146 return ID;
147 }
148};
149
151class CalibrationStatusMessage : public WeArtMessageHandSpecific {
152public:
153 static constexpr const char* ID = "CalibrationStatus";
154
155 virtual std::string getID() override {
156 return ID;
157 }
158
159 CalibrationStatus getStatus() {
160 return status;
161 }
162
163 virtual std::vector<std::string> getValues() override;
164
165 virtual void setValues(std::vector<std::string>& values) override;
166
167protected:
168 CalibrationStatus status;
169};
170
172class CalibrationResultMessage : public WeArtMessageHandSpecific {
173public:
174 static constexpr const char* ID = "CalibrationResult";
175
176 virtual std::string getID() override {
177 return ID;
178 }
179
180 bool getSuccess() {
181 return success;
182 }
183
184 virtual std::vector<std::string> getValues() override;
185
186 virtual void setValues(std::vector<std::string>& values) override;
187
188protected:
189 bool success;
190};
191
193class ExitMessage : public WeArtMessageNoParams {
194public:
195 static constexpr const char* ID = "exit";
196
197 virtual std::string getID() override {
198 return std::string("exit");
199 };
200};
201
203class DisconnectMessage : public WeArtMessageNoParams {
204public:
205 static constexpr const char* ID = "disconnect";
206
207 virtual std::string getID() override {
208 return ID;
209 };
210};
211
213class SetTemperatureMessage : public WeArtMessageObjectSpecific {
214public:
215 static constexpr const char* ID = "temperature";
216
217 SetTemperatureMessage(const float t) : temperature(t) {};
218 SetTemperatureMessage() {};
219 virtual std::string getID() override {
220 return ID;
221 };
222
223 virtual std::vector<std::string> getValues() override;
224
225 virtual void setValues(std::vector<std::string>& values) override;
226
227protected:
228 float temperature;
229};
230
232class StopTemperatureMessage : public WeArtMessageObjectSpecific {
233public:
234 static constexpr const char* ID = "stopTemperature";
235
236 virtual std::string getID() override {
237 return ID;
238 };
239
240 virtual std::vector<std::string> getValues() override;
241
242 virtual void setValues(std::vector<std::string>& values) override;
243};
244
246class SetForceMessage : public WeArtMessageObjectSpecific {
247public:
248 static constexpr const char* ID = "force";
249
250 SetForceMessage(const float f[3]) : force{ f[0], f[1], f[2] } {};
251 SetForceMessage() {};
252 virtual std::string getID() override {
253 return ID;
254 };
255
256 virtual std::vector<std::string> getValues() override;
257
258 virtual void setValues(std::vector<std::string>& values) override;
259
260protected:
261 float force[3];
262};
263
265class StopForceMessage : public WeArtMessageObjectSpecific {
266public:
267 static constexpr const char* ID = "stopForce";
268
269 virtual std::string getID() override {
270 return ID;
271 };
272
273 virtual std::vector<std::string> getValues() override;
274
275 virtual void setValues(std::vector<std::string>& values) override;
276};
277
279class SetTextureMessage : public WeArtMessageObjectSpecific {
280public:
281 static constexpr const char* ID = "texture";
282
283 SetTextureMessage(const int idx, const float vel, const float vol) : index(idx), velocity{ 0.5f, 0.0f, vel }, volume(vol) {};
284 SetTextureMessage() {};
285 virtual std::string getID() override {
286 return ID;
287 };
288
289 virtual std::vector<std::string> getValues() override;
290
291 virtual void setValues(std::vector<std::string>& values) override;
292
293protected:
294 int index;
295 float velocity[3] = { 0.5f, 0.0f, 0.0f };
296 float volume;
297};
298
300class StopTextureMessage : public WeArtMessageObjectSpecific {
301public:
302 static constexpr const char* ID = "stopTexture";
303
304 virtual std::string getID() override {
305 return ID;
306 };
307
308 virtual std::vector<std::string> getValues() override;
309
310 virtual void setValues(std::vector<std::string>& values) override;
311};
312
324class TrackingMessage : public WeArtMessageNoParams {
325public:
326 static constexpr const char* ID = "Tracking";
327
328 virtual std::string getID() override {
329 return std::string(ID);
330 };
331
332 struct Angles {
333 float X;
334 float Y;
335 float Z;
336 };
337
338 virtual std::vector<std::string> getValues() override;
339
340 virtual void setValues(std::vector<std::string>& values) override;
341
342 TrackingType GetType() {
343 return _trackingType;
344 }
345
350 float GetAbduction(HandSide handSide, ActuationPoint actuationPoint);
351
356 float GetClosure(HandSide handSide, ActuationPoint actuationPoint);
357private:
358 TrackingType _trackingType;
359
360 // Closures
361 uint8 RightThumbClosure;
362 uint8 RightIndexClosure;
363 uint8 RightMiddleClosure;
364 uint8 RightPalmClosure;
365 uint8 LeftThumbClosure;
366 uint8 LeftIndexClosure;
367 uint8 LeftMiddleClosure;
368 uint8 LeftPalmClosure;
369
370 // Abductions
371 uint8 RightThumbAbduction;
372 uint8 LeftThumbAbduction;
373};
CalibrationStatus
Definition: WeArtCommon.h:39
HandSide
Definition: WeArtCommon.h:11
TrackingType
Collection of constants used throughout the SDK.
Definition: WeArtCommon.h:6
ActuationPoint
Definition: WeArtCommon.h:18
HandSide StringToHandside(std::string &str)
Definition: WeArtMessages.cpp:5
std::string TrackingTypeToString(TrackingType trackType)
Definition: WeArtMessages.cpp:77
std::string HandsideToString(HandSide hs)
Definition: WeArtMessages.cpp:16
HandSide StringToCalibrationHandSide(std::string &str)
Definition: WeArtMessages.cpp:31
TrackingType StringToTrackingType(const std::string &str)
Definition: WeArtMessages.cpp:71
std::string CalibrationHandSideToString(HandSide hs)
Definition: WeArtMessages.cpp:27
std::string ActuationPointToString(ActuationPoint ap)
Definition: WeArtMessages.cpp:56
ActuationPoint StringToActuationPoint(std::string &str)
Definition: WeArtMessages.cpp:41
Definition: WeArtMessages.h:332
float Y
Definition: WeArtMessages.h:334
float Z
Definition: WeArtMessages.h:335
float X
Definition: WeArtMessages.h:333