14static EHandSide StringToHandside(std::string &str) {
18 else if (str ==
"RIGHT") {
32static std::string HandsideToString(
EHandSide hs) {
50static EActuationPoint StringToActuationPoint(std::string& str) {
52 return EActuationPoint::Thumb;
54 else if (str ==
"INDEX") {
55 return EActuationPoint::Index;
57 else if (str ==
"MIDDLE") {
58 return EActuationPoint::Middle;
60 else if (str ==
"PALM") {
61 return EActuationPoint::Palm;
65 return EActuationPoint::Thumb;
74static std::string ActuationPointToString(EActuationPoint ap) {
75 if (ap == EActuationPoint::Thumb) {
78 else if (ap == EActuationPoint::Index) {
81 else if (ap == EActuationPoint::Middle) {
84 else if (ap == EActuationPoint::Palm) {
98static TrackingType StringToTrackingType(
const std::string& str) {
99 if (str ==
"TrackType1")
100 return TrackingType::WEART_HAND;
101 return TrackingType::DEFAULT;
109static std::string TrackingTypeToString(TrackingType trackType) {
111 case TrackingType::DEFAULT:
113 case TrackingType::WEART_HAND:
129 return"DISCONNECTED";
139 return"UPLOADING_TEXTURES";
141 return"CONNECTING_DEVICE";
155 if (str ==
"DISCONNECTED")
159 if (str ==
"STARTING")
161 if (str ==
"RUNNING")
163 if (str ==
"STOPPING")
165 if (str ==
"UPLOADING_TEXTURES")
167 if (str ==
"CONNECTING_DEVICE")
169 if (str ==
"CALIBRATION")
195 const char field_separator =
':';
197 virtual std::vector<std::string> getValues() = 0;
198 virtual void setValues(std::vector<std::string>& values) = 0;
200 virtual std::string
serialize()
override;
201 virtual void deserialize(std::string message)
override;
209 virtual std::string
serialize()
override;
210 virtual void deserialize(std::string message)
override;
211 std::uint64_t timestamp() {
return _timestamp; }
217 virtual nlohmann::json serializePayload() {
return nlohmann::json(); }
218 virtual void deserializePayload(nlohmann::json payload) {}
219 std::uint64_t _timestamp;
232 virtual std::vector<std::string>
getValues()
override {
return std::vector<std::string>(); };
233 virtual void setValues(std::vector<std::string>& values)
override {};
256 static constexpr const char*
ID =
"StartFromClient";
258 virtual std::string
getID()
override {
return ID; };
261 std::vector<std::string> ret;
262 if (_trackType != TrackingType::DEFAULT) {
270 virtual void setValues(std::vector<std::string>& values)
override {
272 _trackType = TrackingType::DEFAULT;
274 _trackType = StringToTrackingType(values[2]);
278 TrackingType _trackType;
287 static constexpr const char*
ID =
"StopFromClient";
289 virtual std::string
getID()
override {
return ID; };
299 static constexpr const char*
ID =
"StartCalibration";
301 virtual std::string
getID()
override {
return ID; };
310 static constexpr const char*
ID =
"StopCalibration";
312 virtual std::string
getID()
override {
return ID; };
321 static constexpr const char*
ID =
"exit";
323 virtual std::string
getID()
override {
return ID; };
332 static constexpr const char*
ID =
"disconnect";
334 virtual std::string
getID()
override {
return ID; };
346 static constexpr const char*
ID =
"temperature";
348 virtual std::string
getID()
override {
return ID; };
351 std::vector<std::string> ret;
353 ret.push_back(HandsideToString(
handSide));
358 virtual void setValues(std::vector<std::string>& values)
override {
359 assert(values.size() == 3);
361 handSide = StringToHandside(values[1]);
378 static constexpr const char*
ID =
"stopTemperature";
380 virtual std::string
getID()
override {
return ID; };
383 std::vector<std::string> ret;
384 ret.push_back(HandsideToString(
handSide));
389 virtual void setValues(std::vector<std::string>& values)
override {
390 assert(values.size() == 2);
391 handSide = StringToHandside(values[0]);
406 static constexpr const char*
ID =
"force";
408 virtual std::string
getID()
override {
return ID; };
411 std::vector<std::string> ret;
412 ret.push_back(std::to_string(
force[0]));
413 ret.push_back(std::to_string(
force[1]));
414 ret.push_back(std::to_string(
force[2]));
415 ret.push_back(HandsideToString(
handSide));
420 virtual void setValues(std::vector<std::string>& values)
override {
421 assert(values.size() == 5);
422 force[0] = std::stof(values[0]);
423 force[1] = std::stof(values[1]);
424 force[2] = std::stof(values[2]);
425 handSide = StringToHandside(values[3]);
442 static constexpr const char*
ID =
"stopForce";
444 virtual std::string
getID()
override {
return ID; };
447 std::vector<std::string> ret;
448 ret.push_back(HandsideToString(
handSide));
453 virtual void setValues(std::vector<std::string>& values)
override {
454 assert(values.size() == 2);
455 handSide = StringToHandside(values[0]);
470 static constexpr const char*
ID =
"texture";
472 virtual std::string
getID()
override {
return ID; };
475 std::vector<std::string> ret;
482 ret.push_back(std::to_string(
index));
483 ret.push_back(std::to_string(
velocity[0]));
484 ret.push_back(std::to_string(
velocity[1]));
485 ret.push_back(std::to_string(
velocity[2]));
486 ret.push_back(std::to_string(
volume));
487 ret.push_back(HandsideToString(
handSide));
492 virtual void setValues(std::vector<std::string>& values)
override {
493 assert(values.size() == 6);
494 index = std::stoi(values[0]);
498 volume = std::stof(values[4]);
499 handSide = StringToHandside(values[5]);
518 static constexpr const char*
ID =
"stopTexture";
520 virtual std::string
getID()
override {
return ID; };
523 std::vector<std::string> ret;
524 ret.push_back(HandsideToString(
handSide));
529 virtual void setValues(std::vector<std::string>& values)
override {
530 assert(values.size() == 2);
531 handSide = StringToHandside(values[0]);
542 uint8 RightThumbClosure;
543 uint8 RightIndexClosure;
544 uint8 RightMiddleClosure;
545 uint8 RightPalmClosure;
546 uint8 LeftThumbClosure;
547 uint8 LeftIndexClosure;
548 uint8 LeftMiddleClosure;
549 uint8 LeftPalmClosure;
552 uint8 RightThumbAbduction;
553 uint8 LeftThumbAbduction;
555 TrackingType _trackingType;
560 static constexpr const char*
ID =
"Tracking";
562 virtual std::string
getID()
override {
return ID; };
571 std::vector<std::string> ret;
572 ret.push_back(std::to_string(RightThumbClosure));
573 ret.push_back(std::to_string(RightIndexClosure));
574 ret.push_back(std::to_string(RightMiddleClosure));
575 ret.push_back(std::to_string(RightPalmClosure));
576 ret.push_back(std::to_string(LeftThumbClosure));
577 ret.push_back(std::to_string(LeftIndexClosure));
578 ret.push_back(std::to_string(LeftMiddleClosure));
579 ret.push_back(std::to_string(LeftPalmClosure));
583 virtual void setValues(std::vector<std::string>& values)
override {
584 _trackingType = StringToTrackingType(values[0]);
585 switch (_trackingType) {
586 case TrackingType::DEFAULT:
588 assert(values.size() == 8);
589 RightThumbClosure = std::stoi(values[0]);
590 RightIndexClosure = std::stoi(values[1]);
591 RightMiddleClosure = std::stoi(values[2]);
592 RightPalmClosure = std::stoi(values[3]);
593 LeftThumbClosure = std::stoi(values[4]);
594 LeftIndexClosure = std::stoi(values[5]);
595 LeftMiddleClosure = std::stoi(values[6]);
596 LeftPalmClosure = std::stoi(values[7]);
599 case TrackingType::WEART_HAND:
601 assert(values.size() == 9);
603 RightIndexClosure = std::stoi(values[1]);
604 RightThumbClosure = std::stoi(values[2]);
605 RightThumbAbduction = std::stoi(values[3]);
606 RightMiddleClosure = std::stoi(values[4]);
609 LeftIndexClosure = std::stoi(values[5]);
610 LeftThumbClosure = std::stoi(values[6]);
611 LeftThumbAbduction = std::stoi(values[7]);
612 LeftMiddleClosure = std::stoi(values[8]);
618 uint8 byteValue = 0x00;
621 case EHandSide::Left:
622 switch (actuationPoint)
624 case EActuationPoint::Thumb: byteValue = LeftThumbClosure;
break;
625 case EActuationPoint::Index: byteValue = LeftIndexClosure;
break;
626 case EActuationPoint::Middle: byteValue = LeftMiddleClosure;
break;
627 case EActuationPoint::Palm: byteValue = LeftPalmClosure;
break;
630 case EHandSide::Right:
631 switch (actuationPoint)
633 case EActuationPoint::Thumb: byteValue = RightThumbClosure;
break;
634 case EActuationPoint::Index: byteValue = RightIndexClosure;
break;
635 case EActuationPoint::Middle: byteValue = RightMiddleClosure;
break;
636 case EActuationPoint::Palm: byteValue = RightPalmClosure;
break;
641 float num(byteValue);
647 float maxAbductionValue = 255;
649 case EHandSide::Left:
650 if (actuationPoint == EActuationPoint::Thumb)
return ((
float)LeftThumbAbduction) / maxAbductionValue;
652 case EHandSide::Right:
653 if (actuationPoint == EActuationPoint::Thumb)
return ((
float)RightThumbAbduction) / maxAbductionValue;
661class RawDataOn :
public WeArtJsonMessage {
663 static constexpr const char* ID =
"RAW_DATA_ON";
665 virtual std::string getID()
override {
return ID; }
666 virtual void setHandSide(
EHandSide hs)
override {}
667 virtual void setActuationPoint(EActuationPoint ap)
override {}
671class RawDataOff :
public WeArtJsonMessage {
673 static constexpr const char* ID =
"RAW_DATA_OFF";
675 virtual std::string getID()
override {
return ID; }
676 virtual void setHandSide(
EHandSide hs)
override {}
677 virtual void setActuationPoint(EActuationPoint ap)
override {}
681class RawSensorsData :
public WeArtJsonMessage {
683 static constexpr const char* ID =
"RAW_DATA";
685 virtual std::string getID()
override {
return ID; };
686 virtual void setHandSide(
EHandSide hs)
override { hand = hs; }
687 virtual void setActuationPoint(EActuationPoint ap)
override {}
690 bool hasSensor(EActuationPoint ap);
694 virtual nlohmann::json serializePayload()
override;
695 virtual void deserializePayload(nlohmann::json payload)
override;
698 std::map<EActuationPoint, SensorData> sensors;
702class GetMiddlewareStatus :
public WeArtJsonMessage {
704 GetMiddlewareStatus() : WeArtJsonMessage() {}
706 static constexpr const char* ID =
"MW_GET_STATUS";
707 virtual std::string getID()
override {
return ID; };
711class MiddlewareStatusMessage :
public WeArtJsonMessage {
713 MiddlewareStatusMessage() : WeArtJsonMessage() {}
715 static constexpr const char* ID =
"MW_STATUS";
716 virtual std::string getID()
override {
return ID; };
721 virtual nlohmann::json serializePayload()
override;
722 virtual void deserializePayload(nlohmann::json payload)
override;
729class GetDevicesStatusMessage :
public WeArtJsonMessage {
731 GetDevicesStatusMessage() : WeArtJsonMessage() {}
732 static constexpr const char* ID =
"DEVICES_GET_STATUS";
733 virtual std::string getID()
override {
return ID; };
737class DevicesStatusMessage :
public WeArtJsonMessage {
739 DevicesStatusMessage() : WeArtJsonMessage() {}
741 static constexpr const char* ID =
"DEVICES_STATUS";
742 virtual std::string getID()
override {
return ID; };
744 std::vector<ConnectedDeviceStatus> devices() {
return _devices; }
747 virtual nlohmann::json serializePayload()
override;
748 virtual void deserializePayload(nlohmann::json payload)
override;
751 std::vector<ConnectedDeviceStatus> _devices;
MiddlewareStatus
Definition: WeArtCommon.h:56
EHandSide
Definition: WeArtCommon.h:8
@ Left
Definition: WeArtCommon.h:10
@ Right
Definition: WeArtCommon.h:11
Message to the middleware to disconnect.
Definition: WeArtMessages.h:329
virtual std::string getID() override
Definition: WeArtMessages.h:334
static constexpr const char * ID
Definition: WeArtMessages.h:332
Message to the middleware to exit the connection.
Definition: WeArtMessages.h:318
static constexpr const char * ID
Definition: WeArtMessages.h:321
virtual std::string getID() override
Definition: WeArtMessages.h:323
Message to the middleware to set the force of the effect.
Definition: WeArtMessages.h:400
float force[3]
Definition: WeArtMessages.h:431
virtual std::vector< std::string > getValues() override
Definition: WeArtMessages.h:410
static constexpr const char * ID
Definition: WeArtMessages.h:406
SetForceMessage()
Definition: WeArtMessages.h:404
SetForceMessage(const float f[3])
Definition: WeArtMessages.h:403
virtual void setValues(std::vector< std::string > &values) override
Definition: WeArtMessages.h:420
virtual std::string getID() override
Definition: WeArtMessages.h:408
Message to the middleware to set the temperature of the effect.
Definition: WeArtMessages.h:341
float temperature
Definition: WeArtMessages.h:367
virtual std::vector< std::string > getValues() override
Definition: WeArtMessages.h:350
SetTemperatureMessage()
Definition: WeArtMessages.h:344
virtual void setValues(std::vector< std::string > &values) override
Definition: WeArtMessages.h:358
SetTemperatureMessage(const float t)
Definition: WeArtMessages.h:343
virtual std::string getID() override
Definition: WeArtMessages.h:348
static constexpr const char * ID
Definition: WeArtMessages.h:346
Message to the middleware to set the texture of the effect.
Definition: WeArtMessages.h:464
float velocity[3]
Definition: WeArtMessages.h:506
float volume
Definition: WeArtMessages.h:507
virtual void setValues(std::vector< std::string > &values) override
Definition: WeArtMessages.h:492
static constexpr const char * ID
Definition: WeArtMessages.h:470
SetTextureMessage()
Definition: WeArtMessages.h:468
virtual std::string getID() override
Definition: WeArtMessages.h:472
SetTextureMessage(const int idx, const float vel[3], const float vol)
Definition: WeArtMessages.h:467
int index
Definition: WeArtMessages.h:505
virtual std::vector< std::string > getValues() override
Definition: WeArtMessages.h:474
Message to the middleware to start the calibration.
Definition: WeArtMessages.h:296
static constexpr const char * ID
Definition: WeArtMessages.h:299
virtual std::string getID() override
Definition: WeArtMessages.h:301
Message to middleware to start the connection.
Definition: WeArtMessages.h:252
virtual std::vector< std::string > getValues() override
Definition: WeArtMessages.h:260
virtual void setValues(std::vector< std::string > &values) override
Definition: WeArtMessages.h:270
virtual std::string getID() override
Definition: WeArtMessages.h:258
static constexpr const char * ID
Definition: WeArtMessages.h:256
Message to the middleware to stop the calibration.
Definition: WeArtMessages.h:307
virtual std::string getID() override
Definition: WeArtMessages.h:312
static constexpr const char * ID
Definition: WeArtMessages.h:310
Message to the middleware to stop the temperature of the effect.
Definition: WeArtMessages.h:438
static constexpr const char * ID
Definition: WeArtMessages.h:442
virtual std::string getID() override
Definition: WeArtMessages.h:444
virtual std::vector< std::string > getValues() override
Definition: WeArtMessages.h:446
virtual void setValues(std::vector< std::string > &values) override
Definition: WeArtMessages.h:453
Message to middleware to stop the connection.
Definition: WeArtMessages.h:284
virtual std::string getID() override
Definition: WeArtMessages.h:289
static constexpr const char * ID
Definition: WeArtMessages.h:287
Message to the middleware to stop the temperature of the effect.
Definition: WeArtMessages.h:374
virtual void setValues(std::vector< std::string > &values) override
Definition: WeArtMessages.h:389
virtual std::string getID() override
Definition: WeArtMessages.h:380
static constexpr const char * ID
Definition: WeArtMessages.h:378
virtual std::vector< std::string > getValues() override
Definition: WeArtMessages.h:382
Message to the middleware to stop the texture of the effect.
Definition: WeArtMessages.h:514
virtual std::vector< std::string > getValues() override
Definition: WeArtMessages.h:522
static constexpr const char * ID
Definition: WeArtMessages.h:518
virtual std::string getID() override
Definition: WeArtMessages.h:520
virtual void setValues(std::vector< std::string > &values) override
Definition: WeArtMessages.h:529
Generic Tracking message, contains information on closure and abduction (based on tracking type)
Definition: WeArtMessages.h:540
static constexpr const char * ID
Definition: WeArtMessages.h:560
virtual std::vector< std::string > getValues() override
Definition: WeArtMessages.h:570
float GetAbduction(EHandSide handSide, EActuationPoint actuationPoint)
Definition: WeArtMessages.h:646
float GetClosure(EHandSide handSide, EActuationPoint actuationPoint)
Definition: WeArtMessages.h:617
virtual std::string getID() override
Definition: WeArtMessages.h:562
virtual void setValues(std::vector< std::string > &values) override
Definition: WeArtMessages.h:583
Generic Weart message.
Definition: WeArtMessages.h:178
virtual void setHandSide(EHandSide hs)=0
virtual std::string getID()=0
virtual void deserialize(std::string message)=0
virtual std::string serialize()=0
virtual void setActuationPoint(EActuationPoint ap)=0
Message without handside or actuation point parameters.
Definition: WeArtMessages.h:225
virtual std::vector< std::string > getValues() override
Definition: WeArtMessages.h:232
virtual void setActuationPoint(EActuationPoint ap) override
Definition: WeArtMessages.h:229
virtual void setHandSide(EHandSide hs) override
Definition: WeArtMessages.h:228
virtual void setValues(std::vector< std::string > &values) override
Definition: WeArtMessages.h:233
Message without handside or actuation point parameters.
Definition: WeArtMessages.h:239
virtual void setHandSide(EHandSide hs) override
Definition: WeArtMessages.h:245
EHandSide handSide
Definition: WeArtMessages.h:242
EActuationPoint actuationPoint
Definition: WeArtMessages.h:243
virtual void setActuationPoint(EActuationPoint ap) override
Definition: WeArtMessages.h:246
const int nullTextureIndex
Definition: WeArtCommon.h:201
const int maxTextureIndex
Definition: WeArtCommon.h:200
const std::string WEART_SDK_TRACK_TYPE
Definition: WeArtCommon.h:182
const std::string WEART_SDK_VERSION
Definition: WeArtCommon.h:181
const std::string WEART_SDK_TYPE
Definition: WeArtCommon.h:180
Definition: WeArtCommon.h:110
Definition: WeArtCommon.h:97
Definition: WeArtMessages.h:564
float Y
Definition: WeArtMessages.h:566
float Z
Definition: WeArtMessages.h:567
float X
Definition: WeArtMessages.h:565