28#include <SimoxUtility/algorithm/string/string_tools.h>
37 usingTopic(
"ForceTorqueDynamicSimulationValues");
41 frames = simox::alg::split(framesStr,
",;");
42 ARMARX_INFO <<
"ForceTorqueUnit initialized." << std::endl
43 <<
"AgentName: " <<
agentName <<
". " << std::endl
44 <<
"Report Frames: " <<
frames;
45 auto sensorRobotNodeSplit =
47 for (
auto& elem : sensorRobotNodeSplit)
49 simox::alg::trim(elem);
50 std::vector<std::string>
split = simox::alg::split(elem,
":");
51 if (
split.size() == 2)
54 simox::alg::trim_copy(
split[1]);
64 ARMARX_INFO <<
"Starting ForceTorqueUnit, requesting robot from RobotStateComponent...";
71 sharedRobot = robotStateComponent->getSynchronizedRobot();
83 if (!frame.empty() && !
remoteRobot->hasRobotNode(frame))
86 << frame <<
"'. Will not report FT values in this frame...";
105 const Vector3BasePtr& torque,
106 const std::string& sensorName,
107 const std::string& nodeName,
109 const Ice::Current&
c)
122 if (sensorName != nodeName &&
remoteRobot->hasRobotNode(sensorName))
125 framedTorque->changeFrame(
remoteRobot, sensorName);
130 prx->reportSensorValues(sensorName, framedForce, framedTorque);
133 for (
auto& frame :
frames)
135 if (!frame.empty() &&
remoteRobot->hasRobotNode(frame))
143 prx->reportSensorValues(sensorName, framedForce1, framedTorque1);
156 framedForce1->changeFrame(
remoteRobot, it->second);
157 framedTorque1->changeFrame(
remoteRobot, it->second);
158 prx->reportSensorValues(it->second, framedForce1, framedTorque1);
160 << framedForce1->output() <<
"\n"
161 << framedTorque1->output();
169 prx->ice_flushBatchRequests();
180 const std::string& sensorName,
181 const Vector3BasePtr& torques,
182 std::map<std::string, DatafieldFilterBasePtr>&
filters)
184 auto filter = [&,
this](
const std::string& dim,
float value)
186 const auto name = sensorName + dim;
194 auto& filterX = *itX->second;
195 filterX.update(0,
new Variant(value));
196 double r = filterX.getValue()->getDouble();
201 Vector3BasePtr result =
202 new Vector3(filter(
"x", torques->x), filter(
"y", torques->y), filter(
"z", torques->z));
208 const armarx::FramedDirectionBasePtr&,
223 return "ForceTorqueUnitDynamicSimulation";
#define ARMARX_REGISTER_COMPONENT_EXECUTABLE(ComponentT, applicationName)
SpamFilterDataPtr deactivateSpam(SpamFilterDataPtr const &spamFilter, float deactivationDurationSec, const std::string &identifier, bool deactivate)
std::string getConfigIdentifier()
Retrieve config identifier for this component as set in constructor.
Property< PropertyType > getProperty(const std::string &name)
This unit connects to the physics simulator topic (default: "Simulator") and reports force torque val...
VirtualRobot::RobotPtr remoteRobot
void setToNull(const Ice::Current &) override
std::map< std::string, DatafieldFilterBasePtr > forceFilters
Vector3BasePtr filterValues(const std::string &sensorName, const Vector3BasePtr &torques, std::map< std::string, DatafieldFilterBasePtr > &filters)
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
std::map< std::string, DatafieldFilterBasePtr > torqueFilters
SharedRobotInterfacePrx sharedRobot
void setOffset(const FramedDirectionBasePtr &, const FramedDirectionBasePtr &, const Ice::Current &) override
void onExitForceTorqueUnit() override
void onStartForceTorqueUnit() override
std::vector< std::string > frames
PropertyDefinitionsPtr createPropertyDefinitions() override
static std::string GetDefaultName()
void onInitForceTorqueUnit() override
armarx::StringStringDictionary sensorRobotNodeMapping
ForceTorqueUnitListenerPrx listenerPrx
FramedDirection is a 3 dimensional direction vector with a reference frame.
bool usingProxy(const std::string &name, const std::string &endpoints="")
Registers a proxy for retrieval after initialization and adds it to the dependency list.
void terminate()
Initiates termination of this IceManagedObject.
void usingTopic(const std::string &name, bool orderedPublishing=false)
Registers a proxy for subscription after initialization.
Ice::ObjectPrx getProxy(long timeoutMs=0, bool waitForScheduler=true) const
Returns the proxy of this object (optionally it waits for the proxy)
VirtualRobot::RobotPtr createLocalClone()
Clones the structure of this remote robot to a local instance.
static bool synchronizeLocalClone(VirtualRobot::RobotPtr robot, RobotStateComponentInterfacePrx robotStatePrx)
The Variant class is described here: Variants.
#define ARMARX_INFO
The normal logging level.
#define ARMARX_DEBUG
The logging level for output that is only interesting while debugging.
#define ARMARX_WARNING
The logging level for unexpected behaviour, but not a serious problem.
This file offers overloads of toIce() and fromIce() functions for STL container types.
std::vector< std::string > split(const std::string &source, const std::string &splitBy, bool trimElements=false, bool removeEmptyElements=false)
IceInternal::Handle< Vector3 > Vector3Ptr
std::vector< std::string > Split(const std::string &source, const std::string &splitBy, bool trimElements=false, bool removeEmptyElements=false)
IceInternal::Handle< FramedDirection > FramedDirectionPtr
IceUtil::Handle< class PropertyDefinitionContainer > PropertyDefinitionsPtr
PropertyDefinitions smart pointer type.
::IceInternal::ProxyHandle<::IceProxy::armarx::RobotStateComponentInterface > RobotStateComponentInterfacePrx