Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix period management in HapticGlove #173

Merged
merged 2 commits into from
Oct 3, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,9 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0

## [Unreleased]

### Fixed
- Fixed management of the `period` parameter in `HapticGlove` device (https://github.com/robotology/wearables/pull/173).

## [1.7.0] - 2022-09-28

### Changed
Expand Down
12 changes: 6 additions & 6 deletions devices/HapticGlove/conf/HapticGlove.xml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@

<!--Left HapticGlove Device-->
<device type="hapticGlove" name="LeftHapticGloveWearableDevice">
<param name="period">0.01</param>
<param extern-name="period" name="period">0.01</param>
<param name="rightHand">false</param>
<param name="human_joint_list">( "l_thumb_oppose", "l_thumb_proximal", "l_thumb_middle", "l_thumb_distal",
"l_index_abduction", "l_index_proximal", "l_index_middle", "l_index_distal",
Expand All @@ -17,7 +17,7 @@
</device>

<device type="iwear_wrapper" name="LeftHapticGloveWearableDeviceWrapper">
<param name="period">0.01</param>
<param extern-name="period" name="period">0.01</param>
<param name="dataPortName">/WearableData/HapticGlove/LeftHand/data:o</param>
<param name="rpcPortName">/WearableData/HapticGlove/LeftHand/metadataRpc:o</param>
<action phase="startup" level="5" type="attach">
Expand All @@ -29,7 +29,7 @@
</device>

<device type="iwearactuators_wrapper" name="LeftHapticGloveWearableDeviceActuatorsWrapper">
<param name="period">0.01</param>
<param extern-name="period" name="period">0.01</param>
<param name="actuatorCommandInputPortName">/WearableData/HapticGlove/LeftHand/Actuators/input:i</param>
<action phase="startup" level="5" type="attach">
<paramlist name="networks">
Expand All @@ -41,7 +41,7 @@

<!--Right HapticGlove Device-->
<device type="hapticGlove" name="RightHapticGloveWearableDevice">
<param name="period">0.01</param>
<param extern-name="period" name="period">0.01</param>
<param name="rightHand">true</param>
<param name="human_joint_list">( "r_thumb_oppose", "r_thumb_proximal", "r_thumb_middle", "r_thumb_distal",
"r_index_abduction", "r_index_proximal", "r_index_middle", "r_index_distal",
Expand All @@ -53,7 +53,7 @@
</device>

<device type="iwear_wrapper" name="RightHapticGloveWearableDeviceWrapper">
<param name="period">0.01</param>
<param extern-name="period" name="period">0.01</param>
<param name="dataPortName">/WearableData/HapticGlove/RightHand/data:o</param>
<param name="rpcPortName">/WearableData/HapticGlove/RightHand/metadataRpc:o</param>
<action phase="startup" level="5" type="attach">
Expand All @@ -65,7 +65,7 @@
</device>

<device type="iwearactuators_wrapper" name="RightHapticGloveWearableDeviceActuatorsWrapper">
<param name="period">0.01</param>
<param extern-name="period" name="period">0.01</param>
<param name="actuatorCommandInputPortName">/WearableData/HapticGlove/RightHand/Actuators/input:i</param>
<action phase="startup" level="5" type="attach">
<paramlist name="networks">
Expand Down
13 changes: 8 additions & 5 deletions devices/HapticGlove/src/HapticGlove.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,6 @@

const std::string DeviceName = "HapticGlove";
const std::string LogPrefix = DeviceName + wearable::Separator;
double period = 0.01;
const size_t PoseSize = 7;

using namespace wearable;
Expand Down Expand Up @@ -69,6 +68,9 @@ class HapticGlove::SenseGloveImpl
{
public:
mutable std::mutex mutex;

double period = 0.01; //default 100Hz

SenseGloveIMUData gloveData;

WearableName wearableName;
Expand Down Expand Up @@ -241,7 +243,7 @@ bool HapticGlove::SenseGloveImpl::close()
return true;
}
HapticGlove::HapticGlove()
: PeriodicThread(period)
: PeriodicThread(0.01) //default 100Hz
, m_pImpl{std::make_unique<SenseGloveImpl>()}
{}

Expand All @@ -257,12 +259,13 @@ bool HapticGlove::open(yarp::os::Searchable& config)
// ==================================
// Period of the this device
if (!(config.check("period") && config.find("period").isFloat64())) {
yInfo() << LogPrefix << "Using default period: " << period << "s";
yInfo() << LogPrefix << "Using default period: " << m_pImpl->period << "s";
}
else {
period = config.find("period").asFloat64();
yInfo() << LogPrefix << "Using the period : " << period << "s";
m_pImpl->period = config.find("period").asFloat64();
yInfo() << LogPrefix << "Using the period : " << m_pImpl->period << "s";
}
setPeriod(m_pImpl->period);

if (!(config.check("wearableName") && config.find("wearableName").isString())) {
yInfo() << LogPrefix << "Using default wearable name SenseGlove";
Expand Down