9 joint_control::arondto::MoveJointsToPositionAcceptedType
10 GetDefaultParameterization()
12 joint_control::arondto::MoveJointsToPositionAcceptedType ret;
13 ret.jointTargetTolerance = 0.05;
19 .skillId = {.skillName =
"MoveJointsToPosition"},
20 .description =
"Move the joints to position",
21 .rootProfileDefaults = GetDefaultParameterization().toAron(),
23 .parametersType = joint_control::arondto::MoveJointsToPositionAcceptedType::ToAronType(),
49 PeriodicSkill::StepResult
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);
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); });
static Duration MilliSeconds(std::int64_t milliSeconds)
Constructs a duration in milliseconds.
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.
The memory name system (MNS) client.
virtual void connect(armem::client::MemoryNameSystem &memoryNameSystem)
std::optional< RobotState > queryState(const std::string &robotName, const armem::Time ×tamp) const
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
SimplePeriodicSpecializedSkill(const SkillDescription &skillDescription, const armarx::Frequency &frequency)
virtual InitResult init()
Override this method with the actual implementation.
virtual ExitResult exit()
Override this method with the actual implementation.
#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.
A result struct for skill initialization.
armem::robot_state::VirtualRobotReader robotReader