Skip to content

Commit

Permalink
changed naming of HumanDynamicsWrapper and HumanDynamicsRemapper
Browse files Browse the repository at this point in the history
  • Loading branch information
davidegorbani committed Oct 9, 2023
1 parent f6e5f94 commit 680ee40
Show file tree
Hide file tree
Showing 9 changed files with 62 additions and 62 deletions.
2 changes: 1 addition & 1 deletion remappers/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,6 @@
# SPDX-License-Identifier: BSD-3-Clause

add_subdirectory(HumanStateRemapper)
add_subdirectory(HumanDynamicsRemapper)
add_subdirectory(HumanDynamics_nwc_yarp)
add_subdirectory(HumanWrenchRemapper)
add_subdirectory(WearableTargetsRemapper)
Original file line number Diff line number Diff line change
@@ -1,29 +1,29 @@
# SPDX-FileCopyrightText: Fondazione Istituto Italiano di Tecnologia (IIT)
# SPDX-License-Identifier: BSD-3-Clause

yarp_prepare_plugin(human_dynamics_remapper
TYPE hde::devices::HumanDynamicsRemapper
INCLUDE HumanDynamicsRemapper.h
yarp_prepare_plugin(human_dynamics_nwc_yarp
TYPE hde::devices::HumanDynamics_nwc_yarp
INCLUDE HumanDynamics_nwc_yarp.h
CATEGORY device
ADVANCED
DEFAULT ON)

yarp_add_plugin(HumanDynamicsRemapper
HumanDynamicsRemapper.cpp
HumanDynamicsRemapper.h)
yarp_add_plugin(HumanDynamics_nwc_yarp
HumanDynamics_nwc_yarp.cpp
HumanDynamics_nwc_yarp.h)

target_include_directories(HumanDynamicsRemapper PUBLIC
target_include_directories(HumanDynamics_nwc_yarp PUBLIC
$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}>)

target_link_libraries(HumanDynamicsRemapper PUBLIC
target_link_libraries(HumanDynamics_nwc_yarp PUBLIC
IHumanDynamics
HumanDynamicsMsg
YARP::YARP_OS
YARP::YARP_dev
YARP::YARP_init)

yarp_install(
TARGETS HumanDynamicsRemapper
TARGETS HumanDynamics_nwc_yarp
COMPONENT runtime
LIBRARY DESTINATION ${YARP_DYNAMIC_PLUGINS_INSTALL_DIR}
ARCHIVE DESTINATION ${YARP_STATIC_PLUGINS_INSTALL_DIR}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
// SPDX-FileCopyrightText: Fondazione Istituto Italiano di Tecnologia (IIT)
// SPDX-License-Identifier: BSD-3-Clause

#include "HumanDynamicsRemapper.h"
#include "HumanDynamics_nwc_yarp.h"

#include <hde/msgs/HumanDynamics.h>

Expand All @@ -11,16 +11,16 @@
#include <iostream>
#include <mutex>

const std::string RemapperName = "HumanDynamicsRemapper";
const std::string LogPrefix = RemapperName + " :";
const std::string ClientName = "HumanDynamics_nwc_yarp";
const std::string LogPrefix = ClientName + " :";

using namespace hde::devices;

// ==============
// IMPL AND UTILS
// ==============

class HumanDynamicsRemapper::impl
class HumanDynamics_nwc_yarp::impl
{
public:
std::mutex mtx;
Expand All @@ -34,18 +34,18 @@ class HumanDynamicsRemapper::impl
};

// =======================
// IHUMANDYNAMICS REMAPPER
// IHUMANDYNAMICS CLIENT
// =======================

HumanDynamicsRemapper::HumanDynamicsRemapper()
HumanDynamics_nwc_yarp::HumanDynamics_nwc_yarp()
: PeriodicThread(1)
, pImpl{new impl()}
{}

HumanDynamicsRemapper::~HumanDynamicsRemapper() = default;
HumanDynamics_nwc_yarp::~HumanDynamics_nwc_yarp() = default;

// parsing the configuration file and connect ports
bool HumanDynamicsRemapper::open(yarp::os::Searchable& config)
bool HumanDynamics_nwc_yarp::open(yarp::os::Searchable& config)
{
// ===============================
// CHECK THE CONFIGURATION OPTIONS
Expand Down Expand Up @@ -103,10 +103,10 @@ bool HumanDynamicsRemapper::open(yarp::os::Searchable& config)
return true;
}

void HumanDynamicsRemapper::threadRelease()
void HumanDynamics_nwc_yarp::threadRelease()
{}

bool HumanDynamicsRemapper::close()
bool HumanDynamics_nwc_yarp::close()
{
pImpl->terminationCall = true;

Expand All @@ -117,13 +117,13 @@ bool HumanDynamicsRemapper::close()
return true;
}

void HumanDynamicsRemapper::run()
void HumanDynamics_nwc_yarp::run()
{
return;
}

// data are read from the port and saved in buffer variables
void HumanDynamicsRemapper::onRead(hde::msgs::HumanDynamics& humanDynamicsData)
void HumanDynamics_nwc_yarp::onRead(hde::msgs::HumanDynamics& humanDynamicsData)
{
std::lock_guard<std::mutex> lock(pImpl->mtx);
if(!pImpl->terminationCall) {
Expand All @@ -134,19 +134,19 @@ void HumanDynamicsRemapper::onRead(hde::msgs::HumanDynamics& humanDynamicsData)
}

// method of IHumanDynamics interface expose the buffer variables data
std::vector<std::string> HumanDynamicsRemapper::getJointNames() const
std::vector<std::string> HumanDynamics_nwc_yarp::getJointNames() const
{
std::lock_guard<std::mutex> lock(pImpl->mtx);
return pImpl->jointNames;
}

size_t HumanDynamicsRemapper::getNumberOfJoints() const
size_t HumanDynamics_nwc_yarp::getNumberOfJoints() const
{
std::lock_guard<std::mutex> lock(pImpl->mtx);
return pImpl->jointTorques.size();
}

std::vector<double> HumanDynamicsRemapper::getJointTorques() const
std::vector<double> HumanDynamics_nwc_yarp::getJointTorques() const
{
std::lock_guard<std::mutex> lock(pImpl->mtx);
return pImpl->jointTorques;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
// SPDX-FileCopyrightText: Fondazione Istituto Italiano di Tecnologia (IIT)
// SPDX-License-Identifier: BSD-3-Clause

#ifndef HDE_DEVICES_HUMANDYNAMICSREMAPPER
#define HDE_DEVICES_HUMANDYNAMICSREMAPPER
#ifndef HDE_DEVICES_HUMANDYNAMICS_NEC_YARP
#define HDE_DEVICES_HUMANDYNAMICS_NEC_YARP

#include <hde/interfaces/IHumanDynamics.h>

Expand All @@ -17,10 +17,10 @@ namespace hde::msgs {
class HumanDynamics;
} // namespace hde::msgs
namespace hde::devices {
class HumanDynamicsRemapper;
class HumanDynamics_nwc_yarp;
} // namespace hde::devices

class hde::devices::HumanDynamicsRemapper final
class hde::devices::HumanDynamics_nwc_yarp final
: public yarp::dev::DeviceDriver
// inherite from the interface to be exposed
, public hde::interfaces::IHumanDynamics
Expand All @@ -34,8 +34,8 @@ class hde::devices::HumanDynamicsRemapper final
std::unique_ptr<impl> pImpl;

public:
HumanDynamicsRemapper();
~HumanDynamicsRemapper() override;
HumanDynamics_nwc_yarp();
~HumanDynamics_nwc_yarp() override;



Expand All @@ -58,5 +58,5 @@ class hde::devices::HumanDynamicsRemapper final
std::vector<double> getJointTorques() const override;
};

#endif // HDE_DEVICES_HUMANDYNAMICSREMAPPER
#endif // HDE_DEVICES_HUMANDYNAMICS_NEC_YARP

Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@
<robot name="Human-Dynamics-Remapper" build=0 portprefix="">


<device type="human_dynamics_remapper" name="HumanDynamicsRemapper">
<param name="humanDynamicsDataPort">/HDE/HumanDynamicsWrapper/torques:o</param>
<device type="human_dynamics_remapper" name="HumanDynamics_nwc_yarp">
<param name="humanDynamicsDataPort">/HDE/HumanDynamics_nwc_yarp/torques:o</param>
</device>


Expand Down
2 changes: 1 addition & 1 deletion wrappers/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,6 @@
# SPDX-License-Identifier: BSD-3-Clause

add_subdirectory(HumanStateWrapper)
add_subdirectory(HumanDynamicsWrapper)
add_subdirectory(HumanDynamics_nws_yarp)
add_subdirectory(HumanWrenchWrapper)
add_subdirectory(WearableTargetsWrapper)
Original file line number Diff line number Diff line change
@@ -1,29 +1,29 @@
# SPDX-FileCopyrightText: Fondazione Istituto Italiano di Tecnologia (IIT)
# SPDX-License-Identifier: BSD-3-Clause

yarp_prepare_plugin(human_dynamics_wrapper
TYPE hde::wrappers::HumanDynamicsWrapper
INCLUDE HumanDynamicsWrapper.h
yarp_prepare_plugin(human_dynamics_nws_yarp
TYPE hde::wrappers::HumanDynamics_nws_yarp
INCLUDE HumanDynamics_nws_yarp.h
CATEGORY device
ADVANCED
DEFAULT ON)

yarp_add_plugin(HumanDynamicsWrapper
HumanDynamicsWrapper.cpp
HumanDynamicsWrapper.h)
yarp_add_plugin(HumanDynamics_nws_yarp
HumanDynamics_nws_yarp.cpp
HumanDynamics_nws_yarp.h)

target_include_directories(HumanDynamicsWrapper PUBLIC
target_include_directories(HumanDynamics_nws_yarp PUBLIC
$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}>)

target_link_libraries(HumanDynamicsWrapper PUBLIC
target_link_libraries(HumanDynamics_nws_yarp PUBLIC
IHumanDynamics
HumanDynamicsMsg
YARP::YARP_OS
YARP::YARP_dev
YARP::YARP_init)

yarp_install(
TARGETS HumanDynamicsWrapper
TARGETS HumanDynamics_nws_yarp
COMPONENT runtime
LIBRARY DESTINATION ${YARP_DYNAMIC_PLUGINS_INSTALL_DIR}
ARCHIVE DESTINATION ${YARP_STATIC_PLUGINS_INSTALL_DIR}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
// SPDX-FileCopyrightText: Fondazione Istituto Italiano di Tecnologia (IIT)
// SPDX-License-Identifier: BSD-3-Clause

#include "HumanDynamicsWrapper.h"
#include "HumanDynamics_nws_yarp.h"
#include <hde/interfaces/IHumanDynamics.h>
#include <hde/msgs/HumanDynamics.h>

Expand All @@ -11,28 +11,28 @@

#include <mutex>

const std::string DeviceName = "HumanDynamicsWrapper";
const std::string DeviceName = "HumanDynamics_nws_yarp";
const std::string LogPrefix = DeviceName + " :";
constexpr double DefaultPeriod = 0.01;

using namespace hde::wrappers;

class HumanDynamicsWrapper::impl
class HumanDynamics_nws_yarp::impl
{
public:
mutable std::mutex mutex;
hde::interfaces::IHumanDynamics* humanDynamics = nullptr;
yarp::os::BufferedPort<hde::msgs::HumanDynamics> outputPort;
};

HumanDynamicsWrapper::HumanDynamicsWrapper()
HumanDynamics_nws_yarp::HumanDynamics_nws_yarp()
: PeriodicThread(DefaultPeriod)
, pImpl{new impl()}
{}

HumanDynamicsWrapper::~HumanDynamicsWrapper() {}
HumanDynamics_nws_yarp::~HumanDynamics_nws_yarp() {}

bool HumanDynamicsWrapper::open(yarp::os::Searchable& config)
bool HumanDynamics_nws_yarp::open(yarp::os::Searchable& config)
{
// ===============================
// CHECK THE CONFIGURATION OPTIONS
Expand Down Expand Up @@ -72,13 +72,13 @@ bool HumanDynamicsWrapper::open(yarp::os::Searchable& config)
return true;
}

bool HumanDynamicsWrapper::close()
bool HumanDynamics_nws_yarp::close()
{
pImpl->outputPort.close();
return true;
}

void HumanDynamicsWrapper::run()
void HumanDynamics_nws_yarp::run()
{
// Get data from the interface
std::vector<double> jointTorques = pImpl->humanDynamics->getJointTorques();
Expand All @@ -103,7 +103,7 @@ void HumanDynamicsWrapper::run()
pImpl->outputPort.write();
}

bool HumanDynamicsWrapper::attach(yarp::dev::PolyDriver* poly)
bool HumanDynamics_nws_yarp::attach(yarp::dev::PolyDriver* poly)
{
if (!poly) {
yError() << LogPrefix << "Passed PolyDriver is nullptr";
Expand Down Expand Up @@ -141,9 +141,9 @@ bool HumanDynamicsWrapper::attach(yarp::dev::PolyDriver* poly)
return true;
}

void HumanDynamicsWrapper::threadRelease() {}
void HumanDynamics_nws_yarp::threadRelease() {}

bool HumanDynamicsWrapper::detach()
bool HumanDynamics_nws_yarp::detach()
{
while (isRunning()) {
stop();
Expand All @@ -153,10 +153,10 @@ bool HumanDynamicsWrapper::detach()
return true;
}

bool HumanDynamicsWrapper::attachAll(const yarp::dev::PolyDriverList& driverList)
bool HumanDynamics_nws_yarp::attachAll(const yarp::dev::PolyDriverList& driverList)
{
if (driverList.size() > 1) {
yError() << LogPrefix << "This wrapper accepts only one attached PolyDriver";
yError() << LogPrefix << "This server accepts only one attached PolyDriver";
return false;
}

Expand All @@ -170,7 +170,7 @@ bool HumanDynamicsWrapper::attachAll(const yarp::dev::PolyDriverList& driverList
return attach(driver->poly);
}

bool HumanDynamicsWrapper::detachAll()
bool HumanDynamics_nws_yarp::detachAll()
{
return detach();
}
Original file line number Diff line number Diff line change
Expand Up @@ -13,11 +13,11 @@

namespace hde {
namespace wrappers {
class HumanDynamicsWrapper;
class HumanDynamics_nws_yarp;
} // namespace wrappers
} // namespace hde

class hde::wrappers::HumanDynamicsWrapper final
class hde::wrappers::HumanDynamics_nws_yarp final
: public yarp::dev::DeviceDriver
, public yarp::dev::IWrapper
, public yarp::dev::IMultipleWrapper
Expand All @@ -28,8 +28,8 @@ class hde::wrappers::HumanDynamicsWrapper final
std::unique_ptr<impl> pImpl;

public:
HumanDynamicsWrapper();
~HumanDynamicsWrapper() override;
HumanDynamics_nws_yarp();
~HumanDynamics_nws_yarp() override;

// DeviceDriver interface
bool open(yarp::os::Searchable& config) override;
Expand Down

0 comments on commit 680ee40

Please sign in to comment.