Go to the documentation of this file.
28 #include <SimoxUtility/algorithm/string/string_tools.h>
34 usingTopic(
"ForceTorqueDynamicSimulationValues");
35 agentName = getProperty<std::string>(
"AgentName").getValue();
37 std::string framesStr = getProperty<std::string>(
"ReportFrames").getValue();
39 ARMARX_INFO <<
"ForceTorqueUnit initialized." << std::endl <<
"AgentName: " <<
agentName <<
". " << std::endl <<
"Report Frames: " <<
frames;
40 auto sensorRobotNodeSplit =
armarx::Split(getProperty<std::string>(
"SensorRobotNodeMapping").getValue(),
",");
41 for (
auto& elem : sensorRobotNodeSplit)
43 simox::alg::trim(elem);
45 if (
split.size() == 2)
51 usingProxy(getProperty<std::string>(
"RobotStateComponentName").getValue());
56 ARMARX_INFO <<
"Starting ForceTorqueUnit, requesting robot from RobotStateComponent...";
60 RobotStateComponentInterfacePrx robotStateComponent = getProxy<RobotStateComponentInterfacePrx>(getProperty<std::string>(
"RobotStateComponentName").getValue());
61 sharedRobot = robotStateComponent->getSynchronizedRobot();
73 if (!frame.empty() && !
remoteRobot->hasRobotNode(frame))
75 ARMARX_WARNING <<
"Robot " <<
remoteRobot->getName() <<
" does not know report frame '" << frame <<
"'. Will not report FT values in this frame...";
104 if (sensorName != nodeName &&
remoteRobot->hasRobotNode(sensorName))
107 framedTorque->changeFrame(
remoteRobot, sensorName);
112 prx->reportSensorValues(sensorName, framedForce, framedTorque);
115 for (
auto& frame :
frames)
117 if (!frame.empty() &&
remoteRobot->hasRobotNode(frame))
123 prx->reportSensorValues(sensorName, framedForce1, framedTorque1);
134 framedForce1->changeFrame(
remoteRobot, it->second);
135 framedTorque1->changeFrame(
remoteRobot, it->second);
136 prx->reportSensorValues(it->second, framedForce1, framedTorque1);
137 ARMARX_DEBUG <<
deactivateSpam(1, it->second) <<
"Reporting " << it->second <<
": " << framedForce1->output() <<
"\n" << framedTorque1->output() ;
144 prx->ice_flushBatchRequests();
155 auto filter = [&,
this](
const std::string & dim,
float value)
157 const auto name = sensorName + dim;
158 auto itX = filters.find(name);
159 if (itX == filters.end())
162 itX = filters.find(name);
164 auto& filterX = *itX->second;
166 double r = filterX.getValue()->getDouble();
172 Vector3BasePtr result =
new Vector3(filter(
"x", torques->x),
173 filter(
"y", torques->y),
174 filter(
"z", torques->z));
The Variant class is described here: Variants.
static bool synchronizeLocalClone(VirtualRobot::RobotPtr robot, RobotStateComponentInterfacePrx robotStatePrx)
std::vector< std::string > Split(const std::string &source, const std::string &splitBy, bool trimElements=false, bool removeEmptyElements=false)
void onStartForceTorqueUnit() override
VirtualRobot::RobotPtr remoteRobot
void onExitForceTorqueUnit() override
Vector3BasePtr filterValues(const std::string &sensorName, const Vector3BasePtr &torques, std::map< std::string, DatafieldFilterBasePtr > &filters)
std::shared_ptr< Value > value()
void setToNull(const Ice::Current &) override
void terminate()
Initiates termination of this IceManagedObject.
armarx::StringStringDictionary sensorRobotNodeMapping
void onInitForceTorqueUnit() override
std::vector< std::string > frames
void usingTopic(const std::string &name, bool orderedPublishing=false)
Registers a proxy for subscription after initialization.
std::map< std::string, DatafieldFilterBasePtr > forceFilters
std::string getConfigIdentifier()
Retrieve config identifier for this component as set in constructor.
ForceTorqueUnitListenerPrx listenerPrx
const VariantTypeId FramedDirection
VirtualRobot::RobotPtr createLocalClone()
Clones the structure of this remote robot to a local instance.
PropertyDefinitionsPtr createPropertyDefinitions() override
SharedRobotInterfacePrx sharedRobot
SpamFilterDataPtr deactivateSpam(float deactivationDurationSec=10.0f, const std::string &identifier="", bool deactivate=true) const
disables the logging for the current line for the given amount of seconds.
void setOffset(const FramedDirectionBasePtr &, const FramedDirectionBasePtr &, const Ice::Current &) override
IceUtil::Handle< class PropertyDefinitionContainer > PropertyDefinitionsPtr
PropertyDefinitions smart pointer type.
void reportForceTorque(const Vector3BasePtr &force, const Vector3BasePtr &torque, const std::string &sensorName, const std::string &nodeName, bool aValueChanged, const Ice::Current &c=Ice::emptyCurrent) override
bool usingProxy(const std::string &name, const std::string &endpoints="")
Registers a proxy for retrieval after initialization and adds it to the dependency list.
This file offers overloads of toIce() and fromIce() functions for STL container types.
std::map< std::string, DatafieldFilterBasePtr > torqueFilters
std::vector< std::string > split(const std::string &source, const std::string &splitBy, bool trimElements=false, bool removeEmptyElements=false)