GraspTrajectory.cpp
Go to the documentation of this file.
1/*
2 * This file is part of ArmarX.
3 *
4 * Copyright (C) 2012-2016, High Performance Humanoid Technologies (H2T),
5 * Karlsruhe Institute of Technology (KIT), all rights reserved.
6 *
7 * ArmarX is free software; you can redistribute it and/or modify
8 * it under the terms of the GNU General Public License version 2 as
9 * published by the Free Software Foundation.
10 *
11 * ArmarX is distributed in the hope that it will be useful, but
12 * WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details.
15 *
16 * You should have received a copy of the GNU General Public License
17 * along with this program. If not, see <http://www.gnu.org/licenses/>.
18 *
19 * @author Simon Ottenhaus (simon dot ottenhaus at kit dot edu)
20 * @copyright http://www.gnu.org/licenses/gpl-2.0.txt
21 * GNU General Public License
22 */
23
24#include "GraspTrajectory.h"
25
26#include <filesystem>
27#include <fstream>
28#include <memory>
29#include <optional>
30
31#include <SimoxUtility/json/eigen_conversion.h>
32#include <SimoxUtility/json/json.hpp>
33#include <VirtualRobot/RobotNodeSet.h>
34#include <VirtualRobot/math/Helpers.h>
35
43
46
47#include <RobotAPI/interface/units/GraspCandidateProviderInterface.h>
49
50namespace armarx
51{
52
53 Eigen::VectorXf
54 mapValuesToVector(const armarx::NameValueMap& map)
55 {
57 Eigen::VectorXf vector(map.size());
58 std::transform(
59 map.begin(), map.end(), vector.data(), [](const auto& item) { return item.second; });
60 return vector;
61 }
62
63 void
64 GraspTrajectory::writeToFile(const std::string& filename)
65 {
67 RapidXmlWriter writer;
68 RapidXmlWriterNode root = writer.createRootNode("GraspTrajectory");
69 for (const KeypointPtr& keypoint : keypoints)
70 {
71 SimpleJsonLoggerEntry e;
72 e.Add("dt", keypoint->dt);
73 e.AddAsArr("Pose", keypoint->tcpTarget);
74 JsonObjectPtr const obj = std::make_shared<JsonObject>();
75 for (const auto& [name, value] : keypoint->handJointsTarget)
76 {
77 obj->add(name, JsonValue::Create(value));
78 }
79 e.obj->add("HandValues", obj);
80 root.append_string_node("Keypoint", e.obj->toJsonString(0, "", true));
81 }
82 writer.saveToFile(filename, true);
83 }
84
87 {
89 RapidXmlReaderNode const root = reader->getRoot();
90
92 for (const RapidXmlReaderNode& kpNode : root.nodes("Keypoint"))
93 {
94 StructuralJsonParser p(kpNode.value());
95 p.parse();
96 JPathNavigator nav(p.parsedJson);
97 float dt = nav.selectSingleNode("dt").asFloat();
98
99 Eigen::Matrix4f pose;
100 std::vector<JPathNavigator> rows = nav.select("Pose/*");
101 for (int i = 0; i < 4; i++)
102 {
103 std::vector<JPathNavigator> cells = rows.at(i).select("*");
104 for (int j = 0; j < 4; j++)
105 {
106 pose(i, j) = cells.at(j).asFloat();
107 }
108 }
109
110 armarx::NameValueMap handValues;
111 std::vector<JPathNavigator> cells = nav.select("HandValues/*");
112 for (const auto& cell : cells)
113 {
114 handValues[cell.getKey()] = cell.asFloat();
115 }
116
117 // does not work at the moment
118 const auto shapeNode = nav.selectSingleNode("shape");
119 // ARMARX_IMPORTANT << VAROUT(shapeNode.isValid());
120
121 std::optional<std::string> shape;
122 if (shapeNode.isString())
123 {
124 shape = nav.selectSingleNode("shape").asString();
125 // ARMARX_IMPORTANT << "shape: " << shape.value();
126 }
127
128
129 if (!traj)
130 {
131 traj = std::make_shared<GraspTrajectory>(pose, handValues, shape);
132 }
133 else
134 {
135 traj->addKeypoint(pose, handValues, dt, shape);
136 }
137 }
138 return traj;
139 }
140
142 GraspTrajectory::ReadFromFile(const std::string& filename)
143 {
145 const auto ext = std::filesystem::path(filename).extension();
146 if (ext == ".xml")
147 {
149 }
150 if (ext == ".json")
151 {
152 return ReadFromJSON(filename);
153 }
154
155 ARMARX_WARNING << "Unknown extension `" << ext << "`!";
156 return nullptr;
157 }
158
159 // NLOHMANN_DEFINE_TYPE_NON_INTRUSIVE(GraspTrajectory::Keypoint,tcpTarget,handJointsTarget,shape,dt );
160
161
162 inline void
163 from_json(const nlohmann::json& j, GraspTrajectoryKeypoint& kp)
164 {
166 std::optional<std::string> shape;
167
168 if (j.contains("shape"))
169 {
170 if (not j.at("shape").is_null())
171 {
172 shape = j.at("shape");
173 }
174 }
175
177 std::optional<std::map<std::string, float>> targetHandValues;
178
179 if (j.contains("fingerValues"))
180 {
181 if (not j.at("fingerValues").is_null())
182 {
183 targetHandValues = j.at("fingerValues");
184 }
185 }
186
187 // VERY hacky!
188 const Eigen::Matrix<float, 4, 4, Eigen::RowMajor> aronTf = j.at("pose");
189 const Eigen::Matrix4f tf = aronTf.transpose();
190
191 ARMARX_IMPORTANT << tf;
192
195 tf, targetHandValues.value_or(std::map<std::string, float>{}), shape);
196 }
197
199 GraspTrajectory::ReadFromJSON(const std::string& filename)
200 {
201 ARMARX_CHECK(std::filesystem::exists(filename));
202 ARMARX_INFO << "Reading from file `" << filename << "`";
203
204 std::ifstream ifs(filename);
205
206 const nlohmann::json j = nlohmann::json::parse(ifs);
207
208 std::vector<GraspTrajectoryKeypoint> traj;
209 traj = j.at("keypoints");
210
211 const armarx::Duration duration =
212 armarx::Duration::MicroSeconds(j.at("duration").at("microSeconds").get<std::int64_t>());
213
214 // at the moment, we assume that all keypoints are sampled equidistant
215
217 const float dtSeconds = duration.toSecondsDouble() / (traj.size() - 1);
218 ARMARX_VERBOSE << VAROUT(dtSeconds);
219
220 for (auto& kp : traj)
221 {
222 kp.dt = dtSeconds;
223 }
224
225 const std::string frame = j.at("frame").at("frame");
226
227 auto graspTrajectory = std::make_shared<GraspTrajectory>(traj);
228 graspTrajectory->setFrame(frame);
229
230 return graspTrajectory;
231 }
232
234 GraspTrajectory::ReadFromString(const std::string& xml)
235 {
238 }
239
240 GraspTrajectory::GraspTrajectory(const Eigen::Matrix4f& tcpStart,
241 const armarx::NameValueMap& handJointsStart,
242 const std::optional<std::string>& shape)
243 {
245 KeypointPtr keypoint(new Keypoint(tcpStart, handJointsStart, shape));
246 keypointMap[0] = keypoints.size();
247 keypoints.push_back(keypoint);
248 }
249
250 GraspTrajectory::GraspTrajectory(const std::vector<Keypoint>& keypointz)
251 {
252 if (keypointz.empty())
253 {
254 return;
255 }
256
257 // insert first keypoint
258 keypointMap[0] = keypoints.size();
259 keypoints.push_back(std::make_shared<Keypoint>(keypointz.front()));
260
261 // insert remaining keypoints
262 for (std::size_t i = 1; i < keypointz.size(); i++)
263 {
264 const auto& kp = keypointz.at(i);
265 addKeypoint(kp.tcpTarget, kp.handJointsTarget, kp.dt, kp.shape);
266 }
267 }
268
269 void
270 GraspTrajectory::addKeypoint(const Eigen::Matrix4f& tcpTarget,
271 const armarx::NameValueMap& handJointsTarget,
272 float dt,
273 const std::optional<std::string>& shape)
274 {
276 KeypointPtr prev = lastKeypoint();
277 KeypointPtr keypoint(new Keypoint(tcpTarget, handJointsTarget, shape));
278 keypoint->updateVelocities(prev, dt);
279 float t = getDuration() + dt;
280 keypointMap[t] = keypoints.size();
281 keypoints.push_back(keypoint);
282 }
283
284 size_t
286 {
288 return keypoints.size();
289 }
290
291 const std::vector<GraspTrajectory::KeypointPtr>&
293 {
294 return keypoints;
295 }
296
297 void
299 const Eigen::Matrix4f& tcpTarget,
300 const armarx::NameValueMap& handJointsTarget,
301 float dt,
302 const std::optional<std::string>& shape)
303 {
305 if (index <= 0 || index > keypoints.size())
306 {
307 throw LocalException("Index out of range" + std::to_string(index));
308 }
309 KeypointPtr prev = keypoints.at(index - 1);
310 KeypointPtr keypoint(new Keypoint(tcpTarget, handJointsTarget, shape));
311 keypoint->updateVelocities(prev, dt);
312 if (index < keypoints.size())
313 {
314 KeypointPtr next = keypoints.at(index);
315 next->updateVelocities(keypoint, next->dt);
316 }
317 keypoints.insert(keypoints.begin() + index, keypoint);
318 updateKeypointMap();
319 }
320
321 void
323 {
325 if (index <= 0 || index >= keypoints.size())
326 {
327 throw LocalException("Index out of range" + std::to_string(index));
328 }
329 keypoints.erase(keypoints.begin() + index);
330 if (index < keypoints.size())
331 {
333 KeypointPtr prev = keypoints.at(index - 1);
334 KeypointPtr next = keypoints.at(index);
335 next->updateVelocities(prev, next->dt);
336 }
337 updateKeypointMap();
338 }
339
340 void
342 const Eigen::Matrix4f& tcpTarget,
343 const armarx::NameValueMap& handJointsTarget,
344 float dt,
345 const std::optional<std::string>& shape)
346 {
348 if (index <= 0 || index >= keypoints.size())
349 {
350 throw LocalException("Index out of range" + std::to_string(index));
351 }
352 KeypointPtr prev = keypoints.at(index - 1);
353 KeypointPtr keypoint(new Keypoint(tcpTarget, handJointsTarget, shape));
354 keypoint->updateVelocities(prev, dt);
355 keypoints.at(index) = keypoint;
356 updateKeypointMap();
357 }
358
359 void
361 {
363 if (index <= 0 || index >= keypoints.size())
364 {
365 throw LocalException("Index out of range" + std::to_string(index));
366 }
367 KeypointPtr prev = keypoints.at(index - 1);
368 KeypointPtr& keypoint = keypoints.at(index);
369 keypoint->updateVelocities(prev, dt);
370 updateKeypointMap();
371 }
372
375 {
377 return keypoints.at(keypoints.size() - 1);
378 }
379
382 {
384 return keypoints.at(i);
385 }
386
387 Eigen::Matrix4f
389 {
391 return getKeypoint(0)->getTargetPose();
392 }
393
394 void
395 GraspTrajectory::getIndex(float t, int& i1, int& i2, float& f) const
396 {
398 if (t <= 0)
399 {
400 i1 = 0;
401 i2 = 0;
402 f = 0;
403 return;
404 }
405 std::map<float, size_t>::const_iterator it, prev;
406 it = keypointMap.upper_bound(t);
407 if (it == keypointMap.end())
408 {
409 i1 = keypoints.size() - 1;
410 i2 = keypoints.size() - 1;
411 f = 0;
412 return;
413 }
414 prev = std::prev(it);
415 i1 = prev->second;
416 i2 = it->second;
417 f = ::math::Helpers::ILerp(prev->first, it->first, t);
418 }
419
420 Eigen::Vector3f
422 {
424 int i1, i2;
425 float f;
426 getIndex(t, i1, i2, f);
427 return ::math::Helpers::Lerp(
428 getKeypoint(i1)->getTargetPosition(), getKeypoint(i2)->getTargetPosition(), f);
429 }
430
431 Eigen::Matrix3f
433 {
435 int i1, i2;
436 float f;
437 getIndex(t, i1, i2, f);
438 Eigen::Vector3f oriVel = GetOrientationDerivative(t);
439 if (oriVel.squaredNorm() == 0)
440 {
441 return getKeypoint(i1)->getTargetOrientation();
442 }
443 Eigen::AngleAxisf aa(oriVel.norm(), oriVel.normalized());
444 aa.angle() = aa.angle() * f * getKeypoint(i2)->dt;
445 return aa.toRotationMatrix() * getKeypoint(i1)->getTargetOrientation();
446 }
447
448 Eigen::Matrix4f
450 {
452 return ::math::Helpers::CreatePose(GetPosition(t), GetOrientation(t));
453 }
454
455 std::vector<Eigen::Matrix4f>
457 {
459 std::vector<Eigen::Matrix4f> res;
460 for (const KeypointPtr& keypoint : keypoints)
461 {
462 res.emplace_back(keypoint->getTargetPose());
463 }
464 return res;
465 }
466
467 std::vector<Eigen::Vector3f>
469 {
471 std::vector<Eigen::Vector3f> res;
472 for (const KeypointPtr& keypoint : keypoints)
473 {
474 res.emplace_back(keypoint->getTargetPosition());
475 }
476 return res;
477 }
478
479 std::vector<Eigen::Matrix3f>
481 {
483 std::vector<Eigen::Matrix3f> res;
484 for (const KeypointPtr& keypoint : keypoints)
485 {
486 res.emplace_back(keypoint->getTargetOrientation());
487 }
488 return res;
489 }
490
491 armarx::NameValueMap
493 {
495 int i1, i2;
496 float f;
497 getIndex(t, i1, i2, f);
498 auto handTargetsMap = getKeypoint(i1)->handJointsTarget;
499 const auto handTargets1 = mapValuesToVector(handTargetsMap);
500 const auto handTargets2 = mapValuesToVector(getKeypoint(i2)->handJointsTarget);
501 const Eigen::VectorXf lerpTargets = handTargets1 * (1 - f) + handTargets2 * f;
502 auto* lerpTargetsIt = lerpTargets.data();
503 for (auto& [name, value] : handTargetsMap)
504 {
505 value = *(lerpTargetsIt++);
506 }
507 return handTargetsMap;
508 }
509
510 std::optional<std::string>
512 {
514 int i1, i2;
515 float f;
516 getIndex(t, i1, i2, f);
517
518 // i1 is the one before or at the timestamp t
519 return getKeypoint(i1)->shape;
520 }
521
522 Eigen::Vector3f
524 {
526 int i1, i2;
527 float f;
528 getIndex(t, i1, i2, f);
529 return getKeypoint(i2)->feedForwardPosVelocity;
530 }
531
532 Eigen::Vector3f
534 {
536 int i1, i2;
537 float f;
538 getIndex(t, i1, i2, f);
539 return getKeypoint(i2)->feedForwardOriVelocity;
540 }
541
544 {
547 ffVel.block<3, 1>(0, 0) = GetPositionDerivative(t);
548 ffVel.block<3, 1>(3, 0) = GetOrientationDerivative(t);
549 return ffVel;
550 }
551
552 Eigen::Vector3f
554 {
556 int i1, i2;
557 float f;
558 getIndex(t, i1, i2, f);
559 return getKeypoint(i2)->feedForwardHandJointsVelocity;
560 }
561
562 float
564 {
566 return keypointMap.rbegin()->first;
567 }
568
569 GraspTrajectory::Length
571 {
573 Length l;
574 for (size_t i = 1; i < keypoints.size(); i++)
575 {
576 KeypointPtr k0 = keypoints.at(i - 1);
577 KeypointPtr k1 = keypoints.at(i);
578
579 Eigen::Vector3f pos0 = ::math::Helpers::GetPosition(k0->tcpTarget);
580 Eigen::Matrix3f ori0 = ::math::Helpers::GetOrientation(k0->tcpTarget);
581
582 Eigen::Vector3f pos1 = ::math::Helpers::GetPosition(k1->tcpTarget);
583 Eigen::Matrix3f ori1 = ::math::Helpers::GetOrientation(k1->tcpTarget);
584
585 l.pos += (pos1 - pos0).norm();
586 l.ori += fabs(::math::Helpers::GetAngleAxisFromTo(ori0, ori1).angle());
587 }
588 return l;
589 }
590
592 GraspTrajectory::getTranslatedAndRotated(const Eigen::Vector3f& translation,
593 const Eigen::Matrix3f& rotation) const
594 {
597 new GraspTrajectory(::math::Helpers::TranslateAndRotatePose(
598 getKeypoint(0)->getTargetPose(), translation, rotation),
599 getKeypoint(0)->handJointsTarget));
600 for (size_t i = 1; i < keypoints.size(); i++)
601 {
602 const KeypointPtr& kp = keypoints.at(i);
603 traj->addKeypoint(
604 ::math::Helpers::TranslateAndRotatePose(kp->getTargetPose(), translation, rotation),
605 kp->handJointsTarget,
606 kp->dt,
607 kp->shape);
608 }
609 return traj;
610 }
611
613 GraspTrajectory::getTransformed(const Eigen::Matrix4f& transform) const
614 {
617 transform * getStartPose(), getKeypoint(0)->handJointsTarget, getKeypoint(0)->shape));
618 for (size_t i = 1; i < keypoints.size(); i++)
619 {
620 const KeypointPtr& kp = keypoints.at(i);
621 traj->addKeypoint(
622 transform * kp->getTargetPose(), kp->handJointsTarget, kp->dt, kp->shape);
623 }
624 return traj;
625 }
626
629 {
631 return getTransformed(Eigen::Matrix4f::Identity());
632 }
633
635 GraspTrajectory::getTransformedToGraspPose(const Eigen::Matrix4f& target,
636 const Eigen::Vector3f& handForward) const
637 {
639 Eigen::Matrix4f startPose = getStartPose();
640 Eigen::Vector3f targetHandForward =
641 ::math::Helpers::TransformDirection(target, handForward);
642 Eigen::Vector3f trajHandForward =
643 ::math::Helpers::TransformDirection(startPose, handForward);
644 Eigen::Vector3f up(0, 0, 1);
645
646 float angle = ::math::Helpers::Angle(targetHandForward, trajHandForward, up);
647 Eigen::AngleAxisf aa(angle, up);
648
649 Eigen::Matrix4f transform = ::math::Helpers::CreateTranslationRotationTranslationPose(
650 -::math::Helpers::GetPosition(startPose),
651 aa.toRotationMatrix(),
652 ::math::Helpers::GetPosition(target));
654 }
655
658 {
660 Eigen::Matrix3f flip_yz = Eigen::Matrix3f::Identity();
661 flip_yz(0, 0) *= -1.0;
662 Eigen::Matrix4f start_pose = getStartPose();
663 start_pose.block<3, 3>(0, 0) = flip_yz * start_pose.block<3, 3>(0, 0) * flip_yz;
664 GraspTrajectoryPtr output_trajectory(
665 new GraspTrajectory(start_pose, getKeypoint(0)->handJointsTarget));
666 for (size_t i = 1; i < getKeypointCount(); i++)
667 {
669 Eigen::Matrix4f target_pose = kp->getTargetPose();
670 target_pose.block<3, 3>(0, 0) = flip_yz * target_pose.block<3, 3>(0, 0) * flip_yz;
671 output_trajectory->addKeypoint(target_pose, kp->handJointsTarget, kp->dt, kp->shape);
672 }
673 return output_trajectory;
674 }
675
677 GraspTrajectory::calculateReachability(VirtualRobot::RobotNodeSetPtr rns,
678 VirtualRobot::RobotNodePtr tcp,
680 {
683 getAllKeypointPoses(), Eigen::VectorXf::Zero(rns->getSize()), rns, tcp, params);
684 }
685
686 void
687 GraspTrajectory::updateKeypointMap()
688 {
690 keypointMap.clear();
691 float t = 0;
692 for (size_t i = 0; i < keypoints.size(); i++)
693 {
694 t += getKeypoint(i)->dt;
695 keypointMap[t] = i;
696 }
697 }
698
699 void
701 float deltat)
702 {
704 Eigen::Vector3f pos0 = ::math::Helpers::GetPosition(prev->tcpTarget);
705 Eigen::Matrix3f ori0 = ::math::Helpers::GetOrientation(prev->tcpTarget);
706 auto hnd0 = mapValuesToVector(prev->handJointsTarget);
707
708 Eigen::Vector3f pos1 = ::math::Helpers::GetPosition(tcpTarget);
709 Eigen::Matrix3f ori1 = ::math::Helpers::GetOrientation(tcpTarget);
711
712 Eigen::Vector3f dpos = pos1 - pos0;
713 Eigen::Vector3f dori = ::math::Helpers::GetRotationVector(ori0, ori1);
714 Eigen::VectorXf dhnd = hnd1 - hnd0;
715
716 this->dt = deltat;
717 feedForwardPosVelocity = dpos / deltat;
718 feedForwardOriVelocity = dori / deltat;
719 feedForwardHandJointsVelocity = dhnd / deltat;
720 }
721
722 Eigen::Vector3f
724 {
726 return ::math::Helpers::GetPosition(tcpTarget);
727 }
728
729 Eigen::Matrix3f
731 {
733 return ::math::Helpers::GetOrientation(tcpTarget);
734 }
735
736 Eigen::Matrix4f
738 {
740 return tcpTarget;
741 }
742
744 const Eigen::Matrix4f& tcpTarget,
745 const armarx::NameValueMap& handJointsTarget,
746 float dt,
747 const Eigen::Vector3f& feedForwardPosVelocity,
748 const Eigen::Vector3f& feedForwardOriVelocity,
749 const Eigen::VectorXf& feedForwardHandJointsVelocity,
750 const std::optional<std::string>& shape) :
753 shape(shape),
754 dt(dt),
758 {
759 }
760
762 const armarx::NameValueMap& handJointsTarget,
763 const std::optional<std::string>& shape) :
766 shape(shape),
767 dt(0),
768 feedForwardPosVelocity(0, 0, 0),
770 {
771 }
772
773 void
774 GraspTrajectory::setFrame(const std::string& frame)
775 {
776 frame_ = frame;
777 }
778
779 const std::optional<std::string>&
781 {
782 return frame_;
783 }
784} // namespace armarx
uint8_t index
#define ARMARX_CHECK_NOT_EMPTY(c)
#define VAROUT(x)
constexpr T dt
static Duration MicroSeconds(std::int64_t microSeconds)
Constructs a duration in microseconds.
Definition Duration.cpp:24
Eigen::Matrix3f getTargetOrientation() const
void updateVelocities(const GraspTrajectoryKeypointPtr &prev, float deltat)
armarx::NameValueMap handJointsTarget
Eigen::VectorXf feedForwardHandJointsVelocity
Eigen::Vector3f getTargetPosition() const
Eigen::Matrix4f getTargetPose() const
std::optional< std::string > shape
Eigen::VectorXf GetHandValues(float t)
void removeKeypoint(size_t index)
std::optional< std::string > GetShape(float t) const
Eigen::Vector3f GetOrientationDerivative(float t)
Eigen::Matrix4f getStartPose()
Eigen::Matrix4f GetPose(float t)
const std::vector< KeypointPtr > & getAllKeypoints() const
SimpleDiffIK::Reachability calculateReachability(VirtualRobot::RobotNodeSetPtr rns, VirtualRobot::RobotNodePtr tcp=VirtualRobot::RobotNodePtr(), SimpleDiffIK::Parameters params=SimpleDiffIK::Parameters())
Eigen::Vector3f GetPositionDerivative(float t)
void addKeypoint(const Eigen::Matrix4f &tcpTarget, const Eigen::VectorXf &handJointsTarget, float dt)
void setFrame(const std::string &frame)
GraspTrajectoryPtr getClone()
static GraspTrajectoryPtr ReadFromJSON(const std::string &filename)
GraspTrajectoryPtr getTranslatedAndRotated(const Eigen::Vector3f &translation, const Eigen::Matrix3f &rotation)
static GraspTrajectoryPtr ReadFromString(const std::string &xml)
GraspTrajectoryPtr getTransformedToOtherHand() const
const std::optional< std::string > & getFrame() const
std::vector< Eigen::Vector3f > getAllKeypointPositions()
Eigen::Vector3f GetPosition(float t)
GraspTrajectoryKeypoint Keypoint
void setKeypointDt(size_t index, float dt)
std::vector< Eigen::Matrix3f > getAllKeypointOrientations()
std::shared_ptr< Keypoint > KeypointPtr
void replaceKeypoint(size_t index, const Eigen::Matrix4f &tcpTarget, const Eigen::VectorXf &handJointsTarget, float dt)
Eigen::VectorXf GetHandJointsDerivative(float t)
GraspTrajectoryPtr getTransformed(const Eigen::Matrix4f &transform)
KeypointPtr & getKeypoint(int i)
void getIndex(float t, int &i1, int &i2, float &f)
std::vector< Eigen::Matrix4f > getAllKeypointPoses()
Eigen::Matrix3f GetOrientation(float t)
void insertKeypoint(size_t index, const Eigen::Matrix4f &tcpTarget, const Eigen::VectorXf &handJointsTarget, float dt)
GraspTrajectoryPtr getTransformedToGraspPose(const Eigen::Matrix4f &target, const Eigen::Vector3f &handForward=Eigen::Vector3f::UnitZ())
static GraspTrajectoryPtr ReadFromReader(const RapidXmlReaderPtr &reader)
Eigen::Vector6f GetTcpDerivative(float t)
static GraspTrajectoryPtr ReadFromFile(const grasping::GraspCandidatePtr &cnd)
void writeToFile(const std::string &filename)
static JsonValuePtr Create(const std::string &value)
Definition JsonValue.cpp:72
static RapidXmlReaderPtr FromFile(const std::string &path)
static RapidXmlReaderPtr FromXmlString(const std::string &xml)
static Reachability CalculateReachability(const std::vector< Eigen::Matrix4f > targets, const Eigen::VectorXf &initialJV, VirtualRobot::RobotNodeSetPtr rns, VirtualRobot::RobotNodePtr tcp=VirtualRobot::RobotNodePtr(), Parameters params=Parameters())
Use this to check a trajectory of waypoints.
Represents a duration.
Definition Duration.h:17
double toSecondsDouble() const
Returns the amount of seconds.
Definition Duration.cpp:90
#define ARMARX_CHECK(expression)
Shortcut for ARMARX_CHECK_EXPRESSION.
#define ARMARX_INFO
The normal logging level.
Definition Logging.h:181
#define ARMARX_IMPORTANT
The logging level for always important information, but expected behaviour (in contrast to ARMARX_WAR...
Definition Logging.h:190
#define ARMARX_WARNING
The logging level for unexpected behaviour, but not a serious problem.
Definition Logging.h:193
#define ARMARX_VERBOSE
The logging level for verbose information.
Definition Logging.h:187
This file offers overloads of toIce() and fromIce() functions for STL container types.
Eigen::VectorXf mapValuesToVector(const armarx::NameValueMap &map)
std::shared_ptr< RapidXmlReader > RapidXmlReaderPtr
std::shared_ptr< JsonObject > JsonObjectPtr
Definition JsonObject.h:34
auto transform(const Container< InputT, Alloc > &in, OutputT(*func)(InputT const &)) -> Container< OutputT, typename std::allocator_traits< Alloc >::template rebind_alloc< OutputT > >
Convenience function (with less typing) to transform a container of type InputT into the same contain...
Definition algorithm.h:351
void from_json(const nlohmann::json &j, Vector2f &value)
std::shared_ptr< class GraspTrajectory > GraspTrajectoryPtr
double norm(const Point &a)
Definition point.hpp:102
double angle(const Point &a, const Point &b, const Point &c)
Definition point.hpp:109
#define ARMARX_TRACE
Definition trace.h:77