From 12c31c7e89a667dd1b6b0b2b271e8fb67efa34d7 Mon Sep 17 00:00:00 2001 From: Ehsan Ranjbari Date: Tue, 30 Jan 2024 13:36:13 +0100 Subject: [PATCH 01/14] adapt the device code to receive one haptic message from HapticGloveModule --- .gitignore | 2 + devices/HapticGlove/src/HapticGlove.cpp | 42 ++++++++++++++++++- .../Wearable/IWear/Actuators/IHaptic.h | 2 + msgs/thrift/WearableActuators.thrift | 5 ++- .../src/IWearActuatorsWrapper.cpp | 4 +- 5 files changed, 49 insertions(+), 6 deletions(-) diff --git a/.gitignore b/.gitignore index d88da75b..c57f9989 100644 --- a/.gitignore +++ b/.gitignore @@ -8,3 +8,5 @@ CMakeLists.txt.* *.autosave *.original *.*~ +.vscode/c_cpp_properties.json +.vscode/settings.json diff --git a/devices/HapticGlove/src/HapticGlove.cpp b/devices/HapticGlove/src/HapticGlove.cpp index 95fda51a..c35aafa4 100644 --- a/devices/HapticGlove/src/HapticGlove.cpp +++ b/devices/HapticGlove/src/HapticGlove.cpp @@ -305,6 +305,14 @@ bool HapticGlove::open(yarp::os::Searchable& config) m_pImpl->hapticActuatorPrefix = getWearableName() + actuator::IHaptic::getPrefix(); + for (size_t i = 0; i < m_pImpl->gloveData.humanFingerNames.size(); i++) { + m_pImpl->sensegloveHapticActuatorVector.push_back( + std::make_shared( + m_pImpl.get(), + m_pImpl->hapticActuatorPrefix + m_pImpl->gloveData.humanFingerNames[i] + + "::HapticFeedback")); + } + for (size_t i = 0; i < m_pImpl->gloveData.humanFingerNames.size(); i++) { m_pImpl->sensegloveHapticActuatorVector.push_back( std::make_shared( @@ -339,6 +347,12 @@ bool HapticGlove::open(yarp::os::Searchable& config) m_pImpl->gloveData.humanJointSensorNameIdMap.emplace( std::make_pair(m_pImpl->jointSensorPrefix + m_pImpl->gloveData.humanJointNames[i], i)); + for (size_t i = 0; i < m_pImpl->gloveData.humanFingerNames.size(); i++) + m_pImpl->gloveData.humanHapticActuatorNameIdMap.emplace( + std::make_pair(m_pImpl->hapticActuatorPrefix + m_pImpl->gloveData.humanFingerNames[i] + + "::HapticFeedback", + i)); + for (size_t i = 0; i < m_pImpl->gloveData.humanFingerNames.size(); i++) m_pImpl->gloveData.humanHapticActuatorNameIdMap.emplace( std::make_pair(m_pImpl->hapticActuatorPrefix + m_pImpl->gloveData.humanFingerNames[i] @@ -536,6 +550,24 @@ class HapticGlove::SenseGloveImpl::SenseGloveHapticActuator : public wearable::a ~SenseGloveHapticActuator() override = default; bool setHapticCommand(double& value) const override + { + + // std::lock_guard lock(m_gloveImpl->mutex); + + // if (!m_gloveImpl->isAvailable(m_actuatorName, + // m_gloveImpl->gloveData.humanHapticActuatorNameIdMap)) { + // yError() << LogPrefix << "The actuator name (" << m_actuatorName + // << ") is not found in the list of actuators."; + + // return false; + // } + // m_gloveImpl->gloveData.fingersHapticFeedback + // [m_gloveImpl->gloveData.humanHapticActuatorNameIdMap[m_actuatorName]] = value; + + return true; + } + + bool setHapticsCommand(double& forceValue, double& vibrotactileValue) const override { std::lock_guard lock(m_gloveImpl->mutex); @@ -547,12 +579,18 @@ class HapticGlove::SenseGloveImpl::SenseGloveHapticActuator : public wearable::a return false; } - m_gloveImpl->gloveData.fingersHapticFeedback - [m_gloveImpl->gloveData.humanHapticActuatorNameIdMap[m_actuatorName]] = value; + // m_gloveImpl->gloveData.fingersHapticFeedback + // [m_gloveImpl->gloveData.humanHapticActuatorNameIdMap[m_actuatorName]] = value; + + m_gloveImpl->gloveData.fingersHapticFeedback[ + m_gloveImpl->gloveData.humanHapticActuatorNameIdMap[m_actuatorName]] = forceValue; + m_gloveImpl->gloveData.fingersHapticFeedback[ + m_gloveImpl->gloveData.humanHapticActuatorNameIdMap[m_actuatorName] + 5] = vibrotactileValue; return true; } + inline void setStatus(const actuator::ActuatorStatus& status) { m_status = status; } private: diff --git a/interfaces/IWear/include/Wearable/IWear/Actuators/IHaptic.h b/interfaces/IWear/include/Wearable/IWear/Actuators/IHaptic.h index 9430b805..6bce2509 100644 --- a/interfaces/IWear/include/Wearable/IWear/Actuators/IHaptic.h +++ b/interfaces/IWear/include/Wearable/IWear/Actuators/IHaptic.h @@ -27,6 +27,8 @@ class wearable::actuator::IHaptic : public wearable::actuator::IActuator inline static const std::string getPrefix(); virtual bool setHapticCommand(double& value) const = 0; + + virtual bool setHapticsCommand(double& forceValue, double& vibrotactileValue) const = 0; }; inline const std::string wearable::actuator::IHaptic::getPrefix() diff --git a/msgs/thrift/WearableActuators.thrift b/msgs/thrift/WearableActuators.thrift index 86efeed9..41b0c7a5 100644 --- a/msgs/thrift/WearableActuators.thrift +++ b/msgs/thrift/WearableActuators.thrift @@ -24,6 +24,7 @@ struct ActuatorInfo { struct WearableActuatorCommand { 1: ActuatorInfo info; - 2: double value; - 3: double duration; + 2: double forceValue; + 3: double vibroTactileValue; + 4: double duration; } diff --git a/wrappers/IWearActuators/src/IWearActuatorsWrapper.cpp b/wrappers/IWearActuators/src/IWearActuatorsWrapper.cpp index ddcc6723..ce8714ed 100644 --- a/wrappers/IWearActuators/src/IWearActuatorsWrapper.cpp +++ b/wrappers/IWearActuators/src/IWearActuatorsWrapper.cpp @@ -110,7 +110,7 @@ void IWearActuatorsWrapper::onRead(msg::WearableActuatorCommand& wearableActuato wearable::ElementPtr castActuator = std::static_pointer_cast(pImpl->actuatorsMap[info.name]); // Send haptic command - castActuator->setHapticCommand(wearableActuatorCommand.value); + castActuator->setHapticsCommand(wearableActuatorCommand.forceValue, wearableActuatorCommand.vibroTactileValue); } break; @@ -124,7 +124,7 @@ void IWearActuatorsWrapper::onRead(msg::WearableActuatorCommand& wearableActuato wearable::ElementPtr castActuator = std::static_pointer_cast(pImpl->actuatorsMap[info.name]); // Send motor command - castActuator->setMotorPosition(wearableActuatorCommand.value); + castActuator->setMotorPosition(wearableActuatorCommand.forceValue); } break; From 44c56d3931f882b4ed15b29d0f47454956051571 Mon Sep 17 00:00:00 2001 From: Ehsan Ranjbari Date: Wed, 31 Jan 2024 16:15:26 +0100 Subject: [PATCH 02/14] merge all fingers msgs - GloveDevice --- devices/HapticGlove/src/HapticGlove.cpp | 31 ++++++++++--------- .../Wearable/IWear/Actuators/IHaptic.h | 2 +- msgs/thrift/WearableActuators.thrift | 13 ++++++-- .../src/IWearActuatorsWrapper.cpp | 2 +- 4 files changed, 28 insertions(+), 20 deletions(-) diff --git a/devices/HapticGlove/src/HapticGlove.cpp b/devices/HapticGlove/src/HapticGlove.cpp index c35aafa4..5cf41d05 100644 --- a/devices/HapticGlove/src/HapticGlove.cpp +++ b/devices/HapticGlove/src/HapticGlove.cpp @@ -309,8 +309,8 @@ bool HapticGlove::open(yarp::os::Searchable& config) m_pImpl->sensegloveHapticActuatorVector.push_back( std::make_shared( m_pImpl.get(), - m_pImpl->hapticActuatorPrefix + m_pImpl->gloveData.humanFingerNames[i] - + "::HapticFeedback")); + m_pImpl->hapticActuatorPrefix + + "HapticFeedback")); } for (size_t i = 0; i < m_pImpl->gloveData.humanFingerNames.size(); i++) { @@ -349,8 +349,8 @@ bool HapticGlove::open(yarp::os::Searchable& config) for (size_t i = 0; i < m_pImpl->gloveData.humanFingerNames.size(); i++) m_pImpl->gloveData.humanHapticActuatorNameIdMap.emplace( - std::make_pair(m_pImpl->hapticActuatorPrefix + m_pImpl->gloveData.humanFingerNames[i] - + "::HapticFeedback", + std::make_pair(m_pImpl->hapticActuatorPrefix + + "HapticFeedback", i)); for (size_t i = 0; i < m_pImpl->gloveData.humanFingerNames.size(); i++) @@ -567,25 +567,26 @@ class HapticGlove::SenseGloveImpl::SenseGloveHapticActuator : public wearable::a return true; } - bool setHapticsCommand(double& forceValue, double& vibrotactileValue) const override + bool setHapticsCommand(std::vector& forceValue, std::vector& vibrotactileValue) const override { std::lock_guard lock(m_gloveImpl->mutex); - if (!m_gloveImpl->isAvailable(m_actuatorName, - m_gloveImpl->gloveData.humanHapticActuatorNameIdMap)) { - yError() << LogPrefix << "The actuator name (" << m_actuatorName - << ") is not found in the list of actuators."; + // if (!m_gloveImpl->isAvailable(m_actuatorName, + // m_gloveImpl->gloveData.humanHapticActuatorNameIdMap)) { + // yError() << LogPrefix << "The actuator name (" << m_actuatorName + // << ") is not found in the list of actuators."; - return false; - } + // return false; + // } // m_gloveImpl->gloveData.fingersHapticFeedback // [m_gloveImpl->gloveData.humanHapticActuatorNameIdMap[m_actuatorName]] = value; - m_gloveImpl->gloveData.fingersHapticFeedback[ - m_gloveImpl->gloveData.humanHapticActuatorNameIdMap[m_actuatorName]] = forceValue; - m_gloveImpl->gloveData.fingersHapticFeedback[ - m_gloveImpl->gloveData.humanHapticActuatorNameIdMap[m_actuatorName] + 5] = vibrotactileValue; + for (size_t i = 0; i < m_gloveImpl->nFingers; i++) + { + m_gloveImpl->gloveData.fingersHapticFeedback[i] = forceValue[i]; + m_gloveImpl->gloveData.fingersHapticFeedback[i + 5] = vibrotactileValue[i]; + } return true; } diff --git a/interfaces/IWear/include/Wearable/IWear/Actuators/IHaptic.h b/interfaces/IWear/include/Wearable/IWear/Actuators/IHaptic.h index 6bce2509..b4a01d5e 100644 --- a/interfaces/IWear/include/Wearable/IWear/Actuators/IHaptic.h +++ b/interfaces/IWear/include/Wearable/IWear/Actuators/IHaptic.h @@ -28,7 +28,7 @@ class wearable::actuator::IHaptic : public wearable::actuator::IActuator virtual bool setHapticCommand(double& value) const = 0; - virtual bool setHapticsCommand(double& forceValue, double& vibrotactileValue) const = 0; + virtual bool setHapticsCommand(std::vector& forceValue, std::vector& vibrotactileValue) const = 0; }; inline const std::string wearable::actuator::IHaptic::getPrefix() diff --git a/msgs/thrift/WearableActuators.thrift b/msgs/thrift/WearableActuators.thrift index 41b0c7a5..d6abbe62 100644 --- a/msgs/thrift/WearableActuators.thrift +++ b/msgs/thrift/WearableActuators.thrift @@ -22,9 +22,16 @@ struct ActuatorInfo { // Actuator Command data type // ========================== +// struct WearableActuatorCommand { +// 1: ActuatorInfo info; +// 2: double forceValue; +// 3: double vibroTactileValue; +// 4: double duration; +// } + struct WearableActuatorCommand { 1: ActuatorInfo info; - 2: double forceValue; - 3: double vibroTactileValue; - 4: double duration; + 2: list forceValue; + 3: list vibroTactileValue; + 4: list duration; } diff --git a/wrappers/IWearActuators/src/IWearActuatorsWrapper.cpp b/wrappers/IWearActuators/src/IWearActuatorsWrapper.cpp index ce8714ed..c9871b3a 100644 --- a/wrappers/IWearActuators/src/IWearActuatorsWrapper.cpp +++ b/wrappers/IWearActuators/src/IWearActuatorsWrapper.cpp @@ -124,7 +124,7 @@ void IWearActuatorsWrapper::onRead(msg::WearableActuatorCommand& wearableActuato wearable::ElementPtr castActuator = std::static_pointer_cast(pImpl->actuatorsMap[info.name]); // Send motor command - castActuator->setMotorPosition(wearableActuatorCommand.forceValue); + castActuator->setMotorPosition(wearableActuatorCommand.forceValue[0]); } break; From 7094f84275c29e6e4c60312f4754574ab2db790e Mon Sep 17 00:00:00 2001 From: Stefano Dafarra Date: Fri, 16 Feb 2024 13:08:52 +0100 Subject: [PATCH 03/14] Reduced the period of haptic glove wrappers --- devices/HapticGlove/conf/HapticGlove.xml | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/devices/HapticGlove/conf/HapticGlove.xml b/devices/HapticGlove/conf/HapticGlove.xml index c476277e..ccbf15db 100644 --- a/devices/HapticGlove/conf/HapticGlove.xml +++ b/devices/HapticGlove/conf/HapticGlove.xml @@ -17,7 +17,7 @@ - 0.01 + 0.1 /WearableData/HapticGlove/LeftHand/data:o /WearableData/HapticGlove/LeftHand/metadataRpc:o @@ -29,7 +29,7 @@ - 0.01 + 0.1 /WearableData/HapticGlove/LeftHand/Actuators/input:i @@ -53,7 +53,7 @@ - 0.01 + 0.1 /WearableData/HapticGlove/RightHand/data:o /WearableData/HapticGlove/RightHand/metadataRpc:o @@ -65,7 +65,7 @@ - 0.01 + 0.1 /WearableData/HapticGlove/RightHand/Actuators/input:i From 19410739b9b651c7e35628a2e0d393184f26441b Mon Sep 17 00:00:00 2001 From: Ehsan Ranjbari Date: Fri, 1 Mar 2024 18:19:28 +0100 Subject: [PATCH 04/14] commented code lines removed --- devices/HapticGlove/src/HapticGlove.cpp | 23 ----------------------- msgs/thrift/WearableActuators.thrift | 7 ------- 2 files changed, 30 deletions(-) diff --git a/devices/HapticGlove/src/HapticGlove.cpp b/devices/HapticGlove/src/HapticGlove.cpp index 5cf41d05..2e57b2ea 100644 --- a/devices/HapticGlove/src/HapticGlove.cpp +++ b/devices/HapticGlove/src/HapticGlove.cpp @@ -551,19 +551,6 @@ class HapticGlove::SenseGloveImpl::SenseGloveHapticActuator : public wearable::a bool setHapticCommand(double& value) const override { - - // std::lock_guard lock(m_gloveImpl->mutex); - - // if (!m_gloveImpl->isAvailable(m_actuatorName, - // m_gloveImpl->gloveData.humanHapticActuatorNameIdMap)) { - // yError() << LogPrefix << "The actuator name (" << m_actuatorName - // << ") is not found in the list of actuators."; - - // return false; - // } - // m_gloveImpl->gloveData.fingersHapticFeedback - // [m_gloveImpl->gloveData.humanHapticActuatorNameIdMap[m_actuatorName]] = value; - return true; } @@ -572,16 +559,6 @@ class HapticGlove::SenseGloveImpl::SenseGloveHapticActuator : public wearable::a std::lock_guard lock(m_gloveImpl->mutex); - // if (!m_gloveImpl->isAvailable(m_actuatorName, - // m_gloveImpl->gloveData.humanHapticActuatorNameIdMap)) { - // yError() << LogPrefix << "The actuator name (" << m_actuatorName - // << ") is not found in the list of actuators."; - - // return false; - // } - // m_gloveImpl->gloveData.fingersHapticFeedback - // [m_gloveImpl->gloveData.humanHapticActuatorNameIdMap[m_actuatorName]] = value; - for (size_t i = 0; i < m_gloveImpl->nFingers; i++) { m_gloveImpl->gloveData.fingersHapticFeedback[i] = forceValue[i]; diff --git a/msgs/thrift/WearableActuators.thrift b/msgs/thrift/WearableActuators.thrift index d6abbe62..02fef661 100644 --- a/msgs/thrift/WearableActuators.thrift +++ b/msgs/thrift/WearableActuators.thrift @@ -22,13 +22,6 @@ struct ActuatorInfo { // Actuator Command data type // ========================== -// struct WearableActuatorCommand { -// 1: ActuatorInfo info; -// 2: double forceValue; -// 3: double vibroTactileValue; -// 4: double duration; -// } - struct WearableActuatorCommand { 1: ActuatorInfo info; 2: list forceValue; From 9688b1aa2a540449cdd2dbfbb513362d357de02a Mon Sep 17 00:00:00 2001 From: Ehsan Ranjbari Date: Fri, 15 Mar 2024 16:00:23 +0100 Subject: [PATCH 05/14] added moroValue, removed duration --- devices/HapticGlove/src/HapticGlove.cpp | 3 ++- msgs/thrift/WearableActuators.thrift | 2 +- wrappers/IWearActuators/src/IWearActuatorsWrapper.cpp | 2 +- 3 files changed, 4 insertions(+), 3 deletions(-) diff --git a/devices/HapticGlove/src/HapticGlove.cpp b/devices/HapticGlove/src/HapticGlove.cpp index 2e57b2ea..1507cf4b 100644 --- a/devices/HapticGlove/src/HapticGlove.cpp +++ b/devices/HapticGlove/src/HapticGlove.cpp @@ -551,7 +551,8 @@ class HapticGlove::SenseGloveImpl::SenseGloveHapticActuator : public wearable::a bool setHapticCommand(double& value) const override { - return true; + yError() << LogPrefix << "Wrong method has been called! To set the haptic command please use the setHapticsCommand method."; + return false; } bool setHapticsCommand(std::vector& forceValue, std::vector& vibrotactileValue) const override diff --git a/msgs/thrift/WearableActuators.thrift b/msgs/thrift/WearableActuators.thrift index 02fef661..c74fa314 100644 --- a/msgs/thrift/WearableActuators.thrift +++ b/msgs/thrift/WearableActuators.thrift @@ -26,5 +26,5 @@ struct WearableActuatorCommand { 1: ActuatorInfo info; 2: list forceValue; 3: list vibroTactileValue; - 4: list duration; + 4: double motorValue; } diff --git a/wrappers/IWearActuators/src/IWearActuatorsWrapper.cpp b/wrappers/IWearActuators/src/IWearActuatorsWrapper.cpp index c9871b3a..7dc7f874 100644 --- a/wrappers/IWearActuators/src/IWearActuatorsWrapper.cpp +++ b/wrappers/IWearActuators/src/IWearActuatorsWrapper.cpp @@ -124,7 +124,7 @@ void IWearActuatorsWrapper::onRead(msg::WearableActuatorCommand& wearableActuato wearable::ElementPtr castActuator = std::static_pointer_cast(pImpl->actuatorsMap[info.name]); // Send motor command - castActuator->setMotorPosition(wearableActuatorCommand.forceValue[0]); + castActuator->setMotorPosition(wearableActuatorCommand.motorValue); } break; From 533992ba49ba2c8b109e4e9f058456c235c976e5 Mon Sep 17 00:00:00 2001 From: Silvio Traversaro Date: Thu, 29 Feb 2024 22:42:29 +0100 Subject: [PATCH 06/14] Fix compatibility with YARP 3.10 (#206) * Fix compatibility with YARP 3.10 --- devices/Paexo/src/Paexo.cpp | 5 ----- wrappers/IWearActuators/src/IWearActuatorsWrapper.cpp | 11 ++++++----- 2 files changed, 6 insertions(+), 10 deletions(-) diff --git a/devices/Paexo/src/Paexo.cpp b/devices/Paexo/src/Paexo.cpp index 6d379b4d..e58ddb22 100644 --- a/devices/Paexo/src/Paexo.cpp +++ b/devices/Paexo/src/Paexo.cpp @@ -60,8 +60,6 @@ class Paexo::PaexoImpl std::unique_ptr cmdPro; yarp::os::RpcServer rpcPort; - std::string serialComPortName; - // Paexo data buffer PaexoData paexoData; @@ -806,9 +804,6 @@ bool Paexo::attach(yarp::dev::PolyDriver* poly) yInfo() << LogPrefix << "ISerialDevice interface viewed correctly"; } - // Get the comport name of the serial device - pImpl->serialComPortName = poly->getValue("comport").asString(); - // TODO: Check if the ISerialDevice interface is configured correctly // I do not see any method to check this diff --git a/wrappers/IWearActuators/src/IWearActuatorsWrapper.cpp b/wrappers/IWearActuators/src/IWearActuatorsWrapper.cpp index 7dc7f874..888e457f 100644 --- a/wrappers/IWearActuators/src/IWearActuatorsWrapper.cpp +++ b/wrappers/IWearActuators/src/IWearActuatorsWrapper.cpp @@ -20,7 +20,7 @@ constexpr double DefaultPeriod = 0.01; class IWearActuatorsWrapper::impl : public wearable::msg::WearableActuatorCommand { public: - std::string attachedWearableDeviceName; + std::string attachedWearableDeviceKey = "defaultIWearActuatorsWrapperDevice"; std::string actuatorCommandInputPortName; yarp::os::BufferedPort actuatorCommandInputPort; @@ -94,7 +94,7 @@ void IWearActuatorsWrapper::onRead(msg::WearableActuatorCommand& wearableActuato // Check if the commanded actuator name is available if (pImpl->actuatorsMap.find(info.name) == pImpl->actuatorsMap.end()) { - yWarning() << "Requested actuator with name " << info.name << " is not available in " << pImpl->attachedWearableDeviceName << " wearable device \n \t Ignoring wearable actuation command."; + yWarning() << "Requested actuator with name " << info.name << " is not available in " << pImpl->attachedWearableDeviceKey << " wearable device \n \t Ignoring wearable actuation command."; } else // process the wearable actuator command { @@ -153,8 +153,6 @@ bool IWearActuatorsWrapper::attach(yarp::dev::PolyDriver* poly) return false; } - pImpl->attachedWearableDeviceName = poly->getValue("device").asString(); - if (pImpl->iWear || !poly->view(pImpl->iWear) || !pImpl->iWear) { yError() << LogPrefix << "Failed to view the IWear interface from the PolyDriver."; return false; @@ -162,7 +160,7 @@ bool IWearActuatorsWrapper::attach(yarp::dev::PolyDriver* poly) // Check and add all the available actuators - yInfo() << LogPrefix << "Finding available actuators from " << pImpl->attachedWearableDeviceName << " wearable deive ..."; + yInfo() << LogPrefix << "Finding available actuators from " << pImpl->attachedWearableDeviceKey << " wearable deive ..."; for (const auto& a : pImpl->iWear->getHapticActuators()) { @@ -226,6 +224,9 @@ bool IWearActuatorsWrapper::attachAll(const yarp::dev::PolyDriverList& driverLis yError() << LogPrefix << "Passed PolyDriverDescriptor is nullptr."; return false; } + + // Save key that identifies the driver + pImpl->attachedWearableDeviceKey = driver->key; return attach(driver->poly); } From d264b02c1a2c2d805b3cb10942fdd1a822f363c8 Mon Sep 17 00:00:00 2001 From: Silvio Traversaro Date: Mon, 15 Apr 2024 20:37:15 +0200 Subject: [PATCH 07/14] Bump matio-cpp in CI to v0.2.4 (#207) --- .github/workflows/ci.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 5059f287..773bdc60 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -16,7 +16,7 @@ env: YCM_TAG: v0.15.3 YARP_TAG: v3.8.1 iDynTree_TAG: v9.1.0 - matioCpp_TAG: v0.2.2 + matioCpp_TAG: v0.2.4 robometry_TAG: v1.2.1 jobs: From 8cf6fc251382c7ffe2eb419f705440fa3db7b410 Mon Sep 17 00:00:00 2001 From: Ehsan Ranjbari Date: Thu, 13 Jun 2024 17:06:54 +0200 Subject: [PATCH 08/14] Introduce new haptic message --- devices/HapticGlove/conf/HapticGlove.xml | 4 +- msgs/thrift/WearableActuators.thrift | 11 +++- .../include/IWearActuatorsWrapper.h | 3 + .../src/IWearActuatorsWrapper.cpp | 56 ++++++++++++++++++- 4 files changed, 69 insertions(+), 5 deletions(-) diff --git a/devices/HapticGlove/conf/HapticGlove.xml b/devices/HapticGlove/conf/HapticGlove.xml index ccbf15db..06d15622 100644 --- a/devices/HapticGlove/conf/HapticGlove.xml +++ b/devices/HapticGlove/conf/HapticGlove.xml @@ -30,7 +30,7 @@ 0.1 - /WearableData/HapticGlove/LeftHand/Actuators/input:i + /WearableData/HapticGlove/LeftHand/Actuators/input:i LeftHapticGloveWearableDevice @@ -66,7 +66,7 @@ 0.1 - /WearableData/HapticGlove/RightHand/Actuators/input:i + /WearableData/HapticGlove/RightHand/Actuators/input:i RightHapticGloveWearableDevice diff --git a/msgs/thrift/WearableActuators.thrift b/msgs/thrift/WearableActuators.thrift index c74fa314..701abf2c 100644 --- a/msgs/thrift/WearableActuators.thrift +++ b/msgs/thrift/WearableActuators.thrift @@ -23,8 +23,17 @@ struct ActuatorInfo { // ========================== struct WearableActuatorCommand { + 1: ActuatorInfo info; + 2: double value; + 3: double duration; +} + +// ========================== +// Glove Actuator Command data type +// ========================== + +struct GloveActuatorCommand { 1: ActuatorInfo info; 2: list forceValue; 3: list vibroTactileValue; - 4: double motorValue; } diff --git a/wrappers/IWearActuators/include/IWearActuatorsWrapper.h b/wrappers/IWearActuators/include/IWearActuatorsWrapper.h index 6a28c0f0..bff00e4c 100644 --- a/wrappers/IWearActuators/include/IWearActuatorsWrapper.h +++ b/wrappers/IWearActuators/include/IWearActuatorsWrapper.h @@ -12,6 +12,7 @@ #include #include "thrift/WearableActuatorCommand.h" +#include "thrift/GloveActuatorCommand.h" namespace wearable { namespace wrappers { @@ -25,6 +26,7 @@ class wearable::wrappers::IWearActuatorsWrapper , public yarp::dev::IMultipleWrapper , public yarp::os::PeriodicThread , public yarp::os::TypedReaderCallback + , public yarp::os::TypedReaderCallback { private: class impl; @@ -40,6 +42,7 @@ class wearable::wrappers::IWearActuatorsWrapper // TypedReaderCallback void onRead(msg::WearableActuatorCommand& wearableActuatorCommand) override; + void onRead(msg::GloveActuatorCommand& gloveActuatorCommand) override; // PeriodicThread void run() override; diff --git a/wrappers/IWearActuators/src/IWearActuatorsWrapper.cpp b/wrappers/IWearActuators/src/IWearActuatorsWrapper.cpp index 888e457f..21fc4137 100644 --- a/wrappers/IWearActuators/src/IWearActuatorsWrapper.cpp +++ b/wrappers/IWearActuators/src/IWearActuatorsWrapper.cpp @@ -23,11 +23,14 @@ class IWearActuatorsWrapper::impl : public wearable::msg::WearableActuatorComman std::string attachedWearableDeviceKey = "defaultIWearActuatorsWrapperDevice"; std::string actuatorCommandInputPortName; + std::string gloveActuatorCommandInputPortName; yarp::os::BufferedPort actuatorCommandInputPort; + yarp::os::BufferedPort gloveActuatorCommandInputPort; std::unordered_map> actuatorsMap; msg::WearableActuatorCommand wearableActuatorCommand; + msg::GloveActuatorCommand gloveActuatorCommand; wearable::IWear* iWear = nullptr; }; @@ -59,6 +62,11 @@ bool IWearActuatorsWrapper::open(yarp::os::Searchable& config) return false; } + if (!config.check("gloveActuatorCommandInputPortName") || !config.find("gloveActuatorCommandInputPortName").isString()) { + yError() << LogPrefix << "gloveActuatorCommandInputPortName parameter not found"; + return false; + } + if (!config.check("period")) { yInfo() << LogPrefix << "Using default period: " << DefaultPeriod << "s"; @@ -70,6 +78,7 @@ bool IWearActuatorsWrapper::open(yarp::os::Searchable& config) setPeriod(period); pImpl->actuatorCommandInputPortName = config.find("actuatorCommandInputPortName").asString(); + pImpl->gloveActuatorCommandInputPortName = config.find("actuatorCommandInputPortName").asString(); // Configure yarp ports @@ -80,8 +89,15 @@ bool IWearActuatorsWrapper::open(yarp::os::Searchable& config) return false; } + if(!pImpl->gloveActuatorCommandInputPort.open(pImpl->gloveActuatorCommandInputPortName)) + { + yError() << "Failed to open " << pImpl->gloveActuatorCommandInputPortName << " yarp port"; + return false; + } + // Set the callback to use onRead() method of this device pImpl->actuatorCommandInputPort.useCallback(*this); + pImpl->gloveActuatorCommandInputPort.useCallback(*this); return true; } @@ -110,7 +126,7 @@ void IWearActuatorsWrapper::onRead(msg::WearableActuatorCommand& wearableActuato wearable::ElementPtr castActuator = std::static_pointer_cast(pImpl->actuatorsMap[info.name]); // Send haptic command - castActuator->setHapticsCommand(wearableActuatorCommand.forceValue, wearableActuatorCommand.vibroTactileValue); + castActuator->setHapticCommand(wearableActuatorCommand.value); } break; @@ -124,7 +140,43 @@ void IWearActuatorsWrapper::onRead(msg::WearableActuatorCommand& wearableActuato wearable::ElementPtr castActuator = std::static_pointer_cast(pImpl->actuatorsMap[info.name]); // Send motor command - castActuator->setMotorPosition(wearableActuatorCommand.motorValue); + castActuator->setMotorPosition(wearableActuatorCommand.value); + } + + break; + } + default: { + return; + } + } + } +} + +void IWearActuatorsWrapper::onRead(msg::GloveActuatorCommand& gloveActuatorCommand) +{ + // Unpack the actuator in from incoming command + wearable::msg::ActuatorInfo info = gloveActuatorCommand.info; + + // Check if the commanded actuator name is available + if (pImpl->actuatorsMap.find(info.name) == pImpl->actuatorsMap.end()) + { + yWarning() << "Requested actuator with name " << info.name << " is not available in " << pImpl->attachedWearableDeviceKey << " wearable device \n \t Ignoring wearable actuation command."; + } + else // process the wearable actuator command + { + wearable::actuator::ActuatorType aType = pImpl->actuatorsMap[info.name]->getActuatorType(); + + switch (aType) { + case wearable::actuator::ActuatorType::Haptic: { + + // Check if the actuator type in the wearable command is correct + if(info.type == wearable::msg::ActuatorType::HAPTIC) + { + // Get haptic actuator + wearable::ElementPtr castActuator = std::static_pointer_cast(pImpl->actuatorsMap[info.name]); + + // Send haptic command + castActuator->setHapticsCommand(gloveActuatorCommand.forceValue, gloveActuatorCommand.vibroTactileValue); } break; From 12b55ac363c68d0e7445ca212bdd73a87b63d3ba Mon Sep 17 00:00:00 2001 From: Ehsan Ranjbari Date: Tue, 18 Jun 2024 17:20:59 +0200 Subject: [PATCH 09/14] address PR reviews - Mainly: default port Name - hapticfeedback vector size checks --- devices/HapticGlove/src/HapticGlove.cpp | 9 +++- .../Wearable/IWear/Actuators/IHaptic.h | 2 +- .../include/IWearActuatorsWrapper.h | 1 + .../src/IWearActuatorsWrapper.cpp | 50 ++++++++++--------- 4 files changed, 36 insertions(+), 26 deletions(-) diff --git a/devices/HapticGlove/src/HapticGlove.cpp b/devices/HapticGlove/src/HapticGlove.cpp index 1507cf4b..2a89ab45 100644 --- a/devices/HapticGlove/src/HapticGlove.cpp +++ b/devices/HapticGlove/src/HapticGlove.cpp @@ -80,6 +80,7 @@ class HapticGlove::SenseGloveImpl // Number of actuators const int nActuators = 11; // humanFingerNames.size()*2 + hand/palm thumper + const int nActuatorsPerGlove = 5; // Number of the actuators per glove std::unique_ptr pGlove; /**< Pointer to the glove object. */ @@ -555,7 +556,7 @@ class HapticGlove::SenseGloveImpl::SenseGloveHapticActuator : public wearable::a return false; } - bool setHapticsCommand(std::vector& forceValue, std::vector& vibrotactileValue) const override + bool setHapticCommands(std::vector& forceValue, std::vector& vibrotactileValue) const override { std::lock_guard lock(m_gloveImpl->mutex); @@ -565,7 +566,11 @@ class HapticGlove::SenseGloveImpl::SenseGloveHapticActuator : public wearable::a m_gloveImpl->gloveData.fingersHapticFeedback[i] = forceValue[i]; m_gloveImpl->gloveData.fingersHapticFeedback[i + 5] = vibrotactileValue[i]; } - + if (forceValue.size() != m_gloveImpl->nActuatorsPerGlove || vibrotactileValue.size() != m_gloveImpl->nActuatorsPerGlove) + { + yError() << "The sizes of the forceValue and the vibrotactileValue vectors are not correct!"; + return false; + } return true; } diff --git a/interfaces/IWear/include/Wearable/IWear/Actuators/IHaptic.h b/interfaces/IWear/include/Wearable/IWear/Actuators/IHaptic.h index b4a01d5e..2b7fd23c 100644 --- a/interfaces/IWear/include/Wearable/IWear/Actuators/IHaptic.h +++ b/interfaces/IWear/include/Wearable/IWear/Actuators/IHaptic.h @@ -28,7 +28,7 @@ class wearable::actuator::IHaptic : public wearable::actuator::IActuator virtual bool setHapticCommand(double& value) const = 0; - virtual bool setHapticsCommand(std::vector& forceValue, std::vector& vibrotactileValue) const = 0; + virtual bool setHapticCommands(std::vector& forceValue, std::vector& vibrotactileValue) const = 0; }; inline const std::string wearable::actuator::IHaptic::getPrefix() diff --git a/wrappers/IWearActuators/include/IWearActuatorsWrapper.h b/wrappers/IWearActuators/include/IWearActuatorsWrapper.h index bff00e4c..f321e9a5 100644 --- a/wrappers/IWearActuators/include/IWearActuatorsWrapper.h +++ b/wrappers/IWearActuators/include/IWearActuatorsWrapper.h @@ -31,6 +31,7 @@ class wearable::wrappers::IWearActuatorsWrapper private: class impl; std::unique_ptr pImpl; + std::string gloveHandSide; public: IWearActuatorsWrapper(); diff --git a/wrappers/IWearActuators/src/IWearActuatorsWrapper.cpp b/wrappers/IWearActuators/src/IWearActuatorsWrapper.cpp index 21fc4137..890e9959 100644 --- a/wrappers/IWearActuators/src/IWearActuatorsWrapper.cpp +++ b/wrappers/IWearActuators/src/IWearActuatorsWrapper.cpp @@ -62,11 +62,18 @@ bool IWearActuatorsWrapper::open(yarp::os::Searchable& config) return false; } - if (!config.check("gloveActuatorCommandInputPortName") || !config.find("gloveActuatorCommandInputPortName").isString()) { - yError() << LogPrefix << "gloveActuatorCommandInputPortName parameter not found"; + if (!config.check("rightHand") || !config.find("rightHand").isString()) { + yError() << LogPrefix << "rightHand parameter not found"; return false; } + bool isRightHand = config.find("rightHand").asBool(); + gloveHandSide = isRightHand ? "RightHand" : "LeftHand"; + + if (!config.check("gloveActuatorCommandInputPortName") || !config.find("gloveActuatorCommandInputPortName").isString()) { + yWarning() << LogPrefix << "gloveActuatorCommandInputPortName parameter not found! Using the default one."; + pImpl->gloveActuatorCommandInputPortName = "/WearableData/HapticGlove/" + gloveHandSide + "/Actuators/input:i"; // default actuator port + } if (!config.check("period")) { yInfo() << LogPrefix << "Using default period: " << DefaultPeriod << "s"; @@ -78,7 +85,7 @@ bool IWearActuatorsWrapper::open(yarp::os::Searchable& config) setPeriod(period); pImpl->actuatorCommandInputPortName = config.find("actuatorCommandInputPortName").asString(); - pImpl->gloveActuatorCommandInputPortName = config.find("actuatorCommandInputPortName").asString(); + pImpl->gloveActuatorCommandInputPortName = config.find("gloveActuatorCommandInputPortName").asString(); // Configure yarp ports @@ -164,27 +171,24 @@ void IWearActuatorsWrapper::onRead(msg::GloveActuatorCommand& gloveActuatorComma } else // process the wearable actuator command { - wearable::actuator::ActuatorType aType = pImpl->actuatorsMap[info.name]->getActuatorType(); - - switch (aType) { - case wearable::actuator::ActuatorType::Haptic: { - - // Check if the actuator type in the wearable command is correct - if(info.type == wearable::msg::ActuatorType::HAPTIC) - { - // Get haptic actuator - wearable::ElementPtr castActuator = std::static_pointer_cast(pImpl->actuatorsMap[info.name]); - - // Send haptic command - castActuator->setHapticsCommand(gloveActuatorCommand.forceValue, gloveActuatorCommand.vibroTactileValue); - } - - break; + wearable::actuator::ActuatorType aType = pImpl->actuatorsMap[info.name]->getActuatorType(); + if (aType == wearable::actuator::ActuatorType::Haptic) + { + // Check if the actuator type in the wearable command is correct + if(info.type == wearable::msg::ActuatorType::HAPTIC) + { + // Get haptic actuator + wearable::ElementPtr castActuator = std::static_pointer_cast(pImpl->actuatorsMap[info.name]); + + // Send haptic command + castActuator->setHapticCommands(gloveActuatorCommand.forceValue, gloveActuatorCommand.vibroTactileValue); } - default: { - return; - } - } + } + else + { + yError() << "Actuator type is not correct!"; + return; + } } } From 829bba7c07d0800a85abad763da884568ef144b4 Mon Sep 17 00:00:00 2001 From: Ehsan Ranjbari Date: Wed, 19 Jun 2024 12:13:35 +0200 Subject: [PATCH 10/14] Fix vector size check and openning of actuator port --- devices/HapticGlove/src/HapticGlove.cpp | 10 +++---- .../include/IWearActuatorsWrapper.h | 1 - .../src/IWearActuatorsWrapper.cpp | 29 +++++++------------ 3 files changed, 16 insertions(+), 24 deletions(-) diff --git a/devices/HapticGlove/src/HapticGlove.cpp b/devices/HapticGlove/src/HapticGlove.cpp index 2a89ab45..047e979d 100644 --- a/devices/HapticGlove/src/HapticGlove.cpp +++ b/devices/HapticGlove/src/HapticGlove.cpp @@ -561,16 +561,16 @@ class HapticGlove::SenseGloveImpl::SenseGloveHapticActuator : public wearable::a std::lock_guard lock(m_gloveImpl->mutex); - for (size_t i = 0; i < m_gloveImpl->nFingers; i++) - { - m_gloveImpl->gloveData.fingersHapticFeedback[i] = forceValue[i]; - m_gloveImpl->gloveData.fingersHapticFeedback[i + 5] = vibrotactileValue[i]; - } if (forceValue.size() != m_gloveImpl->nActuatorsPerGlove || vibrotactileValue.size() != m_gloveImpl->nActuatorsPerGlove) { yError() << "The sizes of the forceValue and the vibrotactileValue vectors are not correct!"; return false; } + for (size_t i = 0; i < m_gloveImpl->nFingers; i++) + { + m_gloveImpl->gloveData.fingersHapticFeedback[i] = forceValue[i]; + m_gloveImpl->gloveData.fingersHapticFeedback[i + 5] = vibrotactileValue[i]; + } return true; } diff --git a/wrappers/IWearActuators/include/IWearActuatorsWrapper.h b/wrappers/IWearActuators/include/IWearActuatorsWrapper.h index f321e9a5..bff00e4c 100644 --- a/wrappers/IWearActuators/include/IWearActuatorsWrapper.h +++ b/wrappers/IWearActuators/include/IWearActuatorsWrapper.h @@ -31,7 +31,6 @@ class wearable::wrappers::IWearActuatorsWrapper private: class impl; std::unique_ptr pImpl; - std::string gloveHandSide; public: IWearActuatorsWrapper(); diff --git a/wrappers/IWearActuators/src/IWearActuatorsWrapper.cpp b/wrappers/IWearActuators/src/IWearActuatorsWrapper.cpp index 890e9959..a06ff98f 100644 --- a/wrappers/IWearActuators/src/IWearActuatorsWrapper.cpp +++ b/wrappers/IWearActuators/src/IWearActuatorsWrapper.cpp @@ -62,17 +62,18 @@ bool IWearActuatorsWrapper::open(yarp::os::Searchable& config) return false; } - if (!config.check("rightHand") || !config.find("rightHand").isString()) { - yError() << LogPrefix << "rightHand parameter not found"; - return false; - } - - bool isRightHand = config.find("rightHand").asBool(); - gloveHandSide = isRightHand ? "RightHand" : "LeftHand"; - + // Find and configure yarp port related to the actuator commands if (!config.check("gloveActuatorCommandInputPortName") || !config.find("gloveActuatorCommandInputPortName").isString()) { - yWarning() << LogPrefix << "gloveActuatorCommandInputPortName parameter not found! Using the default one."; - pImpl->gloveActuatorCommandInputPortName = "/WearableData/HapticGlove/" + gloveHandSide + "/Actuators/input:i"; // default actuator port + yWarning() << LogPrefix << "gloveActuatorCommandInputPortName parameter not found! The port will not be opened."; + } + else + { + pImpl->gloveActuatorCommandInputPortName = config.find("gloveActuatorCommandInputPortName").asString(); + if(!pImpl->gloveActuatorCommandInputPort.open(pImpl->gloveActuatorCommandInputPortName)) + { + yError() << "Failed to open " << pImpl->gloveActuatorCommandInputPortName << " yarp port"; + return false; + } } if (!config.check("period")) { @@ -85,8 +86,6 @@ bool IWearActuatorsWrapper::open(yarp::os::Searchable& config) setPeriod(period); pImpl->actuatorCommandInputPortName = config.find("actuatorCommandInputPortName").asString(); - pImpl->gloveActuatorCommandInputPortName = config.find("gloveActuatorCommandInputPortName").asString(); - // Configure yarp ports @@ -96,12 +95,6 @@ bool IWearActuatorsWrapper::open(yarp::os::Searchable& config) return false; } - if(!pImpl->gloveActuatorCommandInputPort.open(pImpl->gloveActuatorCommandInputPortName)) - { - yError() << "Failed to open " << pImpl->gloveActuatorCommandInputPortName << " yarp port"; - return false; - } - // Set the callback to use onRead() method of this device pImpl->actuatorCommandInputPort.useCallback(*this); pImpl->gloveActuatorCommandInputPort.useCallback(*this); From a7a088251a0ec0592401b9dcd6c8fde74fc82c7a Mon Sep 17 00:00:00 2001 From: Ehsan Ranjbari Date: Wed, 19 Jun 2024 16:52:21 +0200 Subject: [PATCH 11/14] added const to setHapticCommands method arguments --- devices/HapticGlove/src/HapticGlove.cpp | 2 +- interfaces/IWear/include/Wearable/IWear/Actuators/IHaptic.h | 2 +- wrappers/IWearActuators/src/IWearActuatorsWrapper.cpp | 3 ++- 3 files changed, 4 insertions(+), 3 deletions(-) diff --git a/devices/HapticGlove/src/HapticGlove.cpp b/devices/HapticGlove/src/HapticGlove.cpp index 047e979d..b9231f53 100644 --- a/devices/HapticGlove/src/HapticGlove.cpp +++ b/devices/HapticGlove/src/HapticGlove.cpp @@ -556,7 +556,7 @@ class HapticGlove::SenseGloveImpl::SenseGloveHapticActuator : public wearable::a return false; } - bool setHapticCommands(std::vector& forceValue, std::vector& vibrotactileValue) const override + bool setHapticCommands(const std::vector& forceValue, const std::vector& vibrotactileValue) const override { std::lock_guard lock(m_gloveImpl->mutex); diff --git a/interfaces/IWear/include/Wearable/IWear/Actuators/IHaptic.h b/interfaces/IWear/include/Wearable/IWear/Actuators/IHaptic.h index 2b7fd23c..2d5fcc75 100644 --- a/interfaces/IWear/include/Wearable/IWear/Actuators/IHaptic.h +++ b/interfaces/IWear/include/Wearable/IWear/Actuators/IHaptic.h @@ -28,7 +28,7 @@ class wearable::actuator::IHaptic : public wearable::actuator::IActuator virtual bool setHapticCommand(double& value) const = 0; - virtual bool setHapticCommands(std::vector& forceValue, std::vector& vibrotactileValue) const = 0; + virtual bool setHapticCommands(const std::vector& forceValue, const std::vector& vibrotactileValue) const = 0; }; inline const std::string wearable::actuator::IHaptic::getPrefix() diff --git a/wrappers/IWearActuators/src/IWearActuatorsWrapper.cpp b/wrappers/IWearActuators/src/IWearActuatorsWrapper.cpp index a06ff98f..7aac3aba 100644 --- a/wrappers/IWearActuators/src/IWearActuatorsWrapper.cpp +++ b/wrappers/IWearActuators/src/IWearActuatorsWrapper.cpp @@ -74,6 +74,8 @@ bool IWearActuatorsWrapper::open(yarp::os::Searchable& config) yError() << "Failed to open " << pImpl->gloveActuatorCommandInputPortName << " yarp port"; return false; } + // Set the callback to use onRead() method of this device + pImpl->gloveActuatorCommandInputPort.useCallback(*this); } if (!config.check("period")) { @@ -97,7 +99,6 @@ bool IWearActuatorsWrapper::open(yarp::os::Searchable& config) // Set the callback to use onRead() method of this device pImpl->actuatorCommandInputPort.useCallback(*this); - pImpl->gloveActuatorCommandInputPort.useCallback(*this); return true; } From 2bb61850b54d0ff3e7e27b52f2dd6bbc664e8e92 Mon Sep 17 00:00:00 2001 From: Ehsan Ranjbari Date: Fri, 21 Jun 2024 14:44:43 +0200 Subject: [PATCH 12/14] make actuator ports optional --- wrappers/IWearActuators/src/IWearActuatorsWrapper.cpp | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/wrappers/IWearActuators/src/IWearActuatorsWrapper.cpp b/wrappers/IWearActuators/src/IWearActuatorsWrapper.cpp index 7aac3aba..abb84d73 100644 --- a/wrappers/IWearActuators/src/IWearActuatorsWrapper.cpp +++ b/wrappers/IWearActuators/src/IWearActuatorsWrapper.cpp @@ -57,12 +57,16 @@ void IWearActuatorsWrapper::run() bool IWearActuatorsWrapper::open(yarp::os::Searchable& config) { - if (!config.check("actuatorCommandInputPortName") || !config.find("actuatorCommandInputPortName").isString()) { - yError() << LogPrefix << "actuatorCommandInputPortName parameter not found"; + if (!config.check("actuatorCommandInputPortName") || !config.check("gloveActuatorCommandInputPortName")) + { + yError() << LogPrefix << "No actuator command input ports found."; return false; } // Find and configure yarp port related to the actuator commands + if (!config.find("actuatorCommandInputPortName").isString()) { + yWarning() << LogPrefix << "actuatorCommandInputPortName parameter not found. Haptic feedback will not be available."; + } if (!config.check("gloveActuatorCommandInputPortName") || !config.find("gloveActuatorCommandInputPortName").isString()) { yWarning() << LogPrefix << "gloveActuatorCommandInputPortName parameter not found! The port will not be opened."; } From a6456185b90e688655dbdf331a7362e845ddc6e2 Mon Sep 17 00:00:00 2001 From: Ehsan Ranjbari Date: Fri, 21 Jun 2024 16:14:35 +0200 Subject: [PATCH 13/14] fix actuatorCommandInputPort --- .../src/IWearActuatorsWrapper.cpp | 26 +++++++++---------- 1 file changed, 13 insertions(+), 13 deletions(-) diff --git a/wrappers/IWearActuators/src/IWearActuatorsWrapper.cpp b/wrappers/IWearActuators/src/IWearActuatorsWrapper.cpp index abb84d73..922f49d2 100644 --- a/wrappers/IWearActuators/src/IWearActuatorsWrapper.cpp +++ b/wrappers/IWearActuators/src/IWearActuatorsWrapper.cpp @@ -67,6 +67,19 @@ bool IWearActuatorsWrapper::open(yarp::os::Searchable& config) if (!config.find("actuatorCommandInputPortName").isString()) { yWarning() << LogPrefix << "actuatorCommandInputPortName parameter not found. Haptic feedback will not be available."; } + else + { + pImpl->actuatorCommandInputPortName = config.find("actuatorCommandInputPortName").asString(); + if(!pImpl->actuatorCommandInputPort.open(pImpl->actuatorCommandInputPortName)) + { + yError() << "Failed to open " << pImpl->actuatorCommandInputPortName << " yarp port"; + return false; + } + + // Set the callback to use onRead() method of this device + pImpl->actuatorCommandInputPort.useCallback(*this); + + } if (!config.check("gloveActuatorCommandInputPortName") || !config.find("gloveActuatorCommandInputPortName").isString()) { yWarning() << LogPrefix << "gloveActuatorCommandInputPortName parameter not found! The port will not be opened."; } @@ -91,19 +104,6 @@ bool IWearActuatorsWrapper::open(yarp::os::Searchable& config) const double period = config.check("period", yarp::os::Value(DefaultPeriod)).asFloat64(); setPeriod(period); - pImpl->actuatorCommandInputPortName = config.find("actuatorCommandInputPortName").asString(); - - // Configure yarp ports - - if(!pImpl->actuatorCommandInputPort.open(pImpl->actuatorCommandInputPortName)) - { - yError() << "Failed to open " << pImpl->actuatorCommandInputPortName << " yarp port"; - return false; - } - - // Set the callback to use onRead() method of this device - pImpl->actuatorCommandInputPort.useCallback(*this); - return true; } From 32ff17c018a0015e9859a3ee1496cfd4329bc6d9 Mon Sep 17 00:00:00 2001 From: Ehsan Ranjbari Date: Fri, 21 Jun 2024 16:40:50 +0200 Subject: [PATCH 14/14] Update CMakeLists - bump version to 1.9.0 --- CMakeLists.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 1970aa19..7e9bcbac 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -4,7 +4,7 @@ cmake_minimum_required(VERSION 3.16) -set(PROJECT_VERSION "1.8.0") +set(PROJECT_VERSION "1.9.0") set (WEARABLES_PROJECT_NAME Wearables)