9 joint_control::arondto::MoveJointsToPositionAcceptedType
10 GetDefaultParameterization()
12 joint_control::arondto::MoveJointsToPositionAcceptedType ret;
13 ret.jointTargetTolerance = 0.05;
19 "MoveJointsToPosition",
20 "Move the joints to position",
23 joint_control::arondto::MoveJointsToPositionAcceptedType::ToAronType(),
24 GetDefaultParameterization().toAron()};
37 MoveJointsToPosition::reset()
39 already_running =
false;
43 MoveJointsToPosition::init(
const SpecializedInitInput& in)
50 MoveJointsToPosition::step(
const SpecializedMainInput& in)
55 ARMARX_WARNING <<
"Unable to get robot from robotstatememory. Abort.";
65 std::map<std::string, float> filteredTargets;
66 auto currentValues = robot->jointMap;
67 for (
const auto& [key, val] : in.parameters.targetJointMap)
69 if (
const auto& it = currentValues.find(key); it != currentValues.end())
72 << it->second <<
" and it will be set to " << val;
73 filteredTargets.insert({key, val});
77 if (filteredTargets.size() == 0)
82 auto currentJointValueTolerance = in.parameters.jointTargetTolerance;
84 <<
"Joint target tolerance: " << currentJointValueTolerance;
86 auto currentMaxDelta = std::numeric_limits<float>::max();
90 currentValues = robot->jointMap;
91 float maxDeltaTmp = 0;
92 for (
const auto& [key, value] : filteredTargets)
94 const float delta = fabs((value - currentValues.at(key)));
95 maxDeltaTmp = std::max(delta, maxDeltaTmp);
97 currentMaxDelta = maxDeltaTmp;
102 if (currentMaxDelta <= currentJointValueTolerance)
107 if (!already_running)
109 already_running =
true;
111 NameControlModeMap controlModes;
112 for (
const auto& p : filteredTargets)
114 controlModes[p.first] = ePositionControl;
116 context.kinematicUnitPrx->switchControlMode(controlModes);
118 context.kinematicUnitPrx->setJointAngles(filteredTargets);
124 MoveJointsToPosition::exit(
const SpecializedExitInput& in)
126 std::vector<std::string> joints;
127 std::for_each(in.parameters.targetJointMap.begin(),
128 in.parameters.targetJointMap.end(),
129 [&joints](
const std::pair<std::string, float>& p)
130 { joints.push_back(p.first); });
SpamFilterDataPtr deactivateSpam(SpamFilterDataPtr const &spamFilter, float deactivationDurationSec, const std::string &identifier, bool deactivate)
static Duration MilliSeconds(std::int64_t milliSeconds)
Constructs a duration in milliseconds.
The memory name system (MNS) client.
virtual void connect(armem::client::MemoryNameSystem &memoryNameSystem)
JointControlSkill(armem::client::MemoryNameSystem &mns, JointControlSkillContext &c)
JointControlSkillContext & context
TerminatedSkillStatus stopJointMovement(const std::vector< std::string > &joints)
armem::client::MemoryNameSystem & mns
MoveJointsToPosition(armem::client::MemoryNameSystem &mns, JointControlSkillContext &context)
static SkillDescription Description
#define ARMARX_INFO
The normal logging level.
#define ARMARX_IMPORTANT
The logging level for always important information, but expected behaviour (in contrast to ARMARX_WAR...
#define ARMARX_WARNING
The logging level for unexpected behaviour, but not a serious problem.
This file is part of ArmarX.
This file offers overloads of toIce() and fromIce() functions for STL container types.
A result struct for skill exit function.
armem::robot_state::VirtualRobotReader robotReader