Skip to content

Commit

Permalink
Fix WrenchFrameTransformer
Browse files Browse the repository at this point in the history
  • Loading branch information
RiccardoGrieco authored and lrapetti committed Jul 14, 2022
1 parent f10dea4 commit c2848b1
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 8 deletions.
12 changes: 6 additions & 6 deletions devices/HumanWrenchProvider/HumanWrenchProvider.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ struct WrenchSourceData
WrenchSourceType type;

std::string outputFrame;
std::unique_ptr<IWrenchFrameTransformer> frameTransformer;
IWrenchFrameTransformer frameTransformer;

wearable::sensor::SensorName sensorName;
wearable::SensorPtr<const wearable::sensor::IForceTorque6DSensor> ftWearableSensor;
Expand Down Expand Up @@ -481,7 +481,7 @@ bool HumanWrenchProvider::open(yarp::os::Searchable& config)
}

// Store the transform
WrenchSourceData.frameTransformer->transform = {rotation, position};
WrenchSourceData.frameTransformer.transform = {rotation, position};

yDebug() << LogPrefix << "=============:";
yDebug() << LogPrefix << "New source :" << WrenchSourceData.name;
Expand Down Expand Up @@ -588,7 +588,7 @@ bool HumanWrenchProvider::open(yarp::os::Searchable& config)
}

// Store the wrench source data
pImpl->wrenchSources.emplace_back(std::move(WrenchSourceData));
pImpl->wrenchSources.emplace_back(WrenchSourceData);
}

// ===================
Expand Down Expand Up @@ -761,7 +761,7 @@ void HumanWrenchProvider::run()

// store the frame transform
auto worldToFrameRotation = pImpl->humanKinDynComp.getWorldTransform(forceSource.outputFrame).getRotation();
forceSource.frameTransformer->transform.setRotation(worldToFrameRotation.inverse());
forceSource.frameTransformer.transform.setRotation(worldToFrameRotation.inverse());
}

if (forceSource.type == WrenchSourceType::Robot) {
Expand Down Expand Up @@ -795,13 +795,13 @@ void HumanWrenchProvider::run()
robotFeetToHandsTransform; //RobotFoot_H_RobotHand

// Update the stored transform
forceSource.frameTransformer->transform = robotToHumanTransform;
forceSource.frameTransformer.transform = robotToHumanTransform;

// Get reaction wrenches for the robot
forceSource.wrench = forceSource.wrench * -1;
}

if (!forceSource.frameTransformer->transformWrenchFrame(forceSource.wrench, transformedWrench)) {
if (!forceSource.frameTransformer.transformWrenchFrame(forceSource.wrench, transformedWrench)) {
askToStop();
return;
}
Expand Down
1 change: 0 additions & 1 deletion devices/HumanWrenchProvider/WrenchFrameTransformers.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@ using namespace hde::devices::impl;
bool IWrenchFrameTransformer::transformWrenchFrame(const iDynTree::Wrench inputWrench,
iDynTree::Wrench& transformedWrench)
{
std::lock_guard<std::mutex> lock(_mutex);
transformedWrench = transform * inputWrench;
return true;
}
1 change: 0 additions & 1 deletion devices/HumanWrenchProvider/WrenchFrameTransformers.h
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,6 @@ class hde::devices::impl::IWrenchFrameTransformer
{
public:
iDynTree::Transform transform;
std::mutex _mutex;

IWrenchFrameTransformer() = default;
~IWrenchFrameTransformer() = default;
Expand Down

0 comments on commit c2848b1

Please sign in to comment.