SimoxCSpace.cpp
Go to the documentation of this file.
1 /*
2  * This file is part of ArmarX.
3  *
4  * Copyright (C) 2011-2016, High Performance Humanoid Technologies (H2T), Karlsruhe Institute of Technology (KIT), all rights reserved.
5  *
6  * ArmarX is free software; you can redistribute it and/or modify
7  * it under the terms of the GNU General Public License version 2 as
8  * published by the Free Software Foundation.
9  *
10  * ArmarX is distributed in the hope that it will be useful, but
11  * WITHOUT ANY WARRANTY; without even the implied warranty of
12  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13  * GNU General Public License for more details.
14  *
15  * You should have received a copy of the GNU General Public License
16  * along with this program. If not, see <http://www.gnu.org/licenses/>.
17  *
18  * @package RobotComponents
19  * @author Raphael Grimm ( raphael dot grimm at kit dot edu )
20  * @date 2015
21  * @copyright http://www.gnu.org/licenses/gpl.txt
22  * GNU General Public License
23  */
24 
25 #include "SimoxCSpace.h"
26 
27 #include <algorithm>
28 #include <cmath>
29 #include <exception>
30 #include <unordered_map>
31 #include <unordered_set>
32 
33 #include <VirtualRobot/CollisionDetection/CDManager.h>
34 #include <VirtualRobot/CollisionDetection/CollisionModel.h>
35 #include <VirtualRobot/RobotFactory.h>
36 #include <VirtualRobot/RobotNodeSet.h>
37 #include <VirtualRobot/Visualization/CoinVisualization/CoinVisualizationFactory.h>
38 #include <VirtualRobot/Visualization/CoinVisualization/CoinVisualizationNode.h>
39 #include <VirtualRobot/XML/RobotIO.h>
40 
44 
46 
47 #include "../util/Metrics.h"
54 #include <MotionPlanning/CSpace/CSpaceSampled.h>
55 
56 namespace armarx
57 {
58  bool
60  {
61  struct Initializer
62  {
63  //this is not threadsave
64  Initializer()
65  {
66  //this is checked by SoDB::init()
67  //if (!SoDB::isInitialized())
68  //{
69  SoDB::init();
70  //}
71  }
72 
73  bool
74  doStuff()
75  {
76  return true;
77  }
78  };
79 
80  static Initializer init;
81  return init.doStuff(); //suppresses unused variable
82  }
83 
84  SimoxCSpace::SimoxCSpace(memoryx::CommonStorageInterfacePrx commonStoragePrx,
85  bool loadVisualizationModel,
86  float stationaryObjectMargin) :
87  loadVisualizationModel{loadVisualizationModel}
88  {
89  this->stationaryObjectMargin = stationaryObjectMargin;
90  //check eigen layout for mapped vectors
92  ARMARX_CHECK_EXPRESSION(a.data() + 0 == &a(0, 0));
93  ARMARX_CHECK_EXPRESSION(a.data() + 1 == &a(1, 0));
94  ARMARX_CHECK_EXPRESSION(a.data() + 2 == &a(2, 0));
95  ARMARX_CHECK_EXPRESSION(a.data() + 3 == &a(3, 0));
96  ARMARX_CHECK_EXPRESSION(a.data() + 4 == &a(0, 1));
97  ARMARX_CHECK_EXPRESSION(a.data() + 5 == &a(1, 1));
98  ARMARX_CHECK_EXPRESSION(a.data() + 6 == &a(2, 1));
99  ARMARX_CHECK_EXPRESSION(a.data() + 7 == &a(3, 1));
100  ARMARX_CHECK_EXPRESSION(a.data() + 8 == &a(0, 2));
101  ARMARX_CHECK_EXPRESSION(a.data() + 9 == &a(1, 2));
102  ARMARX_CHECK_EXPRESSION(a.data() + 10 == &a(2, 2));
103  ARMARX_CHECK_EXPRESSION(a.data() + 11 == &a(3, 2));
104  ARMARX_CHECK_EXPRESSION(a.data() + 12 == &a(0, 3));
105  ARMARX_CHECK_EXPRESSION(a.data() + 13 == &a(1, 3));
106  ARMARX_CHECK_EXPRESSION(a.data() + 14 == &a(2, 3));
107  ARMARX_CHECK_EXPRESSION(a.data() + 15 == &a(3, 3));
108 
109  commonStorage = commonStoragePrx;
110 
111  if (!commonStorage)
112  {
113  ARMARX_ERROR_S << "SimoxCSpace ctor: commonStorage == null";
114  throw std::invalid_argument{"SimoxCSpace ctor: commonStorage == null"};
115  }
116  }
117 
118  CSpaceBasePtr
119  SimoxCSpace::clone(bool loadVisualizationModel)
120  {
121  TIMING_START(SimoxCSpaceClone);
122  SimoxCSpacePtr cloned =
123  new SimoxCSpace{commonStorage, loadVisualizationModel, stationaryObjectMargin};
124 
125  for (const auto& obj : stationaryObjects)
126  {
127  cloned->addStationaryObject(obj);
128  }
129  cloned->agentInfo = agentInfo;
131  cloned->initAgent();
132  TIMING_END(SimoxCSpaceClone);
133  return cloned;
134  }
135 
136  Saba::CSpaceSampledPtr
138  {
139 
140  // ARMARX_INFO << "using kinematic chain set: " << agentInfo.kinemaicChainNames.at(0);
141  VirtualRobot::CDManagerPtr tmpCd =
142  VirtualRobot::CDManagerPtr(new VirtualRobot::CDManager(cd));
143 
144  // for (VirtualRobot::SceneObjectSetPtr& set : tmpCd->getSceneObjectSets())
145  // {
146  // ARMARX_INFO << "set size: " << set->getSize();
147  // }
148  Saba::CSpaceSampledPtr result(new Saba::CSpaceSampled(
150  tmpCd,
151  agentInfo.kinemaicChainNames.size() > 0
152  ? agentSceneObj->getRobotNodeSet(agentInfo.kinemaicChainNames.at(0))
153  : VirtualRobot::RobotNodeSetPtr()));
154  return result;
155  }
156 
157  //from SimoxCSpace
158  void
159  SimoxCSpace::addStationaryObject(const StationaryObject& obj, const Ice::Current&)
160  {
161  ARMARX_CHECK_EXPRESSION(obj.objectPose);
162  ARMARX_CHECK_EXPRESSION(obj.objectClassBase);
163  stationaryObjects.emplace_back(obj);
164  }
165 
166  void
167  SimoxCSpace::setStationaryObjects(const StationaryObjectList& objList)
168  {
169  stationaryObjects = objList;
170  }
171 
172  void
173  SimoxCSpace::setAgent(const AgentPlanningInformation& agentInfo, const Ice::Current&)
174  {
175  this->agentInfo = agentInfo;
176  initAgent();
177  }
178 
179  void
180  SimoxCSpace::setConfig(const float*& it)
181  {
182  //stationary agents joints
183  NameValueMap jointValues;
184  for (auto agentJoint : agentJoints)
185  {
186  jointValues[agentJoint->getName()] = *it;
187  agentJoint->setJointValueNoUpdate(*(it++));
188  }
189  // ARMARX_VERBOSE << agentSceneObj.get() << " " << agentSceneObj->getUpdateVisualizationStatus() << " Setting joint values to new values: " << jointValues;
190  agentSceneObj->applyJointValues();
191  }
192 
193  bool
194  SimoxCSpace::isCollisionFree(const ::std::pair<const Ice::Float*, const Ice::Float*>& cfg,
195  const Ice::Current&)
196  {
197  ARMARX_CHECK_EXPRESSION(std::distance(cfg.first, cfg.second) == getDimensionality());
198  const Ice::Float* it;
199  it = cfg.first;
200 
201  setConfig(it);
202 
203  ARMARX_CHECK_EXPRESSION(cfg.second == it);
204  //check
205  return !cd.isInCollision();
206  }
207 
208  void
209  SimoxCSpace::initCollisionTest(const Ice::Current&)
210  {
211  if (isInitialized)
212  {
213  ARMARX_DEBUG_S << "was already initialized SimoxCSpace " << this;
214  return;
215  }
216  TIMING_START(CSpaceInit);
217  //init file manager
219  fileManager.reset(new memoryx::GridFileManager(commonStorage));
220 
221  //just to be save (may crash otherwise)
222  TIMING_START(CSpaceInit_ensureCoinIsInitialized)
224  TIMING_END(CSpaceInit_ensureCoinIsInitialized)
225 
226  isInitialized = true;
227  TIMING_START(CSpaceInit_initAgent)
228  initAgent();
229  TIMING_END(CSpaceInit_initAgent)
230  TIMING_START(CSpaceInit_initStationaryObjects)
232  TIMING_END(CSpaceInit_initStationaryObjects)
233  agentSceneObj->setJointValues(agentInfo.initialJointValues);
234  ARMARX_CHECK_EXPRESSION(stationaryObjectSet->getSize() == stationaryObjects.size());
235  TIMING_END(CSpaceInit);
236  }
237 
238  void
240  {
241  stationaryObjectSet.reset(
242  new VirtualRobot::SceneObjectSet{"StationaryObjectSet", cd.getCollisionChecker()});
243  if (stationaryObjects.size() || stationaryPlanes.size())
244  {
246  for (std::size_t i = 0; i < stationaryObjects.size(); ++i)
247  {
249  const auto& obj = stationaryObjects.at(i);
250  auto&& sceneObj = getMovedSimoxManipulatorObject(
251  obj.objectClassBase, obj.objectPose, fileManager);
252  //deactivate visu since it is not needed and moving visu is as expensive as moving the col mod
253  sceneObj->setUpdateVisualization(false);
254  stationaryObjectSet->addSceneObject(std::move(sceneObj));
255  }
256 
257  for (auto& plane : stationaryPlanes)
258  {
259  VirtualRobot::CoinVisualizationNodePtr visu(new VirtualRobot::CoinVisualizationNode(
260  (SoNode*)VirtualRobot::CoinVisualizationFactory::CreatePolygonVisualization(
261  plane)));
262  VirtualRobot::SceneObjectPtr s(new VirtualRobot::SceneObject(
263  "Plane",
264  visu,
265  VirtualRobot::CollisionModelPtr(new VirtualRobot::CollisionModel(visu)),
266  VirtualRobot::SceneObject::Physics{},
267  cd.getCollisionChecker()));
268 
269  stationaryObjectSet->addSceneObject(s);
270  }
271  if (stationaryObjectSet->getSize())
272  {
273  ARMARX_INFO << "SceneObjects: "
275  stationaryObjectSet->getSceneObjects(),
276  +[](VirtualRobot::SceneObjectPtr const& obj)
277  { return obj->getName(); });
278  ARMARX_CHECK_EXPRESSION(!cd.hasSceneObjectSet(stationaryObjectSet));
279  cd.addCollisionModel(stationaryObjectSet);
280  }
281  }
282  }
283 
284  void
286  {
287  //move agent
288  if (agentInfo.agentPose) //if none is set the default pose is used
289  {
290  agentData.agent->setGlobalPose(
291  armarx::PosePtr::dynamicCast(agentInfo.agentPose)->toEigen());
292  }
293 
294  agentSceneObj = std::move(agentData.agent);
295  //deactivate visu since it is not needed and moving visu is as expensive as moving the col mod
296  agentSceneObj->setUpdateVisualization(false);
297 
298  const std::size_t numberOfJoints = agentData.joints.size();
299  agentJoints.clear();
300  agentJoints.reserve(numberOfJoints);
301  std::move(
302  agentData.joints.begin(), agentData.joints.end(), std::back_inserter(agentJoints));
303 
304  if (isInitialized)
305  {
306  cd = VirtualRobot::CDManager{agentSceneObj->getCollisionChecker()};
307  for (auto& colMod : agentData.collisionSets)
308  {
309  cd.addCollisionModel(std::move(colMod));
310  }
311  // cd.addCollisionModel(stationaryObjectSet);
312  }
313  }
314 
317  {
318  //load agent
320  {
321  auto packageNames = agentInfo.agentProjectNames;
322  if (!agentInfo.agentProjectName.empty())
323  {
324  packageNames.emplace_back(agentInfo.agentProjectName);
325  }
326 
327  std::string absoluteFilePath;
328  std::vector<std::string> paths;
329  for (const auto& package : packageNames)
330  {
331  armarx::CMakePackageFinder packageFinder(package);
332  auto pathStr = packageFinder.getDataDir();
333  std::vector<std::string> packagePaths = Split(pathStr, ";,", false, true);
334 
335  paths.reserve(paths.size() + packagePaths.size());
336  std::move(packagePaths.begin(), packagePaths.end(), std::back_inserter(paths));
337  }
338 
340  agentInfo.agentRelativeFilePath, absoluteFilePath, paths))
341  {
342  std::stringstream s;
343  s << "could not find file " << agentInfo.agentRelativeFilePath << " in project "
344  << agentInfo.agentProjectName;
345  ARMARX_ERROR_S << s.str();
346  throw std::invalid_argument{s.str()};
347  }
348  // static std::map<std::pair<VirtualRobot::RobotIO::RobotDescription, std::string>, VirtualRobot::RobotPtr> agentCache;
349  // static armarx::Mutex agentCacheMutex;
350  // ScopedLock lock(agentCacheMutex);
351  auto loadType = isInitialized ? //the cspace is initializing => load models
353  : VirtualRobot::RobotIO::eCollisionModel)
354  : VirtualRobot::RobotIO::eStructure;
355  auto pair = std::make_pair(loadType, absoluteFilePath);
356  // auto it = robotCache.find(pair);
357  if (!robotCache.hasObject(pair))
358  {
359  agent = VirtualRobot::RobotIO::loadRobot(absoluteFilePath, loadType);
360 
361  ARMARX_DEBUG << "Robot Cache MISS! Path: " << absoluteFilePath
362  << " load type: " << (int)loadType;
363  RobotPoolPtr pool(new RobotPool(agent, 2));
364  agent = pool->getRobot();
365  robotCache.insertObject(pair, pool);
366  // agentCache.insert(std::make_pair(pair, agent)).first;
367  }
368  else
369  {
370  ARMARX_DEBUG << "Robot Cache hit! load type: " << (int)loadType;
371  agent = robotCache.getCacheObject(pair)->getRobot();
372  }
373 
374  // auto loadType = isInitialized ?//the cspace is initializing => load models
375  // (
376  // loadVisualizationModel ?
377  // VirtualRobot::RobotIO::eFull :
378  // VirtualRobot::RobotIO::eCollisionModel
379  // ) : VirtualRobot::RobotIO::eStructure;
380  // agent = VirtualRobot::RobotIO::loadRobot(
381  // absoluteFilePath,
382  // loadType
383  // );
384  // ARMARX_VERBOSE << "Loading robot! Path: " << absoluteFilePath << " load type: " << (int)loadType << " addr: " << agent.get();
385  if (!agent)
386  {
387  std::stringstream s;
388  s << "Can't load agent from: " << absoluteFilePath;
389  ARMARX_ERROR_S << s.str();
390  throw std::invalid_argument{s.str()};
391  }
392  }
393 
394  return getAgentDataFromRobot(agent);
395  }
396 
399  {
400  AgentData data;
401 
402  ARMARX_CHECK_EXPRESSION(robotPtr);
403  data.agent = robotPtr;
404 
405  if (isInitialized)
406  {
408  //attach objects
409  //use the map to track this association
410  std::unordered_map<std::string, std::vector<VirtualRobot::RobotNodePtr>>
411  toCollSetAssociatedObjects;
412  toCollSetAssociatedObjects.reserve(agentInfo.collisionSetNames.size());
413 
414  for (std::size_t i = 0; i < agentInfo.attachedObjects.size(); ++i)
415  {
416  const auto& attached = agentInfo.attachedObjects.at(i);
417  auto&& sceneObj = getSimoxManipulatorObject(
418  attached.objectClassBase, fileManager, false, robotPtr->getCollisionChecker());
419  std::stringstream sceneObjName;
420  sceneObjName << "attached_obj_" << i << "_" << sceneObj->getName();
421  sceneObj->setName(sceneObjName.str());
422 
423  //find node to attach to and attach
424  if (!data.agent->hasRobotNode(attached.attachedToRobotNodeName))
425  {
426  std::stringstream s;
427  s << "Agent " << data.agent->getName() << " has no node "
428  << attached.attachedToRobotNodeName << "to attach object "
429  << attached.objectClassBase->getName();
430  ARMARX_ERROR_S << s.str();
431  throw std::invalid_argument{s.str()};
432  }
433 
434  VirtualRobot::RobotNodePtr nodeToAttachTo =
435  data.agent->getRobotNode(attached.attachedToRobotNodeName);
436  VirtualRobot::RobotFactory::attach(
437  data.agent,
438  sceneObj,
439  nodeToAttachTo,
440  armarx::PosePtr::dynamicCast(attached.relativeObjectPose)->toEigen());
441 
442  //adding to cd
443  if (attached.associatedCollisionSetName.empty())
444  {
445  //add alone
446  data.collisionSets.emplace_back(new VirtualRobot::SceneObjectSet{
447  sceneObjName.str(), data.agent->getCollisionChecker()});
448  data.collisionSets.back()->addSceneObject(
449  data.agent->getRobotNode(sceneObjName.str()));
450  }
451  else
452  {
453  //does the set exist?
454  if (std::find(agentInfo.collisionSetNames.begin(),
455  agentInfo.collisionSetNames.end(),
456  attached.associatedCollisionSetName) ==
457  agentInfo.collisionSetNames.end())
458  {
459  std::stringstream s;
460  s << "Agent " << data.agent->getName() << " has no set "
461  << attached.associatedCollisionSetName
462  << " to use as associated collision set for attached object "
463  << attached.objectClassBase->getName();
464  ARMARX_ERROR_S << s.str();
465  throw std::invalid_argument{s.str()};
466  }
467  //add to set
468  toCollSetAssociatedObjects[attached.associatedCollisionSetName].emplace_back(
469  data.agent->getRobotNode(sceneObjName.str()));
470  }
471  }
472  //get collision models
473  for (const auto& name : agentInfo.collisionSetNames)
474  {
475  if (!data.agent->hasRobotNodeSet(name))
476  {
477  std::stringstream s;
478  s << "Agent " << data.agent->getName() << " has no collision model " << name;
479  ARMARX_ERROR_S << s.str();
480  throw std::invalid_argument{s.str()};
481  }
482 
483  //add set + associated objects for cd
484  data.collisionSets.emplace_back(
485  new VirtualRobot::SceneObjectSet{name, data.agent->getCollisionChecker()});
486  data.collisionSets.back()->addSceneObjects(data.agent->getRobotNodeSet(name));
487 
488  for (auto& obj : toCollSetAssociatedObjects[name])
489  {
490  data.collisionSets.back()->addSceneObject(std::move(obj));
491  }
492  }
493  if (!agentInfo.collisionObjectNames.empty())
494  {
495  data.collisionSets.emplace_back(new VirtualRobot::SceneObjectSet{
496  "collisionObjects", data.agent->getCollisionChecker()});
497  for (const auto& name : agentInfo.collisionObjectNames)
498  {
499  if (!data.agent->hasRobotNode(name))
500  {
501  std::stringstream s;
502  s << "Agent " << data.agent->getName() << " has no collision model "
503  << name;
504  ARMARX_ERROR_S << s.str();
505  throw std::invalid_argument{s.str()};
506  }
507 
508  //add set + associated objects for cd
509  data.collisionSets.back()->addSceneObject(data.agent->getRobotNode(name));
510 
511  for (auto& obj : toCollSetAssociatedObjects[name])
512  {
513  data.collisionSets.back()->addSceneObject(std::move(obj));
514  }
515  }
516  }
517  }
518 
519  //get joints
520  //some joints may be blacklisted or already added
521  std::set<std::string> blacklist(agentInfo.jointsExcludedFromPlanning.begin(),
522  agentInfo.jointsExcludedFromPlanning.end());
523  //add kinematic chains
524  for (const auto& name : agentInfo.kinemaicChainNames)
525  {
526  if (!data.agent->hasRobotNodeSet(name))
527  {
528  std::stringstream s;
529  s << "Agent " << data.agent->getName() << " has no kinematic chain " << name;
530  ARMARX_ERROR_S << s.str();
531  throw std::invalid_argument{s.str()};
532  }
533 
534  //add chain
535  for (auto& node : *(data.agent->getRobotNodeSet(name)))
536  {
537  auto nodeIt = blacklist.find(node->getName());
538  if (nodeIt != blacklist.end())
539  {
540  continue;
541  }
542 
543  if (!(node->isTranslationalJoint() || node->isRotationalJoint()))
544  {
545  std::stringstream s;
546  s << "The node " << node->getName() << " in the kinematic chain " << name
547  << " of agent " << data.agent->getName()
548  << " is neither rotational nor tranlational";
549  ARMARX_ERROR_S << s.str();
550  throw std::invalid_argument{s.str()};
551  }
552 
553  data.joints.emplace_back(node);
554  blacklist.emplace_hint(nodeIt, node->getName());
555  }
556  }
557  //add single nodes
558  for (const auto& name : agentInfo.additionalJointsForPlanning)
559  {
560  if (!data.agent->hasRobotNode(name))
561  {
562  std::stringstream s;
563  s << "Agent " << data.agent->getName() << " has no node " << name;
564  ARMARX_ERROR_S << s.str();
565  throw std::invalid_argument{s.str()};
566  }
567  auto node = data.agent->getRobotNode(name);
568 
569  auto nodeIt = blacklist.find(node->getName());
570  if (nodeIt != blacklist.end())
571  {
572  continue;
573  }
574 
575  if (!(node->isTranslationalJoint() || node->isRotationalJoint()))
576  {
577  std::stringstream s;
578  s << "The node " << node->getName() << " of agent " << data.agent->getName()
579  << " is neither rotational nor tranlational";
580  ARMARX_ERROR_S << s.str();
581  throw std::invalid_argument{s.str()};
582  }
583 
584  data.joints.emplace_back(node);
585  blacklist.emplace_hint(nodeIt, node->getName());
586  }
587  return data;
588  }
589 
590  VirtualRobot::ManipulationObjectPtr
592  const memoryx::ObjectClassBasePtr& object,
593  const memoryx::GridFileManagerPtr& fileManager,
594  bool inflate,
595  VirtualRobot::CollisionCheckerPtr const& colChecker) const
596  {
597  memoryx::ObjectClassPtr objectClass = memoryx::ObjectClassPtr::dynamicCast(object);
598  // static boost::mutex meshCacheMutex;
599  // static std::map<std::pair<int, std::string>, VirtualRobot::ManipulationObjectPtr> meshCache;
601  VirtualRobot::ManipulationObjectPtr mo;
602  if (!objectClass)
603  {
604  std::stringstream s;
605  s << "Can't use object class with ice id " << object->ice_id();
606  ARMARX_ERROR_S << s.str();
607  throw armarx::InvalidArgumentException{s.str()};
608  }
609  {
610  // boost::mutex::scoped_lock lock(meshCacheMutex);
611  auto pair = std::make_pair((int)(stationaryObjectMargin * 1000), object->getId());
612  auto pairZeroMargin = std::make_pair(0, object->getId());
613 
614  if (meshCache.hasObject(pair))
615  {
616  auto tmpMo = meshCache.getCacheObject(pair);
617  IceUtil::Time start = IceUtil::Time::now();
618  mo = tmpMo->clone(tmpMo->getName(), colChecker, true);
619  IceUtil::Time end = IceUtil::Time::now();
620  ARMARX_DEBUG << "mesh Cache hit for " << tmpMo->getName() << " - Cloning took "
621  << (end - start).toMilliSeconds();
622  }
623  else
624  {
625  if (meshCache.hasObject(pairZeroMargin))
626  {
627  auto tmpMo = meshCache.getCacheObject(pairZeroMargin);
628  ARMARX_DEBUG << "mesh Cache HALFMISS - mesh inflation needed for "
629  << tmpMo->getName();
630  mo = tmpMo->clone(tmpMo->getName(), colChecker, true);
631  }
632  else
633  {
634  sw = objectClass->addWrapper(new memoryx::EntityWrappers::SimoxObjectWrapper(
635  fileManager, VirtualRobot::RobotIO::eCollisionModel));
636  VirtualRobot::ManipulationObjectPtr orgMo = sw->getManipulationObject();
637  ARMARX_DEBUG << "mesh Cache MISS for " << orgMo->getName();
639  std::string moName = orgMo->getName();
640  mo = orgMo->clone(moName, colChecker, true);
641  }
642  if (this->stationaryObjectMargin != 0.0f && inflate)
643  {
644  ARMARX_DEBUG << deactivateSpam(3, to_string(stationaryObjectMargin)) << "Using "
645  << stationaryObjectMargin << " as margin";
646 
647  mo->getCollisionModel()->inflateModel(this->stationaryObjectMargin);
648  }
649  meshCache.insertObject(pair, mo);
650  }
651  }
652 
653 
654  return mo;
655  }
656 
657  VirtualRobot::ManipulationObjectPtr
658  SimoxCSpace::getMovedSimoxManipulatorObject(const memoryx::ObjectClassBasePtr& object,
659  const PoseBasePtr& pose,
660  memoryx::GridFileManagerPtr& fileManager) const
661  {
662  VirtualRobot::ManipulationObjectPtr mo = getSimoxManipulatorObject(
663  object,
664  fileManager,
665  true,
666  const_cast<VirtualRobot::CDManager*>(&cd)->getCollisionChecker());
667 
668  //move the object to the given position
669  const auto objectPose = armarx::PosePtr::dynamicCast(pose);
670 
671  if (!objectPose)
672  {
673  std::stringstream s;
674  s << "Can't convert pose of " << memoryx::ObjectClassPtr::dynamicCast(object)->getName()
675  << " to armarx::Pose.";
676  ARMARX_ERROR_S << s.str();
677  throw armarx::InvalidArgumentException{s.str()};
678  }
679 
680  mo->setGlobalPose(objectPose->toEigen());
681  return mo;
682  }
683 
684  void
686  memoryx::WorkingMemoryInterfacePrx workingMemoryPrx,
687  const std::vector<std::string>& excludedInstancesIds /* = std::vector<std::string>() */)
688  {
689  TIMING_START(LoadFromWM);
690  //pass all objects from the scene to the cspace
691  auto objInstPrx = workingMemoryPrx->getObjectInstancesSegment();
692  const auto objs = objInstPrx->getAllEntities();
693  auto agentSeg = workingMemoryPrx->getAgentInstancesSegment();
694 
695  for (const auto& entityBase : objs)
696  {
697  auto id = entityBase->getId();
698  if (std::find(excludedInstancesIds.cbegin(), excludedInstancesIds.cend(), id) !=
699  excludedInstancesIds.cend())
700  {
701  continue;
702  }
703 
704  const memoryx::ObjectInstancePtr object =
705  memoryx::ObjectInstancePtr::dynamicCast(entityBase);
706  auto objPose = object->getPose();
707  if (objPose->frame != GlobalFrame && !objPose->frame.empty())
708  {
709  objPose = FramedPosePtr::dynamicCast(
710  agentSeg->convertToWorldPose(objPose->agent, objPose));
711  }
712 
713  ARMARX_CHECK_EXPRESSION(object);
714 
715  const std::string className = object->getMostProbableClass();
716 
717  memoryx::ObjectClassList classes = workingMemoryPrx->getPriorKnowledge()
718  ->getObjectClassesSegment()
719  ->getClassWithSubclasses(className);
720 
721  if (!classes.size())
722  {
723  ARMARX_INFO_S << "No classes for most probable class '" << className
724  << "' of object '" << object->getName() << "' with id " << id;
725  continue;
726  }
727 
728  addStationaryObject({classes.at(0), armarx::PoseBasePtr{objPose}});
729  }
730  TIMING_END(LoadFromWM);
731  }
732 
734  SimoxCSpace::PrefetchWorkingMemoryObjects(memoryx::WorkingMemoryInterfacePrx workingMemoryPrx,
735  memoryx::CommonStorageInterfacePrx commonStoragePrx,
737  {
738  SimoxCSpacePtr cspace(new SimoxCSpace(commonStoragePrx));
739 
740  AgentPlanningInformation agentData;
741  agentData.agentProjectNames = rsc->getArmarXPackages();
742  agentData.agentRelativeFilePath = rsc->getRobotFilename();
743 
744  cspace->setAgent(agentData);
745 
746  cspace->addObjectsFromWorkingMemory(workingMemoryPrx);
747  cspace->initCollisionTest();
748  return cspace;
749  }
750 
751  void
752  SimoxCSpace::addPlanarObject(const std::vector<Eigen::Vector3f>& convexHull)
753  {
754  stationaryPlanes.push_back(convexHull);
755  }
756 
757  void
759  {
760  if (!commonStorage)
761  {
762  ARMARX_ERROR_S << "SimoxCSpace ice_postUnmarshal: commonStorage == null";
763  throw std::invalid_argument{"SimoxCSpace ice_postUnmarshal: commonStorage == null"};
764  }
765 
766  //should throw no direct exception since they were prevented when adding an agent
767  initAgent();
768  }
769 
770  template <class T, class Thrower>
771  std::vector<std::vector<T>>
772  transpose(const std::vector<std::vector<T>>& src, Thrower thrower)
773  {
774  std::size_t numDatapoints = src.size();
775  if (!numDatapoints)
776  {
777  return {};
778  }
779  std::size_t numDimensions = src.at(0).size();
780  std::vector<std::vector<T>> transposed(numDimensions, std::vector<T>(numDatapoints));
781  for (std::size_t i = 0; i < numDatapoints; ++i)
782  {
783  auto& datapoint = src.at(i);
784  if (datapoint.size() != static_cast<std::size_t>(numDimensions))
785  {
786  thrower(i, datapoint.size(), numDimensions);
787  }
788  for (std::size_t dim = 0; dim < numDimensions; ++dim)
789  {
790  transposed.at(dim).at(i) = datapoint.at(dim);
791  }
792  }
793  return transposed;
794  }
795 
796  template <class T>
797  std::vector<std::vector<T>>
798  transpose(const std::vector<std::vector<T>>& src)
799  {
800  return transpose(src,
801  [](std::size_t idx, std::size_t szi, std::size_t numDim)
802  {
803  std::stringstream ss;
804  ss << "transpose: Element " << idx << " has " << szi
805  << " dimensions. The Element 0 has " << numDim << "dimensions.";
806  throw std::invalid_argument{ss.str()};
807  });
808  }
809 
811  SimoxCSpace::pathToTrajectory(const VectorXfSeq& p) const
812  {
813  if (p.empty())
814  {
815  return nullptr;
816  }
817  auto thrower = [](std::size_t idx, std::size_t szi, std::size_t numDim)
818  {
819  std::stringstream ss;
820  ss << "SimoxCSpace::pathToTrajectory: The datapoint " << idx << " has " << szi
821  << " dimensions. The CSpace has " << numDim << "dimensions.";
822  throw std::invalid_argument{ss.str()};
823  };
824  if (static_cast<std::size_t>(getDimensionality()) != p.front().size())
825  {
826  thrower(0, p.front().size(), static_cast<std::size_t>(getDimensionality()));
827  }
828  TrajectoryPtr traj = new Trajectory{
829  transpose(p, thrower), Ice::DoubleSeq() /*timestamps*/, getAgentJointNames()};
830  LimitlessStateSeq limitlessStates;
831  for (auto& joint : getAgentJoints())
832  {
833  LimitlessState state;
834  state.enabled = joint->isLimitless();
835  state.limitHi = joint->getJointLimitHigh();
836  state.limitLo = joint->getJointLimitLow();
837  limitlessStates.push_back(state);
838  }
839  traj->setLimitless(limitlessStates);
840  return traj;
841  }
842 
843  FloatRangeSeq
844  SimoxCSpace::getDimensionsBounds(const Ice::Current&) const
845  {
846  FloatRangeSeq dims;
847  dims.reserve(getDimensionality());
848  std::transform(agentJoints.begin(),
849  agentJoints.end(),
850  std::back_inserter(dims),
851  [](const VirtualRobot::RobotNodePtr& joint) {
852  return FloatRange{joint->getJointLimitLo(), joint->getJointLimitHi()};
853  });
854  return dims;
855  }
856 
857  Ice::StringSeq
858  SimoxCSpace::getAgentJointNames() const
859  {
860  Ice::StringSeq result;
861  result.reserve(getAgentJoints().size());
862  for (const auto& e : getAgentJoints())
863  {
864  result.emplace_back(e->getName());
865  }
866  return result;
867  }
868 
869  VectorXf
870  SimoxCSpace::jointMapToVector(const std::map<std::string, float>& jointMap,
871  bool checkForNonexistenJointsInCspace) const
872  {
873  VectorXf result(getDimensionality(), 0.f);
874  std::size_t valuesFromMapUsed = 0;
875  auto jointNames = getAgentJointNames();
876  for (std::size_t i = 0; i < jointNames.size(); ++i)
877  {
878  auto it = jointMap.find(jointNames.at(i));
879  if (it != jointMap.end())
880  {
881  result.at(i) = it->second;
882  ++valuesFromMapUsed;
883  }
884  }
885  if (checkForNonexistenJointsInCspace && (valuesFromMapUsed != jointMap.size()))
886  {
887  throw std::invalid_argument{
888  "the joint map contained a joint not contained by the cspace!"};
889  }
890  return result;
891  }
892 
893  SimoxCSpaceWith2DPose::SimoxCSpaceWith2DPose(
894  memoryx::CommonStorageInterfacePrx commonStoragePrx,
895  bool loadVisualizationModel,
896  float stationaryObjectMargin) :
897  SimoxCSpace(commonStoragePrx, loadVisualizationModel, stationaryObjectMargin)
898  {
899  ARMARX_CHECK_EXPRESSION(commonStoragePrx);
900  }
901 
902  CSpaceBasePtr
903  SimoxCSpaceWith2DPose::clone(bool loadVisualizationModel)
904  {
906  commonStorage, loadVisualizationModel, stationaryObjectMargin};
907  for (const auto& obj : stationaryObjects)
908  {
909  cloned->addStationaryObject(obj);
910  }
911  cloned->poseBounds = poseBounds;
912  cloned->agentInfo = agentInfo;
913  cloned->initAgent();
914  return cloned;
915  }
916 
917  FloatRangeSeq
919  {
920  FloatRangeSeq bounds(getDimensionality());
921  bounds.at(0).min = poseBounds.min.e0;
922  bounds.at(0).max = poseBounds.max.e0;
923 
924  bounds.at(1).min = poseBounds.min.e1;
925  bounds.at(1).max = poseBounds.max.e1;
926 
927  bounds.at(2).min = poseBounds.min.e2;
928  bounds.at(2).max = poseBounds.max.e2;
929 
930  auto parentBounds = SimoxCSpace::getDimensionsBounds();
931  std::move(parentBounds.begin(), parentBounds.end(), bounds.begin() + 3);
932  return bounds;
933  }
934 
935  Ice::StringSeq
937  {
938  auto joints = SimoxCSpace::getAgentJointNames();
939  joints.resize(joints.size() + 3);
940  std::move_backward(joints.begin(), joints.end() - 3, joints.end());
941  joints.at(0) = "x";
942  joints.at(1) = "y";
943  joints.at(2) = "alpha";
944  return joints;
945  }
946 
947  void
949  {
950  globalPoseBuffer(0, 3) = *(it++);
951  globalPoseBuffer(1, 3) = *(it++);
952 
953  const auto rot = *(it++);
954 
955  const auto crot = std::cos(rot);
956  const auto srot = std::sin(rot);
957 
958  //see http://planning.cs.uiuc.edu/node102.html
959  //row 0
960  globalPoseBuffer(0, 0) = crot;
961  globalPoseBuffer(0, 1) = -srot;
962  //row 1
963  globalPoseBuffer(1, 0) = srot;
964  globalPoseBuffer(1, 1) = crot;
965 
966  agentSceneObj->setGlobalPoseNoChecks(globalPoseBuffer);
968  }
969 
971  memoryx::CommonStorageInterfacePrx commonStoragePrx,
972  bool loadVisualizationModel,
973  float stationaryObjectMargin) :
974  SimoxCSpace(commonStoragePrx, loadVisualizationModel, stationaryObjectMargin)
975  {
976  ARMARX_CHECK_EXPRESSION(commonStoragePrx);
977  }
978 
979  CSpaceBasePtr
980  SimoxCSpaceWith3DPose::clone(bool loadVisualizationModel)
981  {
983  commonStorage, loadVisualizationModel, stationaryObjectMargin};
984  for (const auto& obj : stationaryObjects)
985  {
986  cloned->addStationaryObject(obj);
987  }
988  cloned->poseBounds = poseBounds;
989  cloned->agentInfo = agentInfo;
990  cloned->initAgent();
991  return cloned;
992  }
993 
994  FloatRangeSeq
996  {
997  FloatRangeSeq bounds(getDimensionality());
998  bounds.at(0).min = poseBounds.min.e0;
999  bounds.at(0).max = poseBounds.max.e0;
1000 
1001  bounds.at(1).min = poseBounds.min.e1;
1002  bounds.at(1).max = poseBounds.max.e1;
1003 
1004  bounds.at(2).min = poseBounds.min.e2;
1005  bounds.at(2).max = poseBounds.max.e2;
1006 
1007  bounds.at(3).min = poseBounds.min.e3;
1008  bounds.at(3).max = poseBounds.max.e3;
1009 
1010  bounds.at(4).min = poseBounds.min.e4;
1011  bounds.at(4).max = poseBounds.max.e4;
1012 
1013  bounds.at(5).min = poseBounds.min.e5;
1014  bounds.at(5).max = poseBounds.max.e5;
1015  auto parentBounds = SimoxCSpace::getDimensionsBounds();
1016  std::move(parentBounds.begin(), parentBounds.end(), bounds.begin() + 6);
1017  return bounds;
1018  }
1019 
1020  void
1022  {
1023  globalPoseBuffer(0, 3) = *(it++);
1024  globalPoseBuffer(1, 3) = *(it++);
1025  globalPoseBuffer(2, 3) = *(it++);
1026 
1027  const auto roll = *(it++);
1028  const auto pitch = *(it++);
1029  const auto yaw = *(it++);
1030 
1031  const auto croll = std::cos(roll);
1032  const auto sroll = std::sin(roll);
1033 
1034  const auto cpitch = std::cos(pitch);
1035  const auto spitch = std::sin(pitch);
1036 
1037  const auto cyaw = std::cos(yaw);
1038  const auto syaw = std::sin(yaw);
1039 
1040  //see http://planning.cs.uiuc.edu/node102.html
1041  //row 0
1042  globalPoseBuffer(0, 0) = cyaw * cpitch;
1043  globalPoseBuffer(0, 1) = cyaw * spitch * sroll - syaw * croll;
1044  globalPoseBuffer(0, 2) = cyaw * spitch * sroll + syaw * sroll;
1045  //row 1
1046  globalPoseBuffer(1, 0) = syaw * cpitch;
1047  globalPoseBuffer(1, 1) = syaw * spitch * sroll + cyaw * croll;
1048  globalPoseBuffer(1, 2) = syaw * spitch * croll - cyaw * sroll;
1049  //row 2
1050  globalPoseBuffer(2, 0) = -spitch;
1051  globalPoseBuffer(2, 1) = cpitch * sroll;
1052  globalPoseBuffer(2, 2) = cpitch * croll;
1053 
1054  agentSceneObj->setGlobalPoseNoChecks(globalPoseBuffer);
1056  }
1057 
1058  Ice::StringSeq
1060  {
1061  auto joints = SimoxCSpace::getAgentJointNames();
1062  joints.resize(joints.size() + 6);
1063  std::move_backward(joints.begin(), joints.end() - 6, joints.end());
1064  joints.at(0) = "x";
1065  joints.at(1) = "y";
1066  joints.at(2) = "z";
1067  joints.at(3) = "alpha";
1068  joints.at(4) = "betha";
1069  joints.at(5) = "gamma";
1070  return joints;
1071  }
1072 
1073  std::vector<armarx::DebugDrawerLineSet>
1074  SimoxCSpace::getTraceVisu(const armarx::VectorXfSeq& vecs,
1075  const std::vector<std::string>& nodeNames,
1076  float traceStepSize)
1077  {
1078  if (traceStepSize <= 0)
1079  {
1080  throw std::invalid_argument{"SimoxCSpace::getTraces: traceStepSize <= 0"};
1081  }
1082  std::vector<armarx::DebugDrawerLineSet> traces;
1083  if (nodeNames.empty())
1084  {
1085  return traces;
1086  }
1087  traces.resize(nodeNames.size());
1088  if (vecs.size() < 2)
1089  {
1090  return traces;
1091  }
1092  auto addPoints = [&]
1093  {
1094  for (std::size_t i = 0; i < nodeNames.size(); ++i)
1095  {
1096  const auto& name = nodeNames.at(i);
1097  armarx::DebugDrawerLineSet& trace = traces.at(i);
1098  const auto pose = getAgentSceneObj()->getRobotNode(name)->getGlobalPose();
1099  trace.points.emplace_back(
1100  DebugDrawerPointCloudElement{pose(0, 3), pose(1, 3), pose(2, 3)});
1101  };
1102  };
1103  for (std::size_t vecI = 0; vecI < vecs.size() - 1; ++vecI)
1104  {
1105  const auto& vecStart = vecs.at(vecI);
1106  const auto& vecEnd = vecs.at(vecI + 1);
1107  assert(vecStart.size() == vecEnd.size());
1108  assert(vecStart.size() == static_cast<std::size_t>(getDimensionality()));
1109  auto dist = euclideanDistance(vecStart.begin(), vecStart.end(), vecEnd.begin());
1110  if (dist > traceStepSize)
1111  {
1112  VectorXf vecCfg = vecStart;
1113  Eigen::Map<const Eigen::VectorXf> eStart{vecStart.data(), getDimensionality()};
1114  Eigen::Map<const Eigen::VectorXf> eEnd{vecEnd.data(), getDimensionality()};
1115  Eigen::Map<Eigen::VectorXf> eCfg{vecCfg.data(), getDimensionality()};
1116 
1117  Eigen::VectorXf eStep = (eEnd - eStart).normalized() * traceStepSize;
1118  setConfig(vecCfg);
1119  while (dist > traceStepSize)
1120  {
1121  addPoints(); //start
1122  eCfg += eStep;
1123  setConfig(vecCfg);
1124  addPoints(); //end
1125  dist -= traceStepSize;
1126  }
1127  addPoints(); //start
1128  setConfig(vecEnd);
1129  addPoints(); //end
1130  }
1131  else
1132  {
1133  setConfig(vecStart);
1134  addPoints(); //start
1135  setConfig(vecEnd);
1136  addPoints(); //end
1137  }
1138  }
1139  return traces;
1140  }
1141 } // namespace armarx
armarx::SimoxCSpaceWith2DPose::setConfig
void setConfig(const float *&it) override
Definition: SimoxCSpace.cpp:948
TIMING_START
#define TIMING_START(name)
Definition: TimeUtil.h:289
armarx::eFull
@ eFull
Definition: MorphingItem.h:35
algorithm.h
armarx::SimoxCSpaceWith3DPose::setConfig
void setConfig(const float *&it) override
Definition: SimoxCSpace.cpp:1021
armarx::VariantType::Float
const VariantTypeId Float
Definition: Variant.h:919
armarx::SimoxCSpace::getDimensionsBounds
FloatRangeSeq getDimensionsBounds(const Ice::Current &=Ice::emptyCurrent) const override
Definition: SimoxCSpace.cpp:844
armarx::SimoxCSpace::getAgentDataAndLoadRobot
AgentData getAgentDataAndLoadRobot() const
Definition: SimoxCSpace.cpp:316
TIMING_END
#define TIMING_END(name)
Definition: TimeUtil.h:306
armarx::SimoxCSpaceWith3DPose::SimoxCSpaceWith3DPose
SimoxCSpaceWith3DPose()=default
armarx::GlobalCache::hasObject
bool hasObject(const Id &id) const
Definition: GlobalCache.h:67
armarx::SimoxCSpace::getAgentDataFromRobot
AgentData getAgentDataFromRobot(VirtualRobot::RobotPtr robotPtr) const
Definition: SimoxCSpace.cpp:398
armarx::SimoxCSpace::AgentData::joints
std::vector< VirtualRobot::RobotNodePtr > joints
The agent's joints.
Definition: SimoxCSpace.h:358
armarx::SimoxCSpace::getAgentSceneObj
const VirtualRobot::RobotPtr & getAgentSceneObj() const
Definition: SimoxCSpace.h:204
GfxTL::Matrix4f
MatrixXX< 4, 4, float > Matrix4f
Definition: MatrixXX.h:650
armarx::SimoxCSpace::AgentData::agent
VirtualRobot::RobotPtr agent
The agent's collision model.
Definition: SimoxCSpace.h:354
CSpace.h
Pose.h
armarx::SimoxCSpace::pathToTrajectory
virtual TrajectoryPtr pathToTrajectory(const Path &p) const
Definition: SimoxCSpace.h:225
armarx::SimoxCSpace::isInitialized
bool isInitialized
Whether the collision check is initialized.
Definition: SimoxCSpace.h:304
armarx::GlobalFrame
const std::string GlobalFrame
Definition: FramedPose.h:65
armarx::Split
std::vector< std::string > Split(const std::string &source, const std::string &splitBy, bool trimElements=false, bool removeEmptyElements=false)
Definition: StringHelperTemplates.h:36
armarx::SimoxCSpaceWith2DPose
Similar to armarx::SimoxCSpace, but prepends dimensions for translation in x and y and a rotation aro...
Definition: SimoxCSpace.h:420
armarx::CMakePackageFinder
The CMakePackageFinder class provides an interface to the CMake Package finder capabilities.
Definition: CMakePackageFinder.h:52
armarx::SimoxCSpaceWith2DPose::globalPoseBuffer
Eigen::Matrix4f globalPoseBuffer
Definition: SimoxCSpace.h:464
armarx::SimoxCSpace::getTraceVisu
std::vector< armarx::DebugDrawerLineSet > getTraceVisu(const Path &p, const std::vector< std::string > &nodeNames, float traceStepSize=std::numeric_limits< float >::infinity())
Definition: SimoxCSpace.h:239
Convex::convexHull
ConvexHull< Point >::type convexHull(const std::vector< Point > &points)
Definition: convexHull.hpp:501
armarx::SimoxCSpaceWith3DPose::globalPoseBuffer
Eigen::Matrix4f globalPoseBuffer
Definition: SimoxCSpace.h:518
armarx::RobotPoolPtr
std::shared_ptr< class RobotPool > RobotPoolPtr
Definition: RobotUnitModuleRobotData.h:35
ObjectClass.h
armarx::SimoxCSpace::AgentData::collisionSets
std::vector< VirtualRobot::SceneObjectSetPtr > collisionSets
The collision stes.
Definition: SimoxCSpace.h:362
armarx::SimoxCSpace::initStationaryObjects
void initStationaryObjects()
Initializes stationary objects for collision checking.
Definition: SimoxCSpace.cpp:239
armarx::SimoxCSpace::addObjectsFromWorkingMemory
virtual void addObjectsFromWorkingMemory(memoryx::WorkingMemoryInterfacePrx workingMemoryPrx, const std::vector< std::string > &excludedInstancesIds=std::vector< std::string >())
Adds all objects except the ones with ids specified in the parameter excludedInstancesIds from the wo...
Definition: SimoxCSpace.cpp:685
armarx::SimoxCSpace::createSimoxCSpace
virtual Saba::CSpaceSampledPtr createSimoxCSpace() const
Definition: SimoxCSpace.cpp:137
IceInternal::Handle< SimoxCSpace >
armarx::SimoxCSpaceWith2DPose::getDimensionsBounds
FloatRangeSeq getDimensionsBounds(const Ice::Current &=Ice::emptyCurrent) const override
Definition: SimoxCSpace.cpp:918
deactivateSpam
SpamFilterDataPtr deactivateSpam(SpamFilterDataPtr const &spamFilter, float deactivationDurationSec, const std::string &identifier, bool deactivate)
Definition: Logging.cpp:75
armarx::ensureCoinIsInitialized
bool ensureCoinIsInitialized()
Definition: SimoxCSpace.cpp:59
armarx::SimoxCSpace::fileManager
memoryx::GridFileManagerPtr fileManager
The file manager used to load objects.
Definition: SimoxCSpace.h:314
armarx::SimoxCSpaceWith3DPose::getDimensionsBounds
FloatRangeSeq getDimensionsBounds(const Ice::Current &=Ice::emptyCurrent) const override
Definition: SimoxCSpace.cpp:995
armarx::SimoxCSpace::stationaryPlanes
std::vector< std::vector< Eigen::Vector3f > > stationaryPlanes
Definition: SimoxCSpace.h:332
armarx::SimoxCSpace::robotCache
GlobalCache< RobotPoolPtr, std::pair< VirtualRobot::RobotIO::RobotDescription, std::string > > robotCache
Definition: SimoxCSpace.h:338
armarx::ctrlutil::a
double a(double t, double a0, double j)
Definition: CtrlUtil.h:45
armarx::SimoxCSpace::clone
CSpaceBasePtr clone(const Ice::Current &=Ice::emptyCurrent) override
Definition: SimoxCSpace.h:125
armarx::SimoxCSpace::getDimensionality
Ice::Long getDimensionality(const Ice::Current &=Ice::emptyCurrent) const override
Definition: SimoxCSpace.h:154
ARMARX_DEBUG_S
#define ARMARX_DEBUG_S
Definition: Logging.h:205
armarx::SimoxCSpace::getAgentJointNames
virtual Ice::StringSeq getAgentJointNames() const
Definition: SimoxCSpace.cpp:858
ARMARX_ERROR_S
#define ARMARX_ERROR_S
Definition: Logging.h:216
armarx::SimoxCSpace::ice_postUnmarshal
void ice_postUnmarshal() override
Initializes basic structures after transmission through ice.
Definition: SimoxCSpace.cpp:758
data
uint8_t data[1]
Definition: EtherCATFrame.h:68
ARMARX_DEBUG
#define ARMARX_DEBUG
Definition: Logging.h:184
armarx::SimoxCSpace::addPlanarObject
virtual void addPlanarObject(const std::vector< Eigen::Vector3f > &convexHull)
Definition: SimoxCSpace.cpp:752
armarx::SimoxCSpace::getAgentJoints
const std::vector< VirtualRobot::RobotNodePtr > & getAgentJoints() const
Definition: SimoxCSpace.h:290
armarx::SimoxCSpace::setAgent
void setAgent(const AgentPlanningInformation &agentInfo, const Ice::Current &=Ice::emptyCurrent) override
Adds a stationary agent to the cspace.
Definition: SimoxCSpace.cpp:173
armarx::CMakePackageFinder::getDataDir
std::string getDataDir() const
Definition: CMakePackageFinder.h:194
armarx::SimoxCSpace::initAgent
void initAgent()
Definition: SimoxCSpace.h:377
MemoryXCoreObjectFactories.h
armarx::RobotPool
This class holds a pool of local VirtualRobots for multi threaded applications that can be requested ...
Definition: RobotPool.h:40
armarx::SimoxCSpace::PrefetchWorkingMemoryObjects
static SimoxCSpacePtr PrefetchWorkingMemoryObjects(memoryx::WorkingMemoryInterfacePrx workingMemoryPrx, memoryx::CommonStorageInterfacePrx commonStoragePrx, RobotStateComponentInterfacePrx rsc)
Load objects from WorkingMemory and puts them into the mesh cache.
Definition: SimoxCSpace.cpp:734
armarx::SimoxCSpace::addStationaryObject
void addStationaryObject(const StationaryObject &obj, const Ice::Current &=Ice::emptyCurrent) override
Adds a stationary object to the cspace.
Definition: SimoxCSpace.cpp:159
armarx::SimoxCSpace::getMovedSimoxManipulatorObject
VirtualRobot::ManipulationObjectPtr getMovedSimoxManipulatorObject(const memoryx::ObjectClassBasePtr &object, const armarx::PoseBasePtr &pose, memoryx::GridFileManagerPtr &fileManager) const
Definition: SimoxCSpace.cpp:658
armarx::armem::Time
armarx::core::time::DateTime Time
Definition: forward_declarations.h:13
memoryx::EntityWrappers::SimoxObjectWrapper
SimoxObjectWrapper offers a simplified access to the Simox ManipulationObject (i.e visualization,...
Definition: SimoxObjectWrapper.h:46
armarx::to_string
const std::string & to_string(const std::string &s)
Definition: StringHelpers.h:41
armarx::SimoxCSpace::initCollisionTest
void initCollisionTest(const Ice::Current &=Ice::emptyCurrent) override
Initializes the collision test.
Definition: SimoxCSpace.cpp:209
armarx::TrajectoryPtr
IceInternal::Handle< Trajectory > TrajectoryPtr
Definition: Trajectory.h:52
armarx::SimoxCSpaceWith2DPose::getAgentJointNames
Ice::StringSeq getAgentJointNames() const override
Definition: SimoxCSpace.cpp:936
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::SimoxCSpaceWith3DPose::getAgentJointNames
Ice::StringSeq getAgentJointNames() const override
Definition: SimoxCSpace.cpp:1059
armarx::control::njoint_controller::platform::platform_follower_controller::NameValueMap
std::map< std::string, float > NameValueMap
Definition: PlatformFollowerController.h:88
armarx::SimoxCSpace::AgentData
Contains information about an agent.
Definition: SimoxCSpace.h:349
armarx::SimoxCSpace::meshCache
GlobalCache< VirtualRobot::ManipulationObjectPtr, std::pair< int, std::string > > meshCache
Definition: SimoxCSpace.h:335
armarx::euclideanDistance
float euclideanDistance(IteratorType1 first1, IteratorType1 last1, IteratorType2 first2)
Returns the euclidean distance.
Definition: Metrics.h:104
CMakePackageFinder.h
SimoxObjectWrapper.h
SimoxCSpace.h
ObjectInstance.h
ARMARX_CHECK_EXPRESSION
#define ARMARX_CHECK_EXPRESSION(expression)
This macro evaluates the expression and if it turns out to be false it will throw an ExpressionExcept...
Definition: ExpressionException.h:73
armarx::SimoxCSpaceWith2DPose::clone
CSpaceBasePtr clone(bool loadVisualizationModel) override
Definition: SimoxCSpace.cpp:903
ARMARX_INFO
#define ARMARX_INFO
Definition: Logging.h:181
memoryx::GridFileManagerPtr
std::shared_ptr< GridFileManager > GridFileManagerPtr
Definition: AbstractEntityWrapper.h:33
armarx::SimoxCSpace::stationaryObjectSet
VirtualRobot::SceneObjectSetPtr stationaryObjectSet
The scene objects for stationary objects.
Definition: SimoxCSpace.h:325
armarx::SimoxCSpaceWith3DPose::clone
CSpaceBasePtr clone(bool loadVisualizationModel) override
Definition: SimoxCSpace.cpp:980
magic_enum::detail::find
constexpr std::size_t find(string_view str, char_type c) noexcept
Definition: magic_enum.hpp:309
armarx::SimoxCSpaceWith3DPose
Similar to armarx::SimoxCSpace, but prepends dimensions for translation in x, y and z and rotations a...
Definition: SimoxCSpace.h:474
IceInternal::ProxyHandle<::IceProxy::armarx::RobotStateComponentInterface >
armarx::SimoxCSpace::setStationaryObjects
virtual void setStationaryObjects(const StationaryObjectList &objList)
Definition: SimoxCSpace.cpp:167
armarx::SimoxCSpace::loadVisualizationModel
bool loadVisualizationModel
Whether the visualization model of objects/agents sould be loaded.
Definition: SimoxCSpace.h:308
armarx::Trajectory
The Trajectory class represents n-dimensional sampled trajectories.
Definition: Trajectory.h:76
scene3D::SceneObjectPtr
boost::intrusive_ptr< SceneObject > SceneObjectPtr
Definition: PointerDefinitions.h:40
memoryx::GridFileManager
GridFileManager provides utility functions for working with files in Mongo GridFS and links to them s...
Definition: GridFileManager.h:41
armarx::SimoxCSpace::cd
VirtualRobot::CDManager cd
The collision checker.
Definition: SimoxCSpace.h:320
MemoryXTypesObjectFactories.h
armarx::SimoxCSpace::agentSceneObj
VirtualRobot::RobotPtr agentSceneObj
Definition: SimoxCSpace.h:330
distance
double distance(const Point &a, const Point &b)
Definition: point.hpp:95
armarx::SimoxCSpace::setConfig
virtual void setConfig(const std::vector< float > cfg)
Sets a configuration to check for.
Definition: SimoxCSpace.h:164
ARMARX_INFO_S
#define ARMARX_INFO_S
Definition: Logging.h:202
armarx::ArmarXDataPath::getAbsolutePath
static bool getAbsolutePath(const std::string &relativeFilename, std::string &storeAbsoluteFilename, const std::vector< std::string > &additionalSearchPaths={}, bool verbose=true)
Definition: ArmarXDataPath.cpp:109
armarx::SimoxCSpace
The SimoxCSpace contains a set of stationary obstacles and an agent.
Definition: SimoxCSpace.h:66
armarx::transpose
std::vector< std::vector< T > > transpose(const std::vector< std::vector< T >> &src, Thrower thrower)
Definition: SimoxCSpace.cpp:772
armarx::SimoxCSpace::isCollisionFree
bool isCollisionFree(const ::std::pair< const Ice::Float *, const Ice::Float * > &cfg, const Ice::Current &=Ice::emptyCurrent) override
Definition: SimoxCSpace.cpp:194
armarx::GlobalCache::getCacheObject
ObjectTypePtr getCacheObject(const Id &id)
Definition: GlobalCache.h:74
ArmarXDataPath.h
armarx::SimoxCSpace::SimoxCSpace
SimoxCSpace()=default
Default ctor.
armarx::ctrlutil::s
double s(double t, double s0, double v0, double a0, double j)
Definition: CtrlUtil.h:33
armarx
This file offers overloads of toIce() and fromIce() functions for STL container types.
Definition: ArmarXTimeserver.cpp:27
IceInternal::trace
void trace(const char *, const ::Ice::OutputStream &, const ::Ice::LoggerPtr &, const TraceLevelsPtr &)
armarx::GlobalCache::insertObject
void insertObject(const Id &id, const ObjectTypePtr &obj)
Definition: GlobalCache.h:90
armarx::SimoxCSpace::agentJoints
std::vector< VirtualRobot::RobotNodePtr > agentJoints
Definition: SimoxCSpace.h:328
armarx::SimoxCSpaceWith3DPose::getDimensionality
Ice::Long getDimensionality(const Ice::Current &=Ice::emptyCurrent) const override
Definition: SimoxCSpace.h:504
VirtualRobot::RobotPtr
std::shared_ptr< class Robot > RobotPtr
Definition: Bus.h:19
armarx::SimoxCSpaceWith2DPose::getDimensionality
Ice::Long getDimensionality(const Ice::Current &=Ice::emptyCurrent) const override
Definition: SimoxCSpace.h:450
armarx::SimoxCSpace::getSimoxManipulatorObject
VirtualRobot::ManipulationObjectPtr getSimoxManipulatorObject(const memoryx::ObjectClassBasePtr &object, const memoryx::GridFileManagerPtr &fileManager, bool inflate=true, VirtualRobot::CollisionCheckerPtr const &colChecker=VirtualRobot::CollisionCheckerPtr{}) const
Definition: SimoxCSpace.cpp:591