Skip to content

Commit

Permalink
changed naming of HumanStateWrapper and HumanStateRemapper
Browse files Browse the repository at this point in the history
  • Loading branch information
davidegorbani committed Oct 9, 2023
1 parent 680ee40 commit d3b48b1
Show file tree
Hide file tree
Showing 8 changed files with 69 additions and 69 deletions.
2 changes: 1 addition & 1 deletion remappers/CMakeLists.txt
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

add_subdirectory(HumanStateRemapper)
add_subdirectory(HumanState_nwc_yarp)
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_state_remapper
TYPE hde::devices::HumanStateRemapper
INCLUDE HumanStateRemapper.h
yarp_prepare_plugin(human_state_nwc_yarp
TYPE hde::devices::HumanState_nwc_yarp
INCLUDE HumanState_nwc_yarp.h
CATEGORY device
ADVANCED
DEFAULT ON)

yarp_add_plugin(HumanStateRemapper
HumanStateRemapper.cpp
HumanStateRemapper.h)
yarp_add_plugin(HumanState_nwc_yarp
HumanState_nwc_yarp.cpp
HumanState_nwc_yarp.h)

target_include_directories(HumanStateRemapper PUBLIC
target_include_directories(HumanState_nwc_yarp PUBLIC
$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}>)

target_link_libraries(HumanStateRemapper PUBLIC
target_link_libraries(HumanState_nwc_yarp PUBLIC
IHumanState
HumanStateMsg
YARP::YARP_OS
YARP::YARP_dev
YARP::YARP_init)

yarp_install(
TARGETS HumanStateRemapper
TARGETS HumanState_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 "HumanStateRemapper.h"
#include "HumanState_nwc_yarp.h"

#include <hde/msgs/HumanState.h>

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

const std::string RemapperName = "HumanStateRemapper";
const std::string LogPrefix = RemapperName + " :";
const std::string ClientName = "HumanState_nwc_yarp";
const std::string LogPrefix = ClientName + " :";

using namespace hde::devices;

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

class HumanStateRemapper::impl
class HumanState_nwc_yarp::impl
{
public:
std::mutex mtx;
Expand All @@ -44,17 +44,17 @@ class HumanStateRemapper::impl
};

// ====================
// IHUMANSTATE REMAPPER
// IHUMANSTATE CLIENT
// ====================

HumanStateRemapper::HumanStateRemapper()
HumanState_nwc_yarp::HumanState_nwc_yarp()
: PeriodicThread(1)
, pImpl{new impl()}
{}

HumanStateRemapper::~HumanStateRemapper() = default;
HumanState_nwc_yarp::~HumanState_nwc_yarp() = default;

bool HumanStateRemapper::open(yarp::os::Searchable& config)
bool HumanState_nwc_yarp::open(yarp::os::Searchable& config)
{
// ===============================
// CHECK THE CONFIGURATION OPTIONS
Expand Down Expand Up @@ -111,10 +111,10 @@ bool HumanStateRemapper::open(yarp::os::Searchable& config)
return true;
}

void HumanStateRemapper::threadRelease()
void HumanState_nwc_yarp::threadRelease()
{}

bool HumanStateRemapper::close()
bool HumanState_nwc_yarp::close()
{
pImpl->terminationCall = true;

Expand All @@ -125,12 +125,12 @@ bool HumanStateRemapper::close()
return true;
}

void HumanStateRemapper::run()
void HumanState_nwc_yarp::run()
{
return;
}

void HumanStateRemapper::onRead(hde::msgs::HumanState& humanStateData)
void HumanState_nwc_yarp::onRead(hde::msgs::HumanState& humanStateData)
{
std::lock_guard<std::mutex> lock(pImpl->mtx);
if(!pImpl->terminationCall) {
Expand All @@ -151,61 +151,61 @@ void HumanStateRemapper::onRead(hde::msgs::HumanState& humanStateData)
}
}

std::vector<std::string> HumanStateRemapper::getJointNames() const
std::vector<std::string> HumanState_nwc_yarp::getJointNames() const
{
std::lock_guard<std::mutex> lock(pImpl->mtx);

return pImpl->jointNames;
}

std::string HumanStateRemapper::getBaseName() const
std::string HumanState_nwc_yarp::getBaseName() const
{
std::lock_guard<std::mutex> lock(pImpl->mtx);
return pImpl->baseName;
}
size_t HumanStateRemapper::getNumberOfJoints() const
size_t HumanState_nwc_yarp::getNumberOfJoints() const
{
std::lock_guard<std::mutex> lock(pImpl->mtx);
return pImpl->jointPositions.size();
}

std::vector<double> HumanStateRemapper::getJointPositions() const
std::vector<double> HumanState_nwc_yarp::getJointPositions() const
{
std::lock_guard<std::mutex> lock(pImpl->mtx);
return pImpl->jointPositions;
}

std::vector<double> HumanStateRemapper::getJointVelocities() const
std::vector<double> HumanState_nwc_yarp::getJointVelocities() const
{
std::lock_guard<std::mutex> lock(pImpl->mtx);
return pImpl->jointVelocities;
}

std::array<double, 3> HumanStateRemapper::getBasePosition() const
std::array<double, 3> HumanState_nwc_yarp::getBasePosition() const
{
std::lock_guard<std::mutex> lock(pImpl->mtx);
return pImpl->basePosition;
}

std::array<double, 4> HumanStateRemapper::getBaseOrientation() const
std::array<double, 4> HumanState_nwc_yarp::getBaseOrientation() const
{
std::lock_guard<std::mutex> lock(pImpl->mtx);
return pImpl->baseOrientation;
}

std::array<double, 6> HumanStateRemapper::getBaseVelocity() const
std::array<double, 6> HumanState_nwc_yarp::getBaseVelocity() const
{
std::lock_guard<std::mutex> lock(pImpl->mtx);
return pImpl->baseVelocity;
}

std::array<double, 3> HumanStateRemapper::getCoMPosition() const
std::array<double, 3> HumanState_nwc_yarp::getCoMPosition() const
{
std::lock_guard<std::mutex> lock(pImpl->mtx);
return pImpl->CoMPosition;
}

std::array<double, 3> HumanStateRemapper::getCoMVelocity() const
std::array<double, 3> HumanState_nwc_yarp::getCoMVelocity() const
{
std::lock_guard<std::mutex> lock(pImpl->mtx);
return pImpl->CoMVelocity;
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_HUMANSTATEREMAPPER
#define HDE_DEVICES_HUMANSTATEREMAPPER
#ifndef HDE_DEVICES_HUMANSTATE_NWC_YARP
#define HDE_DEVICES_HUMANSTATE_NWC_YARP

#include <hde/interfaces/IHumanState.h>

Expand All @@ -17,10 +17,10 @@ namespace hde::msgs {
class HumanState;
} // namespace hde::msgs
namespace hde::devices {
class HumanStateRemapper;
class HumanState_nwc_yarp;
} // namespace hde::devices

class hde::devices::HumanStateRemapper final
class hde::devices::HumanState_nwc_yarp final
: public yarp::dev::DeviceDriver
, public hde::interfaces::IHumanState
, public yarp::os::TypedReaderCallback<hde::msgs::HumanState>
Expand All @@ -31,8 +31,8 @@ class hde::devices::HumanStateRemapper final
std::unique_ptr<impl> pImpl;

public:
HumanStateRemapper();
~HumanStateRemapper() override;
HumanState_nwc_yarp();
~HumanState_nwc_yarp() override;

std::mutex mtx;

Expand Down Expand Up @@ -64,4 +64,4 @@ class hde::devices::HumanStateRemapper final
std::array<double, 3> getCoMVelocity() const override;
};

#endif // HDE_DEVICES_HUMANSTATEREMAPPER
#endif // HDE_DEVICES_HUMANSTATE_NWC_YARP
2 changes: 1 addition & 1 deletion wrappers/CMakeLists.txt
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

add_subdirectory(HumanStateWrapper)
add_subdirectory(HumanState_nws_yarp)
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_state_wrapper
TYPE hde::wrappers::HumanStateWrapper
INCLUDE HumanStateWrapper.h
yarp_prepare_plugin(human_state_nws_yarp
TYPE hde::wrappers::HumanState_nws_yarp
INCLUDE HumanState_nws_yarp.h
CATEGORY device
ADVANCED
DEFAULT ON)

yarp_add_plugin(HumanStateWrapper
HumanStateWrapper.cpp
HumanStateWrapper.h)
yarp_add_plugin(HumanState_nws_yarp
HumanState_nws_yarp.cpp
HumanState_nws_yarp.h)

target_include_directories(HumanStateWrapper PUBLIC
target_include_directories(HumanState_nws_yarp PUBLIC
$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}>)

target_link_libraries(HumanStateWrapper PUBLIC
target_link_libraries(HumanState_nws_yarp PUBLIC
IHumanState
HumanStateMsg
YARP::YARP_OS
YARP::YARP_dev
YARP::YARP_init)

yarp_install(
TARGETS HumanStateWrapper
TARGETS HumanState_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,21 +1,21 @@
// SPDX-FileCopyrightText: Fondazione Istituto Italiano di Tecnologia (IIT)
// SPDX-License-Identifier: BSD-3-Clause

#include "HumanStateWrapper.h"
#include "HumanState_nws_yarp.h"
#include <hde/interfaces/IHumanState.h>
#include <hde/msgs/HumanState.h>

#include <yarp/os/BufferedPort.h>
#include <yarp/os/LogStream.h>
#include <yarp/sig/Vector.h>

const std::string DeviceName = "HumanStateWrapper";
const std::string DeviceName = "HumanState_nws_yarp";
const std::string LogPrefix = DeviceName + " :";
constexpr double DefaultPeriod = 0.01;

using namespace hde::wrappers;

class HumanStateWrapper::impl
class HumanState_nws_yarp::impl
{
public:
hde::interfaces::IHumanState* iHumanState = nullptr;
Expand All @@ -33,14 +33,14 @@ class HumanStateWrapper::impl
std::string baseName;
};

HumanStateWrapper::HumanStateWrapper()
HumanState_nws_yarp::HumanState_nws_yarp()
: PeriodicThread(DefaultPeriod)
, pImpl{new impl()}
{}

HumanStateWrapper::~HumanStateWrapper() {}
HumanState_nws_yarp::~HumanState_nws_yarp() {}

bool HumanStateWrapper::open(yarp::os::Searchable& config)
bool HumanState_nws_yarp::open(yarp::os::Searchable& config)
{
// ===============================
// CHECK THE CONFIGURATION OPTIONS
Expand Down Expand Up @@ -82,12 +82,12 @@ bool HumanStateWrapper::open(yarp::os::Searchable& config)

#include <iostream>

bool HumanStateWrapper::close()
bool HumanState_nws_yarp::close()
{
return true;
}

void HumanStateWrapper::run()
void HumanState_nws_yarp::run()
{

// Get data from the interface
Expand Down Expand Up @@ -154,7 +154,7 @@ void HumanStateWrapper::run()
pImpl->outputPort.write(/*forceStrict=*/true);
}

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

void HumanStateWrapper::threadRelease() {}
void HumanState_nws_yarp::threadRelease() {}

bool HumanStateWrapper::detach()
bool HumanState_nws_yarp::detach()
{
while (isRunning()) {
stop();
Expand All @@ -215,7 +215,7 @@ bool HumanStateWrapper::detach()
return true;
}

bool HumanStateWrapper::attachAll(const yarp::dev::PolyDriverList& driverList)
bool HumanState_nws_yarp::attachAll(const yarp::dev::PolyDriverList& driverList)
{
if (driverList.size() > 1) {
yError() << LogPrefix << "This wrapper accepts only one attached PolyDriver";
Expand All @@ -232,7 +232,7 @@ bool HumanStateWrapper::attachAll(const yarp::dev::PolyDriverList& driverList)
return attach(driver->poly);
}

bool HumanStateWrapper::detachAll()
bool HumanState_nws_yarp::detachAll()
{
return detach();
}
Loading

0 comments on commit d3b48b1

Please sign in to comment.