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 
50 namespace armarx
51 {
52 
53  Eigen::VectorXf
55  {
57  Eigen::VectorXf vector(map.size());
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 
91  GraspTrajectoryPtr traj;
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  {
144  ARMARX_TRACE;
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  {
165  ARMARX_TRACE;
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 
176  ARMARX_TRACE;
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 
193  ARMARX_TRACE;
195  tf, targetHandValues.value_or(std::map<std::string, float>{}), shape);
196  }
197 
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  {
236  ARMARX_TRACE;
238  }
239 
241  const armarx::NameValueMap& handJointsStart,
242  const std::optional<std::string>& shape)
243  {
244  ARMARX_TRACE;
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
271  const armarx::NameValueMap& handJointsTarget,
272  float dt,
273  const std::optional<std::string>& shape)
274  {
275  ARMARX_TRACE;
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  {
287  ARMARX_TRACE;
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  {
304  ARMARX_TRACE;
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  {
324  ARMARX_TRACE;
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  {
332  ARMARX_TRACE;
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  {
347  ARMARX_TRACE;
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  {
362  ARMARX_TRACE;
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  {
376  ARMARX_TRACE;
377  return keypoints.at(keypoints.size() - 1);
378  }
379 
382  {
383  ARMARX_TRACE;
384  return keypoints.at(i);
385  }
386 
389  {
390  ARMARX_TRACE;
391  return getKeypoint(0)->getTargetPose();
392  }
393 
394  void
395  GraspTrajectory::getIndex(float t, int& i1, int& i2, float& f) const
396  {
397  ARMARX_TRACE;
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  {
423  ARMARX_TRACE;
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 
433  {
434  ARMARX_TRACE;
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 
450  {
451  ARMARX_TRACE;
452  return ::math::Helpers::CreatePose(GetPosition(t), GetOrientation(t));
453  }
454 
455  std::vector<Eigen::Matrix4f>
457  {
458  ARMARX_TRACE;
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  {
470  ARMARX_TRACE;
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  {
482  ARMARX_TRACE;
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 
493  {
494  ARMARX_TRACE;
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  {
513  ARMARX_TRACE;
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  {
525  ARMARX_TRACE;
526  int i1, i2;
527  float f;
528  getIndex(t, i1, i2, f);
529  return getKeypoint(i2)->feedForwardPosVelocity;
530  }
531 
532  Eigen::Vector3f
534  {
535  ARMARX_TRACE;
536  int i1, i2;
537  float f;
538  getIndex(t, i1, i2, f);
539  return getKeypoint(i2)->feedForwardOriVelocity;
540  }
541 
544  {
545  ARMARX_TRACE;
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  {
555  ARMARX_TRACE;
556  int i1, i2;
557  float f;
558  getIndex(t, i1, i2, f);
559  return getKeypoint(i2)->feedForwardHandJointsVelocity;
560  }
561 
562  float
564  {
565  ARMARX_TRACE;
566  return keypointMap.rbegin()->first;
567  }
568 
569  GraspTrajectory::Length
571  {
572  ARMARX_TRACE;
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  {
595  ARMARX_TRACE;
596  GraspTrajectoryPtr traj(
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 
614  {
615  ARMARX_TRACE;
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  {
630  ARMARX_TRACE;
632  }
633 
636  const Eigen::Vector3f& handForward) const
637  {
638  ARMARX_TRACE;
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));
653  return getTransformed(transform);
654  }
655 
658  {
659  ARMARX_TRACE;
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  {
681  ARMARX_TRACE;
683  getAllKeypointPoses(), Eigen::VectorXf::Zero(rns->getSize()), rns, tcp, params);
684  }
685 
686  void
687  GraspTrajectory::updateKeypointMap()
688  {
689  ARMARX_TRACE;
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  {
703  ARMARX_TRACE;
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);
710  auto hnd1 = mapValuesToVector(handJointsTarget);
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  {
725  ARMARX_TRACE;
726  return ::math::Helpers::GetPosition(tcpTarget);
727  }
728 
731  {
732  ARMARX_TRACE;
733  return ::math::Helpers::GetOrientation(tcpTarget);
734  }
735 
738  {
739  ARMARX_TRACE;
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) :
751  tcpTarget(tcpTarget),
752  handJointsTarget(handJointsTarget),
753  shape(shape),
754  dt(dt),
755  feedForwardPosVelocity(feedForwardPosVelocity),
756  feedForwardOriVelocity(feedForwardOriVelocity),
757  feedForwardHandJointsVelocity(feedForwardHandJointsVelocity)
758  {
759  }
760 
762  const armarx::NameValueMap& handJointsTarget,
763  const std::optional<std::string>& shape) :
764  tcpTarget(tcpTarget),
765  handJointsTarget(handJointsTarget),
766  shape(shape),
767  dt(0),
768  feedForwardPosVelocity(0, 0, 0),
769  feedForwardOriVelocity(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
armarx::view_selection::skills::direction::state::up
state::Type up(state::Type previous)
Definition: LookDirection.cpp:240
armarx::RapidXmlReaderPtr
std::shared_ptr< RapidXmlReader > RapidXmlReaderPtr
Definition: RapidXmlReader.h:67
armarx::RapidXmlReader::FromFile
static RapidXmlReaderPtr FromFile(const std::string &path)
Definition: RapidXmlReader.h:573
armarx::GraspTrajectory::GetPosition
Eigen::Vector3f GetPosition(float t)
Definition: GraspTrajectory.cpp:241
armarx::GraspTrajectory::getAllKeypointPositions
std::vector< Eigen::Vector3f > getAllKeypointPositions()
Definition: GraspTrajectory.cpp:284
ARMARX_VERBOSE
#define ARMARX_VERBOSE
Definition: Logging.h:187
armarx::GraspTrajectory::Keypoint::tcpTarget
Eigen::Matrix4f tcpTarget
Definition: GraspTrajectory.h:58
armarx::GraspTrajectory::getAllKeypointOrientations
std::vector< Eigen::Matrix3f > getAllKeypointOrientations()
Definition: GraspTrajectory.cpp:295
armarx::GraspTrajectory::calculateReachability
SimpleDiffIK::Reachability calculateReachability(VirtualRobot::RobotNodeSetPtr rns, VirtualRobot::RobotNodePtr tcp=VirtualRobot::RobotNodePtr(), SimpleDiffIK::Parameters params=SimpleDiffIK::Parameters())
Definition: GraspTrajectory.cpp:442
GraspTrajectory.h
armarx::core::time::Duration::toSecondsDouble
double toSecondsDouble() const
Returns the amount of seconds.
Definition: Duration.cpp:90
ARMARX_IMPORTANT
#define ARMARX_IMPORTANT
Definition: Logging.h:190
armarx::GraspTrajectory::getFrame
const std::optional< std::string > & getFrame() const
Definition: GraspTrajectory.cpp:780
armarx::GraspTrajectory::ReadFromJSON
static GraspTrajectoryPtr ReadFromJSON(const std::string &filename)
Definition: GraspTrajectory.cpp:199
armarx::SimpleDiffIK::Parameters
Definition: SimpleDiffIK.h:39
armarx::GraspTrajectory::ReadFromFile
static GraspTrajectoryPtr ReadFromFile(const grasping::GraspCandidatePtr &cnd)
Definition: GraspTrajectory.cpp:467
armarx::GraspTrajectory::insertKeypoint
void insertKeypoint(size_t index, const Eigen::Matrix4f &tcpTarget, const Eigen::VectorXf &handJointsTarget, float dt)
Definition: GraspTrajectory.cpp:127
index
uint8_t index
Definition: EtherCATFrame.h:59
armarx::RapidXmlReader::FromXmlString
static RapidXmlReaderPtr FromXmlString(const std::string &xml)
Definition: RapidXmlReader.h:566
armarx::GraspTrajectory::getTranslatedAndRotated
GraspTrajectoryPtr getTranslatedAndRotated(const Eigen::Vector3f &translation, const Eigen::Matrix3f &rotation)
Definition: GraspTrajectory.cpp:385
GfxTL::Matrix4f
MatrixXX< 4, 4, float > Matrix4f
Definition: MatrixXX.h:650
armarx::GraspTrajectory::getStartPose
Eigen::Matrix4f getStartPose()
Definition: GraspTrajectory.cpp:210
armarx::SimpleDiffIK::Reachability
Definition: SimpleDiffIK.h:83
SimpleJsonLogger.h
armarx::GraspTrajectory::KeypointPtr
std::shared_ptr< Keypoint > KeypointPtr
Definition: GraspTrajectory.h:52
boost::target
Vertex target(const detail::edge_base< Directed, Vertex > &e, const PCG &)
Definition: point_cloud_graph.h:668
StructuralJsonParser.h
Duration.h
armarx::JsonValue::Create
static JsonValuePtr Create(const std::string &value)
Definition: JsonValue.cpp:72
RapidXmlWriter.h
armarx::GraspTrajectory::Keypoint::handJointsTarget
Eigen::VectorXf handJointsTarget
Definition: GraspTrajectory.h:59
armarx::GraspTrajectory::getTransformedToOtherHand
GraspTrajectoryPtr getTransformedToOtherHand() const
Definition: GraspTrajectory.cpp:657
ARMARX_CHECK_NOT_EMPTY
#define ARMARX_CHECK_NOT_EMPTY(c)
Definition: ExpressionException.h:224
armarx::GraspTrajectory::GetTcpDerivative
Eigen::Vector6f GetTcpDerivative(float t)
Definition: GraspTrajectory.cpp:334
ARMARX_CHECK
#define ARMARX_CHECK(expression)
Shortcut for ARMARX_CHECK_EXPRESSION.
Definition: ExpressionException.h:82
armarx::GraspTrajectory::Keypoint::getTargetOrientation
Eigen::Matrix3f getTargetOrientation() const
Definition: GraspTrajectory.cpp:66
armarx::GraspTrajectory::ReadFromReader
static GraspTrajectoryPtr ReadFromReader(const RapidXmlReaderPtr &reader)
Definition: GraspTrajectory.cpp:477
armarx::GraspTrajectory::GetShape
std::optional< std::string > GetShape(float t) const
Definition: GraspTrajectory.cpp:511
ARMARX_TRACE
#define ARMARX_TRACE
Definition: trace.h:77
armarx::GraspTrajectory::Keypoint
GraspTrajectoryKeypoint Keypoint
Definition: GraspTrajectory.h:81
GfxTL::Identity
void Identity(MatrixXX< N, N, T > *a)
Definition: MatrixXX.h:570
armarx::GraspTrajectory::getAllKeypointPoses
std::vector< Eigen::Matrix4f > getAllKeypointPoses()
Definition: GraspTrajectory.cpp:273
cxxopts::value
std::shared_ptr< Value > value()
Definition: cxxopts.hpp:855
armarx::GraspTrajectoryPtr
std::shared_ptr< class GraspTrajectory > GraspTrajectoryPtr
Definition: GraspTrajectory.h:47
armarx::GraspTrajectory::GraspTrajectory
GraspTrajectory()=default
armarx::GraspTrajectory::setFrame
void setFrame(const std::string &frame)
Definition: GraspTrajectory.cpp:774
armarx::GraspTrajectory::GetPositionDerivative
Eigen::Vector3f GetPositionDerivative(float t)
Definition: GraspTrajectory.cpp:316
armarx::GraspTrajectory::removeKeypoint
void removeKeypoint(size_t index)
Definition: GraspTrajectory.cpp:150
JPathNavigator.h
armarx::GraspTrajectory::GetHandValues
Eigen::VectorXf GetHandValues(float t)
Definition: GraspTrajectory.cpp:306
armarx::GraspTrajectory::calculateLength
Length calculateLength() const
Definition: GraspTrajectory.cpp:358
armarx::GraspTrajectory::setKeypointDt
void setKeypointDt(size_t index, float dt)
Definition: GraspTrajectory.cpp:185
armarx::GraspTrajectory::Keypoint::getTargetPosition
Eigen::Vector3f getTargetPosition() const
Definition: GraspTrajectory.cpp:60
armarx::GraspTrajectory::getTransformed
GraspTrajectoryPtr getTransformed(const Eigen::Matrix4f &transform)
Definition: GraspTrajectory.cpp:404
armarx::KeypointPtr
std::shared_ptr< Keypoint > KeypointPtr
Definition: KeypointManager.h:126
armarx::mapValuesToVector
Eigen::VectorXf mapValuesToVector(const armarx::NameValueMap &map)
Definition: GraspTrajectory.cpp:54
filename
std::string filename
Definition: VisualizationRobot.cpp:86
armarx::GraspTrajectory::getIndex
void getIndex(float t, int &i1, int &i2, float &f)
Definition: GraspTrajectory.cpp:216
armarx::GraspTrajectoryKeypoint::GraspTrajectoryKeypoint
GraspTrajectoryKeypoint()=default
armarx::GraspTrajectory::getAllKeypoints
const std::vector< KeypointPtr > & getAllKeypoints() const
Definition: GraspTrajectory.cpp:292
armarx::GraspTrajectory::GetHandJointsDerivative
Eigen::VectorXf GetHandJointsDerivative(float t)
Definition: GraspTrajectory.cpp:343
armarx::to_string
const std::string & to_string(const std::string &s)
Definition: StringHelpers.h:41
armarx::GraspTrajectory::GetOrientationDerivative
Eigen::Vector3f GetOrientationDerivative(float t)
Definition: GraspTrajectory.cpp:325
armarx::GraspTrajectory::ReadFromString
static GraspTrajectoryPtr ReadFromString(const std::string &xml)
Definition: GraspTrajectory.cpp:525
armarx::transform
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
armarx::GraspTrajectory::getTransformedToGraspPose
GraspTrajectoryPtr getTransformedToGraspPose(const Eigen::Matrix4f &target, const Eigen::Vector3f &handForward=Eigen::Vector3f::UnitZ())
Definition: GraspTrajectory.cpp:423
ExpressionException.h
armarx::control::njoint_controller::platform::platform_follower_controller::NameValueMap
std::map< std::string, float > NameValueMap
Definition: PlatformFollowerController.h:88
armarx::from_json
void from_json(const nlohmann::json &j, Vector2f &value)
armarx::GraspTrajectoryKeypoint
Definition: GraspTrajectory.h:45
CMakePackageFinder.h
armarx::GraspTrajectory::lastKeypoint
KeypointPtr & lastKeypoint()
Definition: GraspTrajectory.cpp:198
ARMARX_INFO
#define ARMARX_INFO
Definition: Logging.h:181
armarx::SimpleDiffIK::CalculateReachability
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.
Definition: SimpleDiffIK.cpp:140
armarx::GraspTrajectory::getKeypoint
KeypointPtr & getKeypoint(int i)
Definition: GraspTrajectory.cpp:204
VAROUT
#define VAROUT(x)
Definition: StringHelpers.h:198
armarx::core::time::Duration
Represents a duration.
Definition: Duration.h:16
RapidXmlReader.h
armarx::GraspTrajectory::GetOrientation
Eigen::Matrix3f GetOrientation(float t)
Definition: GraspTrajectory.cpp:251
angle
double angle(const Point &a, const Point &b, const Point &c)
Definition: point.hpp:109
armarx::GraspTrajectory::Keypoint::feedForwardHandJointsVelocity
Eigen::VectorXf feedForwardHandJointsVelocity
Definition: GraspTrajectory.h:63
armarx::GraspTrajectory::Keypoint::feedForwardOriVelocity
Eigen::Vector3f feedForwardOriVelocity
Definition: GraspTrajectory.h:62
Eigen::Matrix
Definition: EigenForwardDeclarations.h:27
armarx::GraspTrajectory::replaceKeypoint
void replaceKeypoint(size_t index, const Eigen::Matrix4f &tcpTarget, const Eigen::VectorXf &handJointsTarget, float dt)
Definition: GraspTrajectory.cpp:167
armarx::GraspTrajectory::writeToFile
void writeToFile(const std::string &filename)
Definition: GraspTrajectory.cpp:451
Logging.h
armarx::GraspTrajectory::Keypoint::getTargetPose
Eigen::Matrix4f getTargetPose() const
Definition: GraspTrajectory.cpp:72
GfxTL::Matrix3f
MatrixXX< 3, 3, float > Matrix3f
Definition: MatrixXX.h:649
armarx::GraspTrajectory::GetPose
Eigen::Matrix4f GetPose(float t)
Definition: GraspTrajectory.cpp:267
ARMARX_WARNING
#define ARMARX_WARNING
Definition: Logging.h:193
armarx::GraspTrajectory::getClone
GraspTrajectoryPtr getClone()
Definition: GraspTrajectory.cpp:417
armarx::core::time::Duration::MicroSeconds
static Duration MicroSeconds(std::int64_t microSeconds)
Constructs a duration in microseconds.
Definition: Duration.cpp:24
armarx::GraspTrajectory::Keypoint::feedForwardPosVelocity
Eigen::Vector3f feedForwardPosVelocity
Definition: GraspTrajectory.h:61
armarx::GraspTrajectory::getDuration
float getDuration() const
Definition: GraspTrajectory.cpp:352
armarx::GraspTrajectory::Keypoint::updateVelocities
void updateVelocities(const KeypointPtr &prev, float dt)
Definition: GraspTrajectory.cpp:78
armarx
This file offers overloads of toIce() and fromIce() functions for STL container types.
Definition: ArmarXTimeserver.cpp:27
armarx::GraspTrajectory::getKeypointCount
size_t getKeypointCount() const
Definition: GraspTrajectory.cpp:121
Exception.h
dt
constexpr T dt
Definition: UnscentedKalmanFilterTest.cpp:45
armarx::GraspTrajectory::addKeypoint
void addKeypoint(const Eigen::Matrix4f &tcpTarget, const Eigen::VectorXf &handJointsTarget, float dt)
Definition: GraspTrajectory.cpp:107
armarx::JsonObjectPtr
std::shared_ptr< JsonObject > JsonObjectPtr
Definition: JsonObject.h:34
norm
double norm(const Point &a)
Definition: point.hpp:102