36 virtual std::string getID() = 0;
40 virtual void setHandSide(
HandSide hs) = 0;
44 virtual void setActuationPoint(ActuationPoint ap) = 0;
46 virtual std::string serialize() = 0;
47 virtual void deserialize(std::string message) = 0;
51class WeArtCsvMessage :
public WeArtMessage {
53 const char field_separator =
':';
55 virtual std::vector<std::string> getValues() = 0;
56 virtual void setValues(std::vector<std::string>& values) = 0;
58 virtual std::string serialize()
override;
59 virtual void deserialize(std::string message)
override;
63class WeArtJsonMessage :
public WeArtMessage {
67 virtual std::string serialize()
override;
68 virtual void deserialize(std::string message)
override;
69 std::uint64_t timestamp() {
return _timestamp; }
71 virtual void setHandSide(
HandSide hs)
override {};
72 virtual void setActuationPoint(ActuationPoint ap)
override {};
75 virtual nlohmann::json serializePayload() {
return nlohmann::json(); }
76 virtual void deserializePayload(nlohmann::json payload) {}
77 std::uint64_t _timestamp;
83class WeArtMessageNoParams :
public WeArtCsvMessage {
85 virtual void setHandSide(
HandSide hs)
override {};
86 virtual void setActuationPoint(ActuationPoint ap)
override {};
89 virtual std::vector<std::string> getValues()
override {
90 return std::vector<std::string>();
92 virtual void setValues(std::vector<std::string>& values)
override {};
97class WeArtMessageHandSpecific :
public WeArtCsvMessage {
105 virtual void setHandSide(
HandSide hs)
override {
108 virtual void setActuationPoint(ActuationPoint ap)
override {};
113class WeArtMessageObjectSpecific :
public WeArtCsvMessage {
119 virtual void setHandSide(
HandSide hs)
override {
123 ActuationPoint getActuationPoint() {
124 return actuationPoint;
127 virtual void setActuationPoint(ActuationPoint ap)
override {
134 ActuationPoint actuationPoint;
139class StartFromClientMessage :
public WeArtMessageNoParams {
141 static constexpr const char* ID =
"StartFromClient";
143 StartFromClientMessage(
TrackingType trackType = TrackingType::WEART_HAND) : _trackType(trackType) {}
145 virtual std::string getID()
override {
149 virtual std::vector<std::string> getValues()
override;
150 virtual void setValues(std::vector<std::string>& values)
override;
156class StopFromClientMessage :
public WeArtMessageNoParams {
158 static constexpr const char* ID =
"StopFromClient";
160 virtual std::string getID()
override {
166class StartCalibrationMessage :
public WeArtMessageNoParams {
168 static constexpr const char* ID =
"StartCalibration";
170 virtual std::string getID()
override {
176class StopCalibrationMessage :
public WeArtMessageNoParams {
178 static constexpr const char* ID =
"StopCalibration";
180 virtual std::string getID()
override {
186class CalibrationStatusMessage :
public WeArtMessageHandSpecific {
188 static constexpr const char* ID =
"CalibrationStatus";
190 virtual std::string getID()
override {
198 virtual std::vector<std::string> getValues()
override;
200 virtual void setValues(std::vector<std::string>& values)
override;
207class CalibrationResultMessage :
public WeArtMessageHandSpecific {
209 static constexpr const char* ID =
"CalibrationResult";
211 virtual std::string getID()
override {
219 virtual std::vector<std::string> getValues()
override;
221 virtual void setValues(std::vector<std::string>& values)
override;
228class ExitMessage :
public WeArtMessageNoParams {
230 static constexpr const char* ID =
"exit";
232 virtual std::string getID()
override {
233 return std::string(
"exit");
238class DisconnectMessage :
public WeArtMessageNoParams {
240 static constexpr const char* ID =
"disconnect";
242 virtual std::string getID()
override {
248class SetTemperatureMessage :
public WeArtMessageObjectSpecific {
250 static constexpr const char* ID =
"temperature";
252 SetTemperatureMessage(
const float t) : temperature(t) {};
253 SetTemperatureMessage() {};
254 virtual std::string getID()
override {
258 virtual std::vector<std::string> getValues()
override;
260 virtual void setValues(std::vector<std::string>& values)
override;
267class StopTemperatureMessage :
public WeArtMessageObjectSpecific {
269 static constexpr const char* ID =
"stopTemperature";
271 virtual std::string getID()
override {
275 virtual std::vector<std::string> getValues()
override;
277 virtual void setValues(std::vector<std::string>& values)
override;
281class SetForceMessage :
public WeArtMessageObjectSpecific {
283 static constexpr const char* ID =
"force";
285 SetForceMessage(
const float f[3]) : force{ f[0], f[1], f[2] } {};
286 SetForceMessage() {};
287 virtual std::string getID()
override {
291 virtual std::vector<std::string> getValues()
override;
293 virtual void setValues(std::vector<std::string>& values)
override;
300class StopForceMessage :
public WeArtMessageObjectSpecific {
302 static constexpr const char* ID =
"stopForce";
304 virtual std::string getID()
override {
308 virtual std::vector<std::string> getValues()
override;
310 virtual void setValues(std::vector<std::string>& values)
override;
314class SetTextureMessage :
public WeArtMessageObjectSpecific {
316 static constexpr const char* ID =
"texture";
318 SetTextureMessage(
const int idx,
const float vel,
const float vol) : index(idx), velocity{ 0.5f, 0.0f, vel }, volume(vol) {};
319 SetTextureMessage() {};
320 virtual std::string getID()
override {
324 virtual std::vector<std::string> getValues()
override;
326 virtual void setValues(std::vector<std::string>& values)
override;
330 float velocity[3] = { 0.5f, 0.0f, 0.0f };
335class StopTextureMessage :
public WeArtMessageObjectSpecific {
337 static constexpr const char* ID =
"stopTexture";
339 virtual std::string getID()
override {
343 virtual std::vector<std::string> getValues()
override;
345 virtual void setValues(std::vector<std::string>& values)
override;
359class TrackingMessage :
public WeArtMessageNoParams {
361 static constexpr const char* ID =
"Tracking";
363 virtual std::string getID()
override {
364 return std::string(ID);
373 virtual std::vector<std::string> getValues()
override;
375 virtual void setValues(std::vector<std::string>& values)
override;
378 return _trackingType;
385 float GetAbduction(
HandSide handSide, ActuationPoint actuationPoint);
391 float GetClosure(
HandSide handSide, ActuationPoint actuationPoint);
396 uint8 RightThumbClosure;
397 uint8 RightIndexClosure;
398 uint8 RightMiddleClosure;
399 uint8 RightPalmClosure;
400 uint8 LeftThumbClosure;
401 uint8 LeftIndexClosure;
402 uint8 LeftMiddleClosure;
403 uint8 LeftPalmClosure;
406 uint8 RightThumbAbduction;
407 uint8 LeftThumbAbduction;
411class RawDataOn :
public WeArtJsonMessage {
413 static constexpr const char* ID =
"RAW_DATA_ON";
415 virtual std::string getID()
override {
return ID; }
416 virtual void setHandSide(
HandSide hs)
override {}
417 virtual void setActuationPoint(ActuationPoint ap)
override {}
421class RawDataOff :
public WeArtJsonMessage {
423 static constexpr const char* ID =
"RAW_DATA_OFF";
425 virtual std::string getID()
override {
return ID; }
426 virtual void setHandSide(
HandSide hs)
override {}
427 virtual void setActuationPoint(ActuationPoint ap)
override {}
431class RawSensorsData :
public WeArtJsonMessage {
433 static constexpr const char* ID =
"RAW_DATA";
435 virtual std::string getID()
override {
return ID; };
436 virtual void setHandSide(
HandSide hs)
override { hand = hs; }
437 virtual void setActuationPoint(ActuationPoint ap)
override {}
440 bool hasSensor(ActuationPoint ap);
444 virtual nlohmann::json serializePayload()
override;
445 virtual void deserializePayload(nlohmann::json payload)
override;
448 std::map<ActuationPoint, SensorData> sensors;
453class AnalogSensorsData :
public WeArtJsonMessage {
455 static constexpr const char* ID =
"RAW_SENSOR_ON_MASK";
457 virtual std::string getID()
override {
return ID; };
458 virtual void setHandSide(
HandSide hs)
override { hand = hs; }
459 virtual void setActuationPoint(ActuationPoint ap)
override {}
462 bool hasSensor(ActuationPoint ap);
466 virtual nlohmann::json serializePayload()
override;
467 virtual void deserializePayload(nlohmann::json payload)
override;
470 std::map<ActuationPoint, AnalogSensorRawData> sensors;
474class GetMiddlewareStatus :
public WeArtJsonMessage {
476 GetMiddlewareStatus() : WeArtJsonMessage() {}
478 static constexpr const char* ID =
"MW_GET_STATUS";
479 virtual std::string getID()
override {
return ID; };
483class MiddlewareStatusMessage :
public WeArtJsonMessage {
485 MiddlewareStatusMessage() : WeArtJsonMessage() {}
487 static constexpr const char* ID =
"MW_STATUS";
488 virtual std::string getID()
override {
return ID; };
493 virtual nlohmann::json serializePayload()
override;
494 virtual void deserializePayload(nlohmann::json payload)
override;
501class GetDevicesStatusMessage :
public WeArtJsonMessage {
503 GetDevicesStatusMessage() : WeArtJsonMessage() {}
504 static constexpr const char* ID =
"DEVICES_GET_STATUS";
505 virtual std::string getID()
override {
return ID; };
509class DevicesStatusMessage :
public WeArtJsonMessage {
511 DevicesStatusMessage() : WeArtJsonMessage() {}
513 static constexpr const char* ID =
"DEVICES_STATUS";
514 virtual std::string getID()
override {
return ID; };
516 std::vector<ConnectedDeviceStatus> devices() {
return _devices; }
519 virtual nlohmann::json serializePayload()
override;
520 virtual void deserializePayload(nlohmann::json payload)
override;
523 std::vector<ConnectedDeviceStatus> _devices;
CalibrationStatus
Definition: WeArtCommon.h:55
MiddlewareStatus
Definition: WeArtCommon.h:61
HandSide
Definition: WeArtCommon.h:17
TrackingType
Definition: WeArtCommon.h:12
HandSide StringToHandside(std::string &str)
Definition: WeArtMessages.cpp:7
std::string TrackingTypeToString(TrackingType trackType)
Definition: WeArtMessages.cpp:91
std::string HandsideToString(HandSide hs)
Definition: WeArtMessages.cpp:20
HandSide StringToCalibrationHandSide(std::string &str)
Definition: WeArtMessages.cpp:37
TrackingType StringToTrackingType(const std::string &str)
Definition: WeArtMessages.cpp:85
std::string MiddlewareStatusToString(MiddlewareStatus status)
Definition: WeArtMessages.cpp:101
std::string CalibrationHandSideToString(HandSide hs)
Definition: WeArtMessages.cpp:33
std::string ActuationPointToString(ActuationPoint ap)
Definition: WeArtMessages.cpp:66
ActuationPoint StringToActuationPoint(std::string &str)
Definition: WeArtMessages.cpp:47
Definition: WeArtCommon.h:130
Definition: WeArtCommon.h:144
Definition: WeArtCommon.h:123
Definition: WeArtMessages.h:367
float Y
Definition: WeArtMessages.h:369
float Z
Definition: WeArtMessages.h:370
float X
Definition: WeArtMessages.h:368