59 for (
size_t i = 0; i < jointNames->getSize(); i++)
62 rsContext->
getDatafieldRef(tempChannelRef, jointNames->getVariant(i)->getString()));
65 NameValueMap jointNamesAndAngles;
66 NameValueMap jointNamesAndTorques;
67 NameControlModeMap controlModes;
71 if (jointNames->getSize() == jointAngles->getSize())
73 for (
int j = 0; j < jointNames->getSize(); j++)
75 jointNamesAndAngles[jointNames->getVariant(j)->getString()] =
76 jointAngles->getVariant(j)->getFloat();
77 jointNamesAndTorques[jointNames->getVariant(j)->getString()] =
79 controlModes[jointNames->getVariant(j)->getString()] = eTorqueControl;
80 currentJointAngles.
addVariant(jointAngles->getVariant(j)->getFloat());
81 currentJointNames.
addVariant(jointNames->getVariant(j)->getString());
86 throw LocalException(
"stateCheckObjectInHand: List lengths do not match!");
93 ARMARX_LOG << eINFO <<
"Installing timeoutGrasp condition";
94 float timeOutCheckObjectInHand =
getInput<float>(
"timeoOutCheckObjectInHand");
97 setLocal(
"TempJointAngles", currentJointAngles);
98 setLocal(
"TempJointNames", currentJointNames);
114 float threshhold = 0.0;
116 for (
size_t i = 0; i < jointNames->getSize(); i++)
119 rsContext->
getDatafieldRef(tempChannelRef, jointNames->getVariant(i)->getString()));
122 float meanSquaredJointAnglesDiff = 0.0;
124 for (
int j = 0; j < jointNames->getSize(); j++)
128 meanSquaredJointAnglesDiff += jointAngleDiff * jointAngleDiff;
131 meanSquaredJointAnglesDiff = sqrt(meanSquaredJointAnglesDiff);
133 if (meanSquaredJointAnglesDiff < threshhold)
158 return "CheckObjectInHand";
CheckObjectInHand(XMLStateConstructorParams stateData)
void onBreak() override
Virtual function, in which the behaviour of state is defined, when it is abnormally exited....
void onEnter() override
Virtual function, in which the behaviour of state is defined, when it is entered. Can be overridden,...
static std::string GetName()
ActionEventIdentifier condSqueezeWithJointTorquesTimeout
void onExit() override
Virtual function, in which the behaviour of state is defined, when it is exited. Can be overridden,...
static SubClassRegistry Registry
void run() override
Virtual function, that can be reimplemented to calculate complex operations.
static XMLStateFactoryBasePtr CreateInstance(XMLStateConstructorParams stateData)
KinematicUnitInterfacePrx kinematicUnitPrx
std::string getKinematicUnitObserverName()
The SingleTypeVariantList class is a subclass of VariantContainer and is comparable to a std::vector<...
void addVariant(const Variant &variant)
VariantPtr getVariant(int index) const
ContextType * getContext() const
bool isRunningTaskStopped() const
isRunningTaskStopped checks whether the RunningTask, that executes run() is requested to stop.
void removeTimeoutEvent(const ActionEventIdentifier &id)
ActionEventIdentifier setTimeoutEvent(int timeoutDurationMs, const EventPtr &evt)
Utility function to start a timer on the systemObserver and register an event on the conditionHandler...
EventPtr createEvent()
Utility function to create a new Event.
std::enable_if_t< std::is_base_of_v< VariantDataClass, T >, IceInternal::Handle< T > > getInput(const std::string &key) const
getInput can be used to access a specific input parameter.
std::enable_if_t< std::is_base_of_v< VariantDataClass, T >, IceInternal::Handle< T > > getLocal(const std::string &key) const
getLocal can be used to access a specific input parameter.
void setLocal(std::string const &key, const Variant &value)
setLocal() sets a local parameter.
DatafieldRefPtr getDatafieldRef(const DataFieldIdentifier &datafieldIdentifier) override
ChannelRefPtr getChannelRef(const std::string &observerName, const std::string &channelName) override
XMLStateTemplate(const XMLStateConstructorParams ¶ms)
#define ARMARX_VERBOSE
The logging level for verbose information.
const VariantTypeId DatafieldRef
This file offers overloads of toIce() and fromIce() functions for STL container types.
IceInternal::Handle< SingleTypeVariantList > SingleTypeVariantListPtr
IceInternal::Handle< ChannelRef > ChannelRefPtr
IceInternal::Handle< XMLStateFactoryBase > XMLStateFactoryBasePtr