KinematicsWorld.cpp
Go to the documentation of this file.
1 /*
2  * This file is part of ArmarX.
3  *
4  * Copyright (C) 2013-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 ArmarXSimulation::Simulator
19  * @author Nikolaus ( vahrenkamp at kit dot edu )
20  * @date 2017
21  * @copyright http://www.gnu.org/licenses/gpl-2.0.txt
22  * GNU General Public License
23  */
24 
25 #include "KinematicsWorld.h"
26 
27 #include <VirtualRobot/Visualization/VisualizationFactory.h>
28 #include <VirtualRobot/CollisionDetection/CollisionChecker.h>
29 #include <VirtualRobot/Nodes/ForceTorqueSensor.h>
30 #include <VirtualRobot/RobotFactory.h>
31 #include <VirtualRobot/RobotNodeSet.h>
32 #include <VirtualRobot/IK/DifferentialIK.h>
33 #include <VirtualRobot/IK/IKSolver.h>
34 #include <VirtualRobot/Obstacle.h>
35 
38 #include <algorithm>
40 
41 using namespace VirtualRobot;
42 using namespace armarx;
43 
44 
45 KinematicsWorld::KinematicsWorld() : SimulatedWorld()
46 {
47  synchronizeDurationMS = 0.0f;
48  currentSimTimeSec = 0.0f;
49 
50  floorPos.setZero();
51  floorUp.setZero();
52  floorDepthMM = 500.0f;
53  floorExtendMM = 50000.0f;
54 }
55 
57  = default;
58 
59 void KinematicsWorld::initialize(int stepSizeMS, float maxRealTimeSimSpeed, bool floorPlane, std::string floorTexture)
60 {
61  ARMARX_INFO_S << "Init KinematicsWorld...";
62 
63  simVisuData.robots.clear();
64  simVisuData.objects.clear();
65  simVisuData.floorTextureFile.clear();
66  simVisuData.floor = false;
67 
68  simReportData.robots.clear();
69 
70  this->maxRealTimeSimSpeed = maxRealTimeSimSpeed;
71  this->stepSizeMs = stepSizeMS;
72 
73  setupFloor(floorPlane, floorTexture);
74 }
75 
76 
77 void KinematicsWorld::createFloorPlane(const Eigen::Vector3f& pos, const Eigen::Vector3f& up)
78 {
79  ScopedRecursiveLockPtr lockEngine = getScopedEngineLock(__FUNCTION__);
80  floorPos = pos;
81  floorUp = up;
82  float size = float(floorExtendMM);
83  float sizeSmall = float(floorDepthMM);
84  float w = size;
85  float h = size;
86  float d = sizeSmall;
87 
88  if (up(1) == 0 && up(2) == 0)
89  {
90  w = sizeSmall;
91  h = size;
92  d = size;
93  }
94  else if (up(0) == 0 && up(2) == 0)
95  {
96  w = size;
97  h = sizeSmall;
98  d = size;
99  }
100 
101  groundObject = VirtualRobot::Obstacle::createBox(w, h, d, VirtualRobot::VisualizationFactory::Color::Gray());
102  std::string name("Floor");
103  groundObject->setName(name);
104  Eigen::Matrix4f gp;
105  gp.setIdentity();
106  gp(2, 3) = -sizeSmall * 0.5f;
107  groundObject->setGlobalPose(gp);
108 
109  groundObject->getVisualization();
110  groundObject->setSimulationType(VirtualRobot::SceneObject::Physics::eStatic);
111 
112  //addObstacleEngine(groundObject, VirtualRobot::SceneObject::Physics::eStatic);
113 }
114 
115 void KinematicsWorld::actuateRobotJoints(const std::string& robotName, const std::map< std::string, float>& angles, const std::map< std::string, float>& velocities)
116 {
117  ScopedRecursiveLockPtr lockEngine = getScopedEngineLock(__FUNCTION__);
118 
119  ARMARX_DEBUG_S << "actuateRobotJoints: first:" << angles.begin()->first << ", ang: " << angles.begin()->second << ", vel:" << velocities.begin()->second;
120  VirtualRobot::RobotPtr kinRobot = getRobot(robotName);
121  if (!kinRobot)
122  {
123  ARMARX_WARNING_S << "No robot available";
124  return;
125  }
126  kinRobot->setJointValues(angles);
127 
128  // Set velocities to zero
129  KinematicRobotInfo& ri = kinematicRobots[robotName];
130  for (auto& entry : angles)
131  {
132  ri.targetVelocities[entry.first] = 0;
133  }
134 }
135 
136 void KinematicsWorld::actuateRobotJointsPos(const std::string& robotName, const std::map< std::string, float>& angles)
137 {
138  ScopedRecursiveLockPtr lockEngine = getScopedEngineLock(__FUNCTION__);
139  if (angles.size() == 0)
140  {
141  return;
142  }
143  ARMARX_DEBUG_S << "actuateRobotJointsPos: first:" << angles.begin()->first << ", ang: " << angles.begin()->second;
144 
145  VirtualRobot::RobotPtr kinRobot = getRobot(robotName);
146  if (!kinRobot)
147  {
148  ARMARX_WARNING_S << "No robot available";
149  return;
150  }
151  kinRobot->setJointValues(angles);
152 
153  // Set velocities to zero
154  KinematicRobotInfo& ri = kinematicRobots[robotName];
155  for (auto& entry : angles)
156  {
157  ri.targetVelocities[entry.first] = 0;
158  }
159 }
160 
161 void KinematicsWorld::actuateRobotJointsVel(const std::string& robotName, const std::map< std::string, float>& velocities)
162 {
163  ScopedRecursiveLockPtr lockEngine = getScopedEngineLock(__FUNCTION__);
164  ARMARX_DEBUG_S << "actuateRobotJointsVel: first: vel:" << velocities.begin()->second;
165 
166  VirtualRobot::RobotPtr kinRobot = getRobot(robotName);
167  if (!kinRobot)
168  {
169  ARMARX_WARNING_S << "No robot available";
170  return;
171  }
172 
173  // store velocities for static robots
174  KinematicRobotInfo& ri = kinematicRobots[robotName];
175  // preserve all values of velocities, and add values of robotInfo
176  std::map<std::string, float> res = velocities;
177  res.insert(ri.targetVelocities.begin(), ri.targetVelocities.end());
178  ri.targetVelocities = res;
179 }
180 
181 void KinematicsWorld::actuateRobotJointsTorque(const std::string& robotName, const std::map< std::string, float>& torques)
182 {
183  ScopedRecursiveLockPtr lockEngine = getScopedEngineLock(__FUNCTION__);
184  ARMARX_DEBUG_S << "actuateRobotJointsTorque: first:" << torques.begin()->first << "," << torques.begin()->second;
185 
186  ARMARX_DEBUG_S << "No torque mode available...";
187 }
188 
189 void KinematicsWorld::setRobotPose(const std::string& robotName, const Eigen::Matrix4f& globalPose)
190 {
191  ScopedRecursiveLockPtr lockEngine = getScopedEngineLock(__FUNCTION__);
192  ARMARX_DEBUG << "setRobotPose:" << globalPose(0, 3) << "," << globalPose(1, 3) << ", " << globalPose(2, 3);
193 
194  VirtualRobot::RobotPtr kinRobot = getRobot(robotName);
195  if (!kinRobot)
196  {
197  ARMARX_WARNING_S << "No robot available";
198  return;
199  }
200 
201  kinRobot->setGlobalPose(globalPose);
202 }
203 
204 void KinematicsWorld::applyForceRobotNode(const std::string& robotName, const std::string& robotNodeName, const Eigen::Vector3f& force)
205 {
206  ScopedRecursiveLockPtr lockEngine = getScopedEngineLock(__FUNCTION__);
207  ARMARX_DEBUG_S << "ApplyForce not available";
208 }
209 
210 void KinematicsWorld::applyTorqueRobotNode(const std::string& robotName, const std::string& robotNodeName, const Eigen::Vector3f& torque)
211 {
212  ScopedRecursiveLockPtr lockEngine = getScopedEngineLock(__FUNCTION__);
213  ARMARX_DEBUG_S << "ApplyTorque not available";
214 }
215 
216 void KinematicsWorld::applyForceObject(const std::string& objectName, const Eigen::Vector3f& force)
217 {
218  ScopedRecursiveLockPtr lockEngine = getScopedEngineLock(__FUNCTION__);
219  ARMARX_DEBUG_S << "applyForceObject not available";
220 }
221 
222 void KinematicsWorld::applyTorqueObject(const std::string& objectName, const Eigen::Vector3f& torque)
223 {
224  ScopedRecursiveLockPtr lockEngine = getScopedEngineLock(__FUNCTION__);
225  ARMARX_DEBUG_S << "applyTorqueObject not available";
226 }
227 
228 
229 bool KinematicsWorld::hasObject(const std::string& instanceName)
230 {
231  return getObject(instanceName).get();
232 }
233 
234 void KinematicsWorld::setObjectPose(const std::string& objectName, const Eigen::Matrix4f& globalPose)
235 {
236  ScopedRecursiveLockPtr lockEngine = getScopedEngineLock(__FUNCTION__);
237  VirtualRobot::SceneObjectPtr o = getObject(objectName);
238 
239  if (!o)
240  {
241  ARMARX_WARNING_S << "No object found with name " << objectName;
242  return;
243  }
244 
245  o->setGlobalPose(globalPose);
246 }
247 
248 
249 float KinematicsWorld::getRobotMass(const std::string& robotName)
250 {
251  ScopedRecursiveLockPtr lockEngine = getScopedEngineLock(__FUNCTION__);
252 
253  VirtualRobot::RobotPtr kinRobot = getRobot(robotName);
254  if (!kinRobot)
255  {
256  ARMARX_WARNING_S << "No robot available";
257  return 0;
258  }
259 
260  return kinRobot->getMass();
261 }
262 
263 std::map< std::string, float> KinematicsWorld::getRobotJointAngles(const std::string& robotName)
264 {
265  ScopedRecursiveLockPtr lockEngine = getScopedEngineLock(__FUNCTION__);
266  std::map<std::string, float> res;
267 
268  VirtualRobot::RobotPtr kinRob = getRobot(robotName);
269  if (!kinRob)
270  {
271  ARMARX_WARNING_S << "No robot available";
272  return std::map< std::string, float>();
273  }
274 
275  std::vector<RobotNodePtr> rn = kinRob->getRobotNodes();
276 
277  for (auto& i : rn)
278  {
279  if (i->isJoint())
280  {
281  res[i->getName()] = i->getJointValue();
282  }
283  }
284 
285  ARMARX_DEBUG_S << "getRobotJointAngles:" << res.begin()->second;
286 
287  return res;
288 }
289 
290 float KinematicsWorld::getRobotJointAngle(const std::string& robotName, const std::string& nodeName)
291 {
292  ScopedRecursiveLockPtr lockEngine = getScopedEngineLock(__FUNCTION__);
293 
294  VirtualRobot::RobotPtr kinRob = getRobot(robotName);
295  if (!kinRob)
296  {
297  ARMARX_WARNING_S << "No robot available";
298  return 0;
299  }
300 
301  if (!kinRob->hasRobotNode(nodeName))
302  {
303  ARMARX_WARNING_S << "No robotNode available with name " << nodeName;
304  return 0;
305  }
306 
307  float res = kinRob->getRobotNode(nodeName)->getJointValue();
308  ARMARX_DEBUG_S << "getRobotJointAngle:" << res;
309  return res;
310 }
311 
312 std::map< std::string, float> KinematicsWorld::getRobotJointVelocities(const std::string& robotName)
313 {
314  ScopedRecursiveLockPtr lockEngine = getScopedEngineLock(__FUNCTION__);
315  std::map< std::string, float> res;
316 
317  VirtualRobot::RobotPtr kinRobot = getRobot(robotName);
318  if (!kinRobot)
319  {
320  ARMARX_WARNING_S << "No robot available";
321  return res;
322  }
323 
324  KinematicRobotInfo& ri = kinematicRobots[robotName];
325  res = ri.targetVelocities;
326 
327  ARMARX_DEBUG_S << "getRobotJointVelocities:" << res.begin()->second;
328  return res;
329 }
330 
331 float KinematicsWorld::getRobotJointVelocity(const std::string& robotName, const std::string& nodeName)
332 {
333  ScopedRecursiveLockPtr lockEngine = getScopedEngineLock(__FUNCTION__);
334 
335  VirtualRobot::RobotPtr kinRobot = getRobot(robotName);
336  if (!kinRobot)
337  {
338  ARMARX_WARNING_S << "No robot available";
339  return 0;
340  }
341 
342  if (!kinRobot->hasRobotNode(nodeName))
343  {
344  ARMARX_WARNING_S << "No robotNode available with name " << nodeName;
345  return 0;
346  }
347  KinematicRobotInfo& ri = kinematicRobots[robotName];
348 
349  float res = 0.0f;
350  if (ri.targetVelocities.find(nodeName) != ri.targetVelocities.end())
351  {
352  res = ri.targetVelocities[nodeName];
353  }
354 
355  ARMARX_DEBUG_S << "getRobotJointVelocity:" << res;
356  return res;
357 }
358 
359 std::map<std::string, float> KinematicsWorld::getRobotJointTorques(const std::string&)
360 {
361  return std::map< std::string, float>();
362 }
363 
364 ForceTorqueDataSeq KinematicsWorld::getRobotForceTorqueSensors(const std::string&)
365 {
366  return {};
367 }
368 
369 float KinematicsWorld::getRobotJointLimitLo(const std::string& robotName, const std::string& nodeName)
370 {
371  ScopedRecursiveLockPtr lockEngine = getScopedEngineLock(__FUNCTION__);
372 
373  VirtualRobot::RobotPtr kinRobot = getRobot(robotName);
374  if (!kinRobot)
375  {
376  ARMARX_WARNING_S << "No robot available";
377  return 0;
378  }
379 
380  if (!kinRobot->hasRobotNode(nodeName))
381  {
382  ARMARX_WARNING_S << "No robotNode available with name " << nodeName;
383  return 0;
384  }
385 
386  return kinRobot->getRobotNode(nodeName)->getJointLimitLo();
387 }
388 
389 float KinematicsWorld::getRobotJointLimitHi(const std::string& robotName, const std::string& nodeName)
390 {
391  ScopedRecursiveLockPtr lockEngine = getScopedEngineLock(__FUNCTION__);
392 
393  VirtualRobot::RobotPtr kinRobot = getRobot(robotName);
394  if (!kinRobot)
395  {
396  ARMARX_WARNING_S << "No robot available";
397  return 0;
398  }
399 
400  if (!kinRobot->hasRobotNode(nodeName))
401  {
402  ARMARX_WARNING_S << "No robotNode available with name " << nodeName;
403  return 0;
404  }
405 
406  return kinRobot->getRobotNode(nodeName)->getJointLimitHi();
407 }
408 
409 Eigen::Matrix4f KinematicsWorld::getRobotPose(const std::string& robotName)
410 {
411  ScopedRecursiveLockPtr lockEngine = getScopedEngineLock(__FUNCTION__);
412  ARMARX_DEBUG_S << "get robot pose";
413 
414  VirtualRobot::RobotPtr kinRobot = getRobot(robotName);
415  if (!kinRobot)
416  {
417  ARMARX_WARNING_S << "No robot available";
418  return Eigen::Matrix4f::Identity();
419  }
420 
421  return kinRobot->getGlobalPose();
422 }
423 
424 float KinematicsWorld::getRobotMaxTorque(const std::string& robotName, const std::string& nodeName)
425 {
426  ScopedRecursiveLockPtr lockEngine = getScopedEngineLock(__FUNCTION__);
427  ARMARX_DEBUG_S << "getRobotMaxTorque";
428 
429  VirtualRobot::RobotPtr kinRobot = getRobot(robotName);
430  if (!kinRobot)
431  {
432  ARMARX_WARNING_S << "Robot '" << robotName << "' not found";
433  return 0.0f;
434  }
435 
436  if (!kinRobot->hasRobotNode(nodeName))
437  {
438  ARMARX_WARNING_S << "Robot node '" << nodeName << "' does not exist";
439  return 0.0f;
440  }
441 
442  return kinRobot->getRobotNode(nodeName)->getMaxTorque();
443 }
444 
445 void KinematicsWorld::setRobotMaxTorque(const std::string& robotName, const std::string& nodeName, float maxTorque)
446 {
447  ScopedRecursiveLockPtr lockEngine = getScopedEngineLock(__FUNCTION__);
448  ARMARX_DEBUG_S << "setRobotMaxTorque";
449 
450  VirtualRobot::RobotPtr kinRobot = getRobot(robotName);
451  if (!kinRobot)
452  {
453  ARMARX_WARNING_S << "Robot '" << robotName << "' not found";
454  return;
455  }
456 
457  if (!kinRobot->hasRobotNode(nodeName))
458  {
459  ARMARX_WARNING_S << "Robot node '" << nodeName << "' does not exist";
460  return;
461  }
462 
463  kinRobot->getRobotNode(nodeName)->setMaxTorque(maxTorque);
464 }
465 
466 Eigen::Matrix4f KinematicsWorld::getRobotNodePose(const std::string& robotName, const std::string& robotNodeName)
467 {
468  ScopedRecursiveLockPtr lockEngine = getScopedEngineLock(__FUNCTION__);
469  ARMARX_DEBUG_S << "get robot node pose";
470 
471  VirtualRobot::RobotPtr kinRobot = getRobot(robotName);
472  if (!kinRobot)
473  {
474  ARMARX_WARNING_S << "No robot available";
475  return Eigen::Matrix4f::Identity();
476  }
477 
478  if (!kinRobot->hasRobotNode(robotNodeName))
479  {
480  ARMARX_WARNING_S << "No robotNode available with name " << robotNodeName;
481  return Eigen::Matrix4f::Identity();
482  }
483 
484  return kinRobot->getRobotNode(robotNodeName)->getGlobalPose();
485 }
486 
487 
488 Eigen::Vector3f KinematicsWorld::getRobotLinearVelocity(const std::string& robotName, const std::string& nodeName)
489 {
490  ScopedRecursiveLockPtr lockEngine = getScopedEngineLock(__FUNCTION__);
491  ARMARX_DEBUG_S << "get robot linear velocity";
492 
493  VirtualRobot::RobotPtr kinRobot = getRobot(robotName);
494  if (!kinRobot)
495  {
496  ARMARX_WARNING_S << "No robot available";
497  return Eigen::Vector3f::Identity();
498  }
499  KinematicRobotInfo& ri = kinematicRobots[robotName];
500 
501  return ri.velTransActual;
502 }
503 
504 
505 Eigen::Vector3f KinematicsWorld::getRobotAngularVelocity(const std::string& robotName, const std::string& nodeName)
506 {
507  ScopedRecursiveLockPtr lockEngine = getScopedEngineLock(__FUNCTION__);
508  ARMARX_DEBUG << "get robot angular vel";
509 
510  VirtualRobot::RobotPtr kinRobot = getRobot(robotName);
511  if (!kinRobot)
512  {
513  ARMARX_WARNING << "No robot available";
514  return Eigen::Vector3f::Identity();
515  }
516  KinematicRobotInfo& ri = kinematicRobots[robotName];
517 
518  RobotNodePtr rn = kinRobot->getRobotNode(nodeName);
519  if (!rn)
520  {
521  ARMARX_WARNING << "No rn found with name " << nodeName;
522  return Eigen::Vector3f::Identity();
523  }
524 
525  // Get jacobian
526  RobotNodeSetPtr rns = RobotNodeSet::createRobotNodeSet(kinRobot, "All_Nodes", kinRobot->getRobotNodes());
527  DifferentialIKPtr j(new DifferentialIK(rns));
528  Eigen::MatrixXf jac = j->getJacobianMatrix(rn, IKSolver::Orientation);
529 
530  // Get joint velocities
531  std::vector<std::string> nodeNames = rns->getNodeNames();
532  Eigen::VectorXf joint_vel(nodeNames.size());
533  int i = 0;
534  for (std::vector<std::string>::iterator it = nodeNames.begin(); it != nodeNames.end(); ++it, ++i)
535  {
536  joint_vel(i) = ri.actualVelocities[*it];
537  }
538 
539  Eigen::Vector3f omega;
540  omega = jac * joint_vel; // vel induced by robot joints
541 
542  return ri.velRotActual + omega;
543 }
544 
545 void KinematicsWorld::setRobotLinearVelocity(const std::string& robotName, const std::string& robotNodeName, const Eigen::Vector3f& vel)
546 {
547  ScopedRecursiveLockPtr lockEngine = getScopedEngineLock(__FUNCTION__);
548  ARMARX_DEBUG_S << "set robot lin vel";
549 
550  VirtualRobot::RobotPtr kinRobot = getRobot(robotName);
551  if (!kinRobot)
552  {
553  ARMARX_WARNING_S << "No robot available";
554  return ;
555  }
556  KinematicRobotInfo& ri = kinematicRobots[robotName];
557 
558  ri.velTransTarget = vel * 1000.0f; // m -> mm
559  ARMARX_DEBUG_S << "set robot lin vel end";
560 }
561 
562 void KinematicsWorld::setRobotAngularVelocity(const std::string& robotName, const std::string& robotNodeName, const Eigen::Vector3f& vel)
563 {
564  ScopedRecursiveLockPtr lockEngine = getScopedEngineLock(__FUNCTION__);
565  ARMARX_DEBUG_S << "set robot ang vel";
566 
567  ARMARX_DEBUG_S << "set robot lin vel";
568 
569  VirtualRobot::RobotPtr kinRobot = getRobot(robotName);
570  if (!kinRobot)
571  {
572  ARMARX_WARNING_S << "No robot available";
573  return;
574  }
575  KinematicRobotInfo& ri = kinematicRobots[robotName];
576 
577  ri.velRotTarget = vel;
578  ARMARX_DEBUG_S << "set robot ang vel end";
579 }
580 
581 void KinematicsWorld::setRobotLinearVelocityRobotRootFrame(const std::string& robotName, const std::string& robotNodeName, const Eigen::Vector3f& vel)
582 {
583  ScopedRecursiveLockPtr lockEngine = getScopedEngineLock(__FUNCTION__);
584  ARMARX_DEBUG_S << "set robot lin vel";
585 
586  VirtualRobot::RobotPtr kinRobot = getRobot(robotName);
587  if (!kinRobot)
588  {
589  ARMARX_WARNING_S << "No robot available";
590  return;
591  }
592  KinematicRobotInfo& ri = kinematicRobots[robotName];
593 
594  Eigen::Matrix4f newPose;
595  newPose.setIdentity();
596  newPose.block<3, 1>(0, 3) = vel;
597  auto globalPose = kinRobot->getGlobalPose();
598  globalPose(0, 3) = 0;
599  globalPose(1, 3) = 0;
600  globalPose(2, 3) = 0;
601  Eigen::Matrix4f globalNewPose = globalPose * newPose;
602  ri.velTransTarget = globalNewPose.block<3, 1>(0, 3) * 1000.0f; // m -> mm
603  ARMARX_DEBUG_S << "set robot lin vel end";
604 }
605 
606 void KinematicsWorld::setRobotAngularVelocityRobotRootFrame(const std::string& robotName, const std::string& robotNodeName, const Eigen::Vector3f& vel)
607 {
608  ScopedRecursiveLockPtr lockEngine = getScopedEngineLock(__FUNCTION__);
609  ARMARX_DEBUG_S << "set robot ang vel";
610 
611  VirtualRobot::RobotPtr kinRobot = getRobot(robotName);
612  if (!kinRobot)
613  {
614  ARMARX_WARNING_S << "No robot available";
615  return;
616  }
617  KinematicRobotInfo& ri = kinematicRobots[robotName];
618 
619  Eigen::Matrix4f newPose;
620  newPose.setIdentity();
621  newPose.block<3, 1>(0, 3) = vel;
622  Eigen::Matrix4f globalPose = kinRobot->getGlobalPose();
623  globalPose(0, 3) = 0;
624  globalPose(1, 3) = 0;
625  globalPose(2, 3) = 0;
626  Eigen::Matrix4f globalNewPose = globalPose * newPose;
627  ri.velRotTarget = globalNewPose.block<3, 1>(0, 3);
628 }
629 
630 bool KinematicsWorld::hasRobot(const std::string& robotName)
631 {
632  ScopedRecursiveLockPtr lockEngine = getScopedEngineLock(__FUNCTION__);
633 
634  std::map<std::string, KinematicRobotInfo>::iterator it = kinematicRobots.begin();
635  while (it != kinematicRobots.end())
636  {
637  if (it->first == robotName)
638  {
639  return true;
640  }
641  it++;
642  }
643 
644  return false;
645 }
646 
647 bool KinematicsWorld::hasRobotNode(const std::string& robotName, const std::string& robotNodeName)
648 {
649  ScopedRecursiveLockPtr lockEngine = getScopedEngineLock(__FUNCTION__);
650 
651  VirtualRobot::RobotPtr kinRobot = getRobot(robotName);
652  if (!kinRobot)
653  {
654  ARMARX_WARNING_S << "No robot available";
655  return false;
656  }
657 
658  return (kinRobot->hasRobotNode(robotNodeName));
659 }
660 
661 
663 {
664  ScopedRecursiveLockPtr lockEngine = getScopedEngineLock(__FUNCTION__);
665 
666  if (!hasRobot(robotName))
667  {
668  ARMARX_WARNING_S << "No robot with name " << robotName;
669  return VirtualRobot::RobotPtr();
670  }
671 
672  return kinematicRobots[robotName].robot;
673 }
674 
675 std::map<std::string, RobotPtr> KinematicsWorld::getRobots()
676 {
677  std::map<std::string, RobotPtr> result;
678  ScopedRecursiveLockPtr lockEngine = getScopedEngineLock(__FUNCTION__);
679  for (auto& elem : kinematicRobots)
680  {
681  const KinematicRobotInfo& info = elem.second;
682  result[elem.first] = (info.robot);
683  }
684  return result;
685 }
686 
688 {
690  std::vector<VirtualRobot::SceneObjectPtr>::const_iterator it;
691 
692  for (it = kinematicObjects.begin(); it != kinematicObjects.end(); it++)
693  {
694  if ((*it)->getName() == objectName)
695  {
696  o = *it;
697  break;
698  }
699  }
700 
701  return o;
702 }
703 
704 Eigen::Matrix4f KinematicsWorld::getObjectPose(const std::string& objectName)
705 {
706  ScopedRecursiveLockPtr lockEngine = getScopedEngineLock(__FUNCTION__);
707  ARMARX_DEBUG_S << "get object pose";
708 
709  VirtualRobot::SceneObjectPtr o = getObject(objectName);
710  if (!o)
711  {
712  ARMARX_WARNING_S << "No object found with name " << objectName;
713  return Eigen::Matrix4f::Identity();
714  }
715 
716  return o->getGlobalPose();
717 }
718 
719 bool KinematicsWorld::objectReleasedEngine(const std::string& robotName, const std::string& robotNodeName, const std::string& objectName)
720 {
721  ScopedRecursiveLockPtr lockEngine = getScopedEngineLock(__FUNCTION__);
722  ARMARX_INFO_S << "Object released, robot " << robotName << ", node:" << robotNodeName << ", object:" << objectName;
723  VirtualRobot::RobotPtr kinRobot = getRobot(robotName);
724  if (!kinRobot)
725  {
726  ARMARX_WARNING_S << "No robot available";
727  return false;
728  }
729 
730  if (!kinRobot->hasRobotNode(robotNodeName))
731  {
732  ARMARX_WARNING_S << "No robotNode available with name " << robotNodeName;
733  return false;
734  }
735 
736  /*VirtualRobot::SceneObjectPtr o = getObject(objectName);
737 
738  if (!o)
739  {
740  ARMARX_WARNING_S << "No object found with name " << objectName;
741  return false;
742  }*/
743  RobotNodePtr rn = kinRobot->getRobotNode(objectName);
744  if (!rn)
745  {
746  ARMARX_WARNING_S << "No rn found with name " << objectName;
747  return false;
748  }
749 
750  bool res = RobotFactory::detach(kinRobot, rn);
751  return res;
752 }
753 
754 bool KinematicsWorld::objectGraspedEngine(const std::string& robotName, const std::string& robotNodeName, const std::string& objectName, Eigen::Matrix4f& storeLocalTransform)
755 {
756  ScopedRecursiveLockPtr lockEngine = getScopedEngineLock(__FUNCTION__);
757  ARMARX_INFO_S << "Object grasped, robot " << robotName << ", node:" << robotNodeName << ", object:" << objectName;
758 
759  // check if object is already grasped
760  for (const auto& ao : attachedObjects)
761  {
762  if (ao.robotName == robotName && ao.robotNodeName == robotNodeName && ao.objectName == objectName)
763  {
764  ARMARX_INFO_S << "Object already attached, skipping...";
765  return false;
766  }
767  }
768  VirtualRobot::RobotPtr kinRobot = getRobot(robotName);
769  if (!kinRobot)
770  {
771  ARMARX_WARNING_S << "No robot available";
772  return false;
773  }
774 
775  if (!kinRobot->hasRobotNode(robotNodeName))
776  {
777  ARMARX_WARNING_S << "No robotNode available with name " << robotNodeName;
778  return false;
779  }
780 
781  RobotNodePtr rn = kinRobot->getRobotNode(robotNodeName);
782 
783  VirtualRobot::SceneObjectPtr o = getObject(objectName);
784 
785  if (!o)
786  {
787  ARMARX_WARNING_S << "No object found with name " << objectName;
788  return false;
789  }
790 
791  storeLocalTransform = rn->toLocalCoordinateSystem(o->getGlobalPose());
792  bool res = RobotFactory::attach(kinRobot, o, rn, storeLocalTransform);
793  return res;
794 }
795 
796 
798 {
799  return groundObject;
800 }
801 
802 
803 
804 bool KinematicsWorld::removeRobotEngine(const std::string& robotName)
805 {
806  // lock engine and data
807  ScopedRecursiveLockPtr lockEngine = getScopedEngineLock(__FUNCTION__);
808 
809  VirtualRobot::RobotPtr kinRobot = getRobot(robotName);
810  if (!kinRobot)
811  {
812  ARMARX_WARNING_S << "No robot available";
813  return false;
814  }
815 
816  ARMARX_DEBUG_S << "Removing robot " << robotName;
817 
818  kinematicRobots.erase(robotName);
819 
820  return true;
821 }
822 
823 
824 bool KinematicsWorld::addRobotEngine(RobotPtr robot, double pid_p, double pid_i, double pid_d, const std::string& filename, bool staticRobot, bool selfCollisions)
825 {
826  ARMARX_VERBOSE_S << "Adding robot " << robot->getName() << ", file:" << filename;
827 
828  // lock engine and data
829  ScopedRecursiveLockPtr lockEngine = getScopedEngineLock(__FUNCTION__);
830 
831  //access engine
832  ARMARX_DEBUG_S << "add robot";
833 
834  if (hasRobot(robot->getName()))
835  {
836  ARMARX_ERROR_S << "More than robot with identical name is currently not supported!";
837  return false;
838  }
839 
840  KinematicRobotInfo robInfo;
841 
842  ARMARX_INFO_S << "Building static robot...";
843  /*std::vector< RobotNodePtr > nodes = robot->getRobotNodes();
844  for (auto n : nodes)
845  {
846  n->setSimulationType(SceneObject::Physics::eKinematic);
847  }*/
848 
849  RobotPtr r = robot->clone(robot->getName());
850 
851  // since we do not visualize this robot we can skip visualization updates
852  r->setThreadsafe(false); // we already got a mutex protection
853  r->setUpdateVisualization(false);
854  r->setPropagatingJointValuesEnabled(false);
855 
856  robInfo.robot = r;
857 
858  kinematicRobots[r->getName()] = robInfo;
859 
860  return true;
861 }
862 
863 armarx::FramedPosePtr KinematicsWorld::toFramedPose(const Eigen::Matrix4f& globalPose, const std::string& robotName, const std::string& frameName)
864 {
865  ScopedRecursiveLockPtr lockEngine = getScopedEngineLock(__FUNCTION__);
866 
867  RobotPtr kinRobot = getRobot(robotName);
868  if (!kinRobot)
869  {
870  ARMARX_WARNING_S << "No robot or wrong name:" << robotName;
871  return FramedPosePtr();
872  }
873 
874  RobotNodePtr rn = kinRobot->getRobotNode(frameName);
875 
876  if (!rn)
877  {
878  ARMARX_WARNING_S << "No robot node found (" << frameName << ")";
879  return FramedPosePtr();
880  }
881 
882  Eigen::Matrix4f localPose = rn->toLocalCoordinateSystem(globalPose);
883 
884  armarx::FramedPosePtr framedPose = new armarx::FramedPose(localPose, frameName, kinRobot->getName());
885  return framedPose;
886 }
887 
888 bool KinematicsWorld::synchronizeRobotNodePoses(const std::string& robotName, std::map<std::string, armarx::PoseBasePtr>& objMap)
889 {
890  // lock engine and data
891  ScopedRecursiveLockPtr lockEngine = getScopedEngineLock(__FUNCTION__);
892  ScopedRecursiveLockPtr lockSync = getScopedSyncLock(__FUNCTION__);
893 
894  RobotPtr kinRobot = getRobot(robotName);
895  if (!kinRobot)
896  {
897  ARMARX_WARNING_S << "No robot or wrong name:" << robotName;
898  return false;
899  }
900 
901  VirtualRobot::SceneObjectPtr currentObjEngine = kinRobot->getRootNode();
902 
903  if (!synchronizeSceneObjectPoses(currentObjEngine, objMap))
904  {
905  ARMARX_ERROR_S << "Failed to synchronize objects...";
906  return false;
907  }
908  return true;
909 }
910 
912 {
913 
914  ScopedRecursiveLockPtr lockEngine = getScopedEngineLock(__FUNCTION__);
915  for (const auto& data : kinematicRobots)
916  {
917  RobotPtr kinRobot = data.second.robot;
918  auto robotName = data.first;
919  if (!kinRobot)
920  {
921  ARMARX_WARNING_S << "No robot or wrong name:" << robotName;
922  continue;
923  }
924 
926  std::vector<RobotNodePtr> rn = kinRobot->getRobotNodes();
927  KinematicRobotInfo& ri = kinematicRobots[robotName];
929  IceUtil::Time timestamp = IceUtil::Time::secondsDouble(currentSimTimeSec);
930  for (auto& i : rn)
931  {
932  if ((i->isJoint()))
933  {
934  std::string n = i->getName();
935 
936  jointAngles[n] = i->getJointValue();
937  auto filterIt = jointAngleDerivationFilters.find(i);
938  if (filterIt == jointAngleDerivationFilters.end())
939  {
940  // DerivationFilterBasePtr filter(new ) ;
941  ARMARX_INFO << "Creating filter for " << n;
942  filterIt = jointAngleDerivationFilters.insert(std::make_pair(i, std::make_pair(timestamp, i->getJointValue()))).first;
943  // filterIt->second.windowFilterSize = 25;
944  }
945  else
946  {
947  jointVelocities[n] = (i->getJointValue() - filterIt->second.second) / (timestamp - filterIt->second.first).toSecondsDouble();
948  filterIt->second.second = i->getJointValue();
949  filterIt->second.first = timestamp;
950  }
951  // filterIt->second.update(timestamp.toMicroSeconds(), new Variant(jointAngles[n]));
952  // if (ri.targetVelocities.find(n) != ri.targetVelocities.end())
953  // {
954  // jointVelocities[n] = ri.targetVelocities[n];
955  // }
956  // else
957  {
958  // jointVelocities[n] = filterIt->second.getValue()->getFloat();
959 
960  }
961  }
962  }
963  // ARMARX_INFO << deactivateSpam(1) << jointVelocities;
964 
965  // calculate linear velocity of robot
966  Eigen::Vector3f linearVelocity;
967  auto filterIt = linearVelocityFilters.find(kinRobot);
968  Eigen::Vector3f pos = kinRobot->getGlobalPose().block<3, 1>(0, 3);
969  if (filterIt == linearVelocityFilters.end())
970  {
971  filterIt = linearVelocityFilters.insert(std::make_pair(kinRobot, std::make_pair(timestamp, pos))).first;
972  }
973  linearVelocity = (pos - filterIt->second.second) / (timestamp - filterIt->second.first).toSecondsDouble();
974  filterIt->second.second = pos;
975  filterIt->second.first = timestamp;
976  ri.velTransActual = linearVelocity;
977  //ARMARX_INFO << deactivateSpam(1) << linearVelocity;
978 
979 
980 
981  // calculate angular velocity of robot
982  Eigen::Vector3f angularVelocity;
983  angularVelocity.setZero();
984  auto filterVelIt = angularVelocityFilters.find(kinRobot);
985  if (filterVelIt == angularVelocityFilters.end()) // store previous orientation (TODO: add filtering, e.g. on rpy)
986  {
987  //Eigen::Vector3f rpy;
988  //MathTools::eigen4f2rpy(kinRobot->getGlobalPose(), rpy);
989  filterVelIt = angularVelocityFilters.insert(std::make_pair(kinRobot, std::make_pair(timestamp, kinRobot->getGlobalPose()))).first;
990  }
991 
992  double deltaTimestamp = (timestamp - filterVelIt->second.first).toSecondsDouble();
993 
994 
995  // old method
996  // Eigen::Matrix4f deltaMat = kinRobot->getGlobalPose() * filterVelIt->second.second.inverse();
997  // MathTools::eigen4f2rpy(deltaMat, angularVelocity);
998  // if (deltaTimestamp > 0)
999  // {
1000  // angularVelocity /= deltaTimestamp;
1001  // }
1002  // ri.velRotActual = angularVelocity;
1003 
1004  // method from http://math.stackexchange.com/questions/668866/how-do-you-find-angular-velocity-given-a-pair-of-3x3-rotation-matrices
1005  Eigen::Matrix3f Rot_prev, Rot_new, A, Omega_mat;
1006  float theta;
1007  Rot_prev = filterVelIt->second.second.block(0, 0, 3, 3);
1008  Rot_new = kinRobot->getGlobalPose().block(0, 0, 3, 3);
1009  A = Rot_new * Rot_prev.transpose();
1010  theta = acos((A.trace() - 1) / 2.);
1011 
1012  if (theta == 0.)
1013  {
1014  ri.velRotActual.setZero();
1015  return;
1016  }
1017 
1018  Omega_mat = theta * (A - A.transpose()) / (2 * deltaTimestamp * sin(theta));
1019  ri.velRotActual[0] = Omega_mat(2, 1);
1020  ri.velRotActual[1] = Omega_mat(0, 2);
1021  ri.velRotActual[2] = Omega_mat(1, 0);
1022 
1023  if (deltaTimestamp > 0.1)
1024  {
1025  angularVelocityFilters[kinRobot] = std::make_pair(timestamp, kinRobot->getGlobalPose());
1026  }
1027 
1028  //ARMARX_INFO << deactivateSpam(1) << VAROUT(angularVelocity);
1029  }
1030 }
1031 
1032 bool KinematicsWorld::getRobotStatus(const std::string& robotName, NameValueMap& jointAngles, NameValueMap& jointVelocities, NameValueMap& jointTorques, Eigen::Vector3f& linearVelocity, Eigen::Vector3f& angularVelocity)
1033 {
1034  ScopedRecursiveLockPtr lockEngine = getScopedEngineLock(__FUNCTION__);
1035  RobotPtr kinRobot = getRobot(robotName);
1036  if (!kinRobot)
1037  {
1038  ARMARX_WARNING_S << "No robot or wrong name:" << robotName;
1039  return false;
1040  }
1041 
1042  std::vector<RobotNodePtr> rn = kinRobot->getRobotNodes();
1043  KinematicRobotInfo& ri = kinematicRobots[robotName];
1044 
1045  // float simTimeFactor = 1.0;
1046  // if (simStepExecutionTimeMS > 0)
1047  // {
1048  // simTimeFactor = simTimeStepMS / simStepExecutionTimeMS;
1049  // }
1050 
1051  // IceUtil::Time timestamp = IceUtil::Time::secondsDouble(currentSimTimeSec);
1053  for (auto& i : rn)
1054  {
1055  if ((i->isJoint()))
1056  {
1057  std::string n = i->getName();
1058 
1059  jointAngles[n] = i->getJointValue();
1060  // auto filterIt = jointAngleDerivationFilters.find(rn[i]);
1061  // if (filterIt == jointAngleDerivationFilters.end())
1062  // {
1063  // filterIt = jointAngleDerivationFilters.insert(std::make_pair(rn[i], new filters::DerivationFilter())).first;
1064  // filterIt->second->windowFilterSize = 25;
1065  // }
1066  // filterIt->second->update(timestamp.toMicroSeconds(), new Variant(jointAngles[n]));
1067  // // if (ri.targetVelocities.find(n) != ri.targetVelocities.end())
1068  // // {
1069  // // jointVelocities[n] = ri.targetVelocities[n];
1070  // // }
1071  // // else
1072  // {
1073  // jointVelocities[n] = filterIt->second->getValue()->getFloat() * simTimeFactor;
1074  // }
1075  // ARMARX_INFO << deactivateSpam(1, n) << n << ": " << jointVelocities[n];
1076  jointTorques[n] = 0;
1077  }
1078  }
1079 
1080  linearVelocity = ri.velTransActual;
1081 
1082 
1083  // filterIt = angularVelocityFilters.find(kinRobot);
1084  // if (filterIt == angularVelocityFilters.end())
1085  // {
1086  // filterIt = angularVelocityFilters.insert(std::make_pair(kinRobot, new filters::DerivationFilter())).first;
1087  // filterIt->second->windowFilterSize = 25;
1088  // }
1089  // filterIt->second->update(timestamp.toMicroSeconds(), new Variant(jointAngles[n]));
1090  angularVelocity = ri.velRotTarget;
1091 
1092  return true;
1093 }
1094 
1096 {
1097  ScopedRecursiveLockPtr lockEngine = getScopedEngineLock(__FUNCTION__);
1098 
1099  // not implemented
1100 
1101  return true;
1102 }
1103 
1104 
1106 {
1107  // lock engine and data
1108  ScopedRecursiveLockPtr lockEngine = getScopedEngineLock(__FUNCTION__);
1109  ScopedRecursiveLockPtr lockSync = getScopedSyncLock(__FUNCTION__);
1110 
1111  for (auto oEngine : kinematicObjects)
1112  {
1113  bool objectFound = false;
1114 
1115  for (auto& s : simVisuData.objects)
1116  {
1117  if (s.name == oEngine->getName())
1118  {
1119  objectFound = true;
1120  synchronizeSceneObjectPoses(oEngine, s.objectPoses);
1121  s.updated = true;
1122  break;
1123  }
1124  }
1125 
1126  if (!objectFound)
1127  {
1128  ARMARX_WARNING_S << "Object with name " << oEngine->getName() << " not in synchronized list";
1129  }
1130  }
1131 
1132  return true;
1133 }
1134 
1135 bool KinematicsWorld::addObstacleEngine(VirtualRobot::SceneObjectPtr o, VirtualRobot::SceneObject::Physics::SimulationType simType)
1136 {
1137  ScopedRecursiveLockPtr lockEngine = getScopedEngineLock(__FUNCTION__);
1138 
1139  ARMARX_DEBUG_S << "Adding obstacle " << o->getName();
1140  VirtualRobot::SceneObjectPtr clonedObj = o->clone(o->getName());
1141 
1142  kinematicObjects.push_back(clonedObj);
1143 
1144  // since we do not visualize this object we can skip visualization updates
1145  clonedObj->setUpdateVisualization(false);
1146 
1147  return true;
1148 }
1149 
1150 std::vector<std::string> KinematicsWorld::getRobotNames()
1151 {
1152  std::vector<std::string> names;
1153  {
1154  ScopedRecursiveLockPtr lockEngine = getScopedEngineLock(__FUNCTION__);
1155  std::map<std::string, KinematicRobotInfo>::iterator it = kinematicRobots.begin();
1156  while (it != kinematicRobots.end())
1157  {
1158  names.push_back(it->first);
1159  it++;
1160  }
1161  }
1162  return names;
1163 }
1164 
1165 void KinematicsWorld::setObjectSimType(const std::string& objectName, SceneObject::Physics::SimulationType simType)
1166 {
1167  ScopedRecursiveLockPtr lockEngine = getScopedEngineLock(__FUNCTION__);
1168  SceneObjectPtr o = getObject(objectName);
1169  if (!o)
1170  {
1171  ARMARX_WARNING_S << "Could not find object with name " << objectName;
1172  return;
1173  }
1174  //o->setSimType(simType);
1175 }
1176 
1177 void KinematicsWorld::setRobotNodeSimType(const std::string& robotName, const std::string& robotNodeName, SceneObject::Physics::SimulationType simType)
1178 {
1179  ScopedRecursiveLockPtr lockEngine = getScopedEngineLock(__FUNCTION__);
1180  RobotPtr r = getRobot(robotName);
1181  if (!r)
1182  {
1183  ARMARX_WARNING_S << "Could not find robot with name " << robotName;
1184  return;
1185  }
1186  RobotNodePtr rn = r->getRobotNode(robotNodeName);
1187  if (!rn)
1188  {
1189  ARMARX_WARNING_S << "Could not find robot node with name " << robotNodeName;
1190  return;
1191  }
1192  //rn->setSimType(simType);
1193 }
1194 
1195 std::vector<std::string> KinematicsWorld::getObstacleNames()
1196 {
1197  std::vector<std::string> names;
1198  {
1199  ScopedRecursiveLockPtr lockEngine = getScopedEngineLock(__FUNCTION__);
1200 
1201  for (auto& o : kinematicObjects)
1202  {
1203  names.push_back(o->getName());
1204  }
1205  }
1206  return names;
1207 }
1208 
1209 
1210 bool KinematicsWorld::removeObstacleEngine(const std::string& name)
1211 {
1212  ARMARX_VERBOSE_S << "Removing obstacle " << name;
1213  ScopedRecursiveLockPtr lockEngine = getScopedEngineLock(__FUNCTION__);
1214  {
1215  SceneObjectPtr o = getObject(name);
1216 
1217  if (!o)
1218  {
1219  return false;
1220  }
1221 
1222  std::vector<SceneObjectPtr>::iterator it = find(kinematicObjects.begin(), kinematicObjects.end(), o);
1223 
1224  if (it != kinematicObjects.end())
1225  {
1226  kinematicObjects.erase(it);
1227  }
1228  else
1229  {
1230  ARMARX_WARNING_S << "Sync error";
1231  }
1232  }
1233 
1234  return true;
1235 }
1236 
1237 
1238 
1240 {
1241  ScopedRecursiveLockPtr lockEngine = getScopedEngineLock(__FUNCTION__);
1242  ARMARX_DEBUG << "start sim physics";
1243 
1244 
1245  // IceUtil::Time startTime = IceUtil::Time::now();
1246  float dt1 = getDeltaTimeMilli();
1247 
1248  // the engine has to be stepped with seconds
1249  // max 100 internal loops
1250  ARMARX_DEBUG << deactivateSpam(1) << "dt1: " << dt1 << " ms";
1251  simTimeStepMS = dt1;
1252  // step static objects and robots
1253  stepStaticObjects(dt1 / 1000.0);
1254  stepStaticRobots(dt1 / 1000.0);
1256 
1257 
1258  currentSimTimeSec += dt1 / 1000.0;
1259  // IceUtil::Time duration = IceUtil::Time::now() - startTime;
1261  ARMARX_DEBUG << "end sim physics, simTime ms:" << simStepExecutionDurationMS;
1262 }
1263 
1264 
1266 {
1267  auto startTime = IceUtil::Time::now(); // this should always be real time and not virtual time
1268  {
1269  ScopedRecursiveLockPtr lockEngine = getScopedEngineLock(__FUNCTION__);
1270 
1271  float stepSize = (float)(stepSizeMs) / 1000.0f;
1272  ARMARX_DEBUG_S << "start sim physics: " << VAROUT(stepSize) << VAROUT(stepSizeMs);
1273 
1275 
1276  // step static robots
1277  stepStaticObjects(stepSize);
1278  stepStaticRobots(stepSize);
1280 
1281  currentSimTimeSec += stepSize;
1282  }
1283 
1284 
1285  if (maxRealTimeSimSpeed > 0)
1286  {
1287  auto duration = (IceUtil::Time::now() - startTime).toMilliSecondsDouble();
1288  const double minStepSizeMs = static_cast<double>(stepSizeMs) / maxRealTimeSimSpeed;
1289  if (duration < minStepSizeMs)
1290  {
1291  ARMARX_DEBUG << "Sim calculation took " << duration << " - Sleeping now for " << (stepSizeMs - duration);
1292  usleep(1000 * (minStepSizeMs - duration));
1293  }
1294  }
1295 
1296  IceUtil::Time duration = IceUtil::Time::now() - startTime;
1297  simStepExecutionDurationMS = (float)duration.toMilliSecondsDouble();
1298  ARMARX_DEBUG << "end sim physics, simTime ms:" << simStepExecutionDurationMS;
1299 }
1300 
1301 void KinematicsWorld::stepStaticRobots(double deltaInSeconds)
1302 {
1303  // step through all static robots and apply velocities
1304  for (auto dr : kinematicRobots)
1305  {
1306  KinematicRobotInfo ri = dr.second;
1307  std::map<std::string, float> targetPos;
1308  VirtualRobot::RobotPtr kinRob = ri.robot;
1309  ARMARX_DEBUG << "Applying velocities for static robot " << kinRob->getName();
1310  for (auto nv : ri.targetVelocities)
1311  {
1312  if (!kinRob->hasRobotNode(nv.first))
1313  {
1314  ARMARX_ERROR << deactivateSpam(4, nv.first) << "No rn with name " << nv.first;
1315  continue;
1316  }
1317  double change = (nv.second * deltaInSeconds);
1318 
1319  //double randomNoiseValue = distribution(generator);
1320  //change += randomNoiseValue;
1321  double newAngle = kinRob->getRobotNode(nv.first)->getJointValue() + change;
1322  targetPos[nv.first] = (float)newAngle;
1323  }
1324  if (targetPos.size() > 0)
1325  {
1326  ARMARX_DEBUG << "Target joint angles:" << targetPos;
1327  kinRob->setJointValues(targetPos);
1328  }
1329  if (ri.velTransTarget.norm() > 0 || ri.velRotTarget.norm() > 0)
1330  {
1331  Eigen::Matrix4f gp = kinRob->getGlobalPose();
1332  gp.block(0, 3, 3, 1) += ri.velTransTarget * deltaInSeconds;
1333  Eigen::Matrix3f m3;
1334  m3 = Eigen::AngleAxisf(ri.velRotTarget(0) * deltaInSeconds, Eigen::Vector3f::UnitX())
1335  * Eigen::AngleAxisf(ri.velRotTarget(1) * deltaInSeconds, Eigen::Vector3f::UnitY())
1336  * Eigen::AngleAxisf(ri.velRotTarget(2) * deltaInSeconds, Eigen::Vector3f::UnitZ());
1337  gp.block(0, 0, 3, 3) *= m3;
1338  setRobotPose(kinRob->getName(), gp);
1339  }
1340  }
1341 }
1342 
1343 
1344 void KinematicsWorld::stepStaticObjects(double deltaInSeconds)
1345 {
1346  // Step attached objects
1347  for (auto& o : attachedObjects)
1348  {
1349  if (kinematicRobots.find(o.robotName) == kinematicRobots.end())
1350  {
1351  // Robot not found
1352  continue;
1353  }
1354 
1355  VirtualRobot::RobotPtr kinRob = kinematicRobots[o.robotName].robot;
1356 
1357  if (!kinRob->hasRobotNode(o.objectName))
1358  {
1359  // Object is not attached
1360  continue;
1361  }
1362 
1363  Eigen::Matrix4f pose = kinRob->getRobotNode(o.objectName)->getGlobalPose();
1364 
1365  for (auto& kino : kinematicObjects)
1366  {
1367  if (kino->getName() == o.objectName)
1368  {
1369  kino->setGlobalPose(pose);
1370  break;
1371  }
1372  }
1373  }
1374 }
1375 
1377 {
1378  return stepSizeMs;
1379 }
1380 
1381 std::vector<SimDynamics::DynamicsEngine::DynamicsContactInfo> KinematicsWorld::copyContacts()
1382 {
1383  ScopedRecursiveLockPtr lockSync = getScopedSyncLock(__FUNCTION__);
1384  return std::vector<SimDynamics::DynamicsEngine::DynamicsContactInfo>();
1385 }
1386 
1387 std::vector<SceneObjectPtr> KinematicsWorld::getObjects()
1388 {
1389  return kinematicObjects;
1390 }
1391 
1392 void KinematicsWorld::setupFloorEngine(bool enable, const std::string& floorTexture)
1393 {
1394 
1395  ScopedRecursiveLockPtr lockEngine = getScopedEngineLock(__FUNCTION__);
1396 
1397  std::string textureFile = floorTexture;
1398 
1399  if (enable)
1400  {
1401  ARMARX_INFO_S << "Creating floor plane...";
1402  Eigen::Vector3f pos;
1403  pos.setZero();
1404  Eigen::Vector3f up = Eigen::Vector3f::UnitZ();
1405  createFloorPlane(pos, up);
1406  }
1407 }
1408 
1409 void KinematicsWorld::enableLogging(const std::string& robotName, const std::string& logFile)
1410 {
1411  ScopedRecursiveLockPtr lockEngine = getScopedEngineLock(__FUNCTION__);
1412 
1413 }
1414 
1415 
1416 
1417 bool KinematicsWorld::synchronizeSceneObjectPoses(SceneObjectPtr currentObjEngine, std::map<std::string, armarx::PoseBasePtr>& objMap)
1418 {
1419  if (!currentObjEngine)
1420  {
1421  return false;
1422  }
1423 
1424  PosePtr p(new Pose(currentObjEngine->getGlobalPose()));
1425  objMap[currentObjEngine->getName()] = p;
1426  std::vector<SceneObjectPtr> childrenE = currentObjEngine->getChildren();
1427 
1428  for (const auto& i : childrenE)
1429  {
1430  if (!synchronizeSceneObjectPoses(i, objMap))
1431  {
1432  return false;
1433  }
1434  }
1435 
1436  return true;
1437 }
1438 
1439 
1441 {
1442  // lock engine and data
1443  ScopedRecursiveLockPtr lockEngine = getScopedEngineLock(__FUNCTION__);
1444 
1445  // CONTACTS
1446  /*if (collectContacts)
1447  {
1448  contacts = dynamicsWorld->getEngine()->getContacts();
1449  std::stringstream ss;
1450  for (auto c : contacts)
1451  {
1452  ss << c.objectAName << " < - > " << c.objectBName;
1453  }
1454  ARMARX_DEBUG << "Contacts:" << endl << ss.str();
1455  }*/
1456  return true;
1457 }
1458 
1460 {
1461  ScopedRecursiveLockPtr lockEngine = getScopedEngineLock(__FUNCTION__);
1462 
1463  auto newEndTime = IceUtil::Time::now();
1464  auto frameTime = newEndTime - lastTime;
1465  lastTime = newEndTime;
1466 
1467  return (float)(frameTime).toMilliSecondsDouble();;
1468 }
1469 
1470 /*
1471 int KinematicsWorld::getContactCont()
1472 {
1473  ScopedRecursiveLockPtr l = getScopedSyncLock(__FUNCTION__);
1474  return contacts.size();
1475 }*/
1476 
1477 DistanceInfo KinematicsWorld::getRobotNodeDistance(const std::string& robotName, const std::string& robotNodeName1, const std::string& robotNodeName2)
1478 {
1479  ScopedRecursiveLockPtr lockEngine = getScopedEngineLock(__FUNCTION__);
1480 
1481  VirtualRobot::RobotPtr robot = getRobot(robotName);
1482  if (!robot)
1483  {
1484  throw LocalException("Wrong robot name. '") << robotName << "'";
1485  }
1486 
1487  if (!robot->hasRobotNode(robotNodeName1))
1488  {
1489  throw LocalException("Wrong robot node name. '") << robotNodeName1 << "'";
1490  }
1491  if (!robot->hasRobotNode(robotNodeName2))
1492  {
1493  throw LocalException("Wrong robot node name. '") << robotNodeName2 << "'";
1494  }
1495 
1496  // Compute distance from node to the rest of the robot (does that make sense?!)
1497  Eigen::Vector3f p1, p2;
1498  auto model1 = robot->getRobotNode(robotNodeName1)->getCollisionModel();
1499  auto model2 = robot->getRobotNode(robotNodeName2)->getCollisionModel();
1500  float d = robot->getCollisionChecker()->calculateDistance(model1, model2, p1, p2);
1501  DistanceInfo di;
1502  di.distance = d;
1503  di.p1 = new Vector3(p1);
1504  di.p2 = new Vector3(p2);
1505 
1506  return di;
1507 }
1508 
1509 DistanceInfo KinematicsWorld::getDistance(const std::string& robotName, const std::string& robotNodeName, const std::string& worldObjectName)
1510 {
1511  ScopedRecursiveLockPtr lockEngine = getScopedEngineLock(__FUNCTION__);
1512 
1513  VirtualRobot::RobotPtr robot = getRobot(robotName);
1514  if (!robot)
1515  {
1516  throw LocalException("Wrong robot name. '") << robotName << "'";
1517  }
1518 
1519  if (!robot->hasRobotNode(robotNodeName))
1520  {
1521  throw LocalException("Wrong robot node name. '") << robotNodeName << "'";
1522  }
1523  VirtualRobot::SceneObjectPtr so = getObject(worldObjectName);
1524  if (!so)
1525  {
1526  throw LocalException("No object with name '") << worldObjectName << "'";
1527  }
1528  Eigen::Vector3f p1, p2;
1529 
1530  float d = robot->getCollisionChecker()->calculateDistance(robot->getRobotNode(robotNodeName)->getCollisionModel(), so->getCollisionModel(), p1, p2);
1531  DistanceInfo di;
1532  di.distance = d;
1533  di.p1 = new Vector3(p1);
1534  di.p2 = new Vector3(p2);
1535 
1536  return di;
1537 }
1538 
1539 
1540 
armarx::KinematicsWorld::getRobotJointTorques
std::map< std::string, float > getRobotJointTorques(const std::string &) override
Definition: KinematicsWorld.cpp:359
armarx::SimulatedWorld::simStepExecutionDurationMS
float simStepExecutionDurationMS
Definition: SimulatedWorld.h:457
armarx::SimulatedWorldData::robots
EIGEN_MAKE_ALIGNED_OPERATOR_NEW std::vector< RobotInfo > robots
Definition: SimulatedWorld.h:110
armarx::KinematicsWorld::~KinematicsWorld
~KinematicsWorld() override
armarx::KinematicsWorld::getRobotJointLimitLo
float getRobotJointLimitLo(const std::string &robotName, const std::string &nodeName) override
Definition: KinematicsWorld.cpp:369
armarx::KinematicsWorld::initialize
virtual void initialize(int stepSizeMS, float maxRealTimeSimSpeed=1, bool floorPlane=false, std::string floorTexture=std::string())
Definition: KinematicsWorld.cpp:59
armarx::KinematicsWorld::getRobots
std::map< std::string, VirtualRobot::RobotPtr > getRobots() override
Definition: KinematicsWorld.cpp:675
armarx::KinematicsWorld::createFloorPlane
virtual void createFloorPlane(const Eigen::Vector3f &pos, const Eigen::Vector3f &up)
Definition: KinematicsWorld.cpp:77
armarx::KinematicsWorld::setRobotAngularVelocity
void setRobotAngularVelocity(const std::string &robotName, const std::string &robotNodeName, const Eigen::Vector3f &vel) override
Definition: KinematicsWorld.cpp:562
armarx::SimulatedWorld::simVisuData
SceneVisuData simVisuData
Definition: SimulatedWorld.h:451
armarx::KinematicsWorld::jointAngleDerivationFilters
std::map< VirtualRobot::RobotNodePtr, std::pair< IceUtil::Time, float > > jointAngleDerivationFilters
Definition: KinematicsWorld.h:201
armarx::KinematicsWorld::getObstacleNames
std::vector< std::string > getObstacleNames() override
Definition: KinematicsWorld.cpp:1195
armarx::KinematicsWorld::getDeltaTimeMilli
float getDeltaTimeMilli()
Definition: KinematicsWorld.cpp:1459
armarx::KinematicsWorld::getObject
virtual VirtualRobot::SceneObjectPtr getObject(const std::string &objectName)
Definition: KinematicsWorld.cpp:687
armarx::KinematicsWorld::hasRobot
bool hasRobot(const std::string &robotName) override
Definition: KinematicsWorld.cpp:630
armarx::SimulatedWorld::getScopedSyncLock
virtual ScopedRecursiveLockPtr getScopedSyncLock(const std::string &callStr)
Definition: SimulatedWorld.cpp:747
armarx::KinematicsWorld::getFloor
VirtualRobot::SceneObjectPtr getFloor() override
Definition: KinematicsWorld.cpp:797
armarx::KinematicsWorld::applyForceObject
void applyForceObject(const std::string &objectName, const Eigen::Vector3f &force) override
Definition: KinematicsWorld.cpp:216
armarx::KinematicsWorld::setObjectPose
void setObjectPose(const std::string &objectName, const Eigen::Matrix4f &globalPose) override
Definition: KinematicsWorld.cpp:234
LocalException.h
GfxTL::Orientation
ScalarT Orientation(const VectorXD< 2, ScalarT > &p1, const VectorXD< 2, ScalarT > &p2, const VectorXD< 2, ScalarT > &c)
Definition: Orientation.h:9
armarx::navigation::core::Pose
Eigen::Isometry3f Pose
Definition: basic_types.h:31
armarx::KinematicsWorld::kinematicObjects
std::vector< VirtualRobot::SceneObjectPtr > kinematicObjects
Definition: KinematicsWorld.h:200
armarx::KinematicsWorld::toFramedPose
FramedPosePtr toFramedPose(const Eigen::Matrix4f &globalPose, const std::string &robotName, const std::string &frameName) override
toFramedPose Constructs a framed pose
Definition: KinematicsWorld.cpp:863
armarx::VariantType::FramedPose
const VariantTypeId FramedPose
Definition: FramedPose.h:37
VirtualRobot
Definition: FramedPose.h:43
armarx::KinematicsWorld::floorPos
Eigen::Vector3f floorPos
Definition: KinematicsWorld.h:205
armarx::KinematicsWorld::setObjectSimType
void setObjectSimType(const std::string &objectName, VirtualRobot::SceneObject::Physics::SimulationType simType) override
Definition: KinematicsWorld.cpp:1165
armarx::KinematicsWorld::enableLogging
void enableLogging(const std::string &robotName, const std::string &logFile) override
Definition: KinematicsWorld.cpp:1409
armarx::KinematicsWorld::getRobotNames
std::vector< std::string > getRobotNames() override
Definition: KinematicsWorld.cpp:1150
armarx::KinematicsWorld::setRobotLinearVelocityRobotRootFrame
void setRobotLinearVelocityRobotRootFrame(const std::string &robotName, const std::string &robotNodeName, const Eigen::Vector3f &vel) override
Definition: KinematicsWorld.cpp:581
armarx::KinematicsWorld::getRobotJointVelocities
std::map< std::string, float > getRobotJointVelocities(const std::string &robotName) override
Definition: KinematicsWorld.cpp:312
armarx::KinematicsWorld::getRobotJointVelocity
float getRobotJointVelocity(const std::string &robotName, const std::string &nodeName) override
Definition: KinematicsWorld.cpp:331
armarx::SimulatedWorld::maxRealTimeSimSpeed
float maxRealTimeSimSpeed
Definition: SimulatedWorld.h:453
armarx::KinematicsWorld::stepStaticRobots
void stepStaticRobots(double deltaInSeconds)
Definition: KinematicsWorld.cpp:1301
armarx::FramedPosePtr
IceInternal::Handle< FramedPose > FramedPosePtr
Definition: FramedPose.h:250
armarx::ForceTorqueInfo
Definition: SimulatedWorld.h:48
armarx::KinematicsWorld::objectReleasedEngine
bool objectReleasedEngine(const std::string &robotName, const std::string &robotNodeName, const std::string &objectName) override
remove a joint
Definition: KinematicsWorld.cpp:719
armarx::KinematicsWorld::applyTorqueRobotNode
void applyTorqueRobotNode(const std::string &robotName, const std::string &robotNodeName, const Eigen::Vector3f &torque) override
Definition: KinematicsWorld.cpp:210
armarx::KinematicsWorld::hasObject
bool hasObject(const std::string &instanceName) override
Definition: KinematicsWorld.cpp:229
armarx::SimulatedWorld
The SimulatedWorld class encapsulates the whole physics simulation and the corresponding data.
Definition: SimulatedWorld.h:128
armarx::SimulatedWorld::simTimeStepMS
float simTimeStepMS
Definition: SimulatedWorld.h:454
armarx::KinematicsWorld::lastTime
IceUtil::Time lastTime
Definition: KinematicsWorld.h:212
armarx::KinematicsWorld::stepPhysicsFixedTimeStep
void stepPhysicsFixedTimeStep() override
Perform one simulation step.
Definition: KinematicsWorld.cpp:1265
armarx::SimulatedWorld::attachedObjects
std::vector< GraspingInfo > attachedObjects
Definition: SimulatedWorld.h:449
so
linux gnu libIceDB so
Definition: CMakeLists.txt:7
armarx::KinematicsWorld::KinematicRobotInfo::actualVelocities
std::map< std::string, float > actualVelocities
Definition: KinematicsWorld.h:194
armarx::KinematicsWorld::KinematicRobotInfo::velRotActual
Eigen::Vector3f velRotActual
Definition: KinematicsWorld.h:196
armarx::SimulatedWorld::synchronizeDurationMS
float synchronizeDurationMS
Definition: SimulatedWorld.h:459
armarx::KinematicsWorld::floorExtendMM
double floorExtendMM
Definition: KinematicsWorld.h:207
armarx::KinematicsWorld::getRobotMaxTorque
float getRobotMaxTorque(const std::string &robotName, const std::string &nodeName) override
Definition: KinematicsWorld.cpp:424
armarx::KinematicsWorld::angularVelocityFilters
std::map< VirtualRobot::RobotPtr, std::pair< IceUtil::Time, Eigen::Matrix4f > > angularVelocityFilters
Definition: KinematicsWorld.h:203
armarx::KinematicsWorld::actuateRobotJointsVel
void actuateRobotJointsVel(const std::string &robotName, const std::map< std::string, float > &velocities) override
Definition: KinematicsWorld.cpp:161
armarx::KinematicsWorld::applyForceRobotNode
void applyForceRobotNode(const std::string &robotName, const std::string &robotNodeName, const Eigen::Vector3f &force) override
Definition: KinematicsWorld.cpp:204
armarx::KinematicsWorld::actuateRobotJoints
void actuateRobotJoints(const std::string &robotName, const std::map< std::string, float > &angles, const std::map< std::string, float > &velocities) override
ignoring velocity target
Definition: KinematicsWorld.cpp:115
armarx::KinematicsWorld::copyContacts
std::vector< SimDynamics::DynamicsEngine::DynamicsContactInfo > copyContacts() override
Definition: KinematicsWorld.cpp:1381
armarx::SimulatedWorld::simReportData
SimulatedWorldData simReportData
Definition: SimulatedWorld.h:452
armarx::KinematicsWorld::getDistance
armarx::DistanceInfo getDistance(const std::string &robotName, const std::string &robotNodeName, const std::string &worldObjectName) override
Definition: KinematicsWorld.cpp:1509
armarx::SimulatedWorld::getScopedEngineLock
virtual ScopedRecursiveLockPtr getScopedEngineLock(const std::string &callStr)
Definition: SimulatedWorld.cpp:714
armarx::KinematicsWorld::floorDepthMM
double floorDepthMM
Definition: KinematicsWorld.h:208
armarx::KinematicsWorld::objectGraspedEngine
bool objectGraspedEngine(const std::string &robotName, const std::string &robotNodeName, const std::string &objectName, Eigen::Matrix4f &storeLocalTransform) override
create a joint
Definition: KinematicsWorld.cpp:754
armarx::KinematicsWorld::removeObstacleEngine
bool removeObstacleEngine(const std::string &name) override
Definition: KinematicsWorld.cpp:1210
IceInternal::Handle< FramedPose >
armarx::KinematicsWorld::stepSizeMs
int stepSizeMs
Definition: KinematicsWorld.h:180
armarx::KinematicsWorld::updateForceTorqueSensor
bool updateForceTorqueSensor(ForceTorqueInfo &ftInfo) override
Definition: KinematicsWorld.cpp:1095
armarx::KinematicsWorld::synchronizeSimulationDataEngine
bool synchronizeSimulationDataEngine() override
Definition: KinematicsWorld.cpp:1440
GfxTL::Identity
void Identity(MatrixXX< N, N, T > *a)
Definition: MatrixXX.h:523
armarx::KinematicsWorld::KinematicRobotInfo::velTransActual
Eigen::Vector3f velTransActual
Definition: KinematicsWorld.h:195
ARMARX_DEBUG_S
#define ARMARX_DEBUG_S
Definition: Logging.h:198
armarx::KinematicsWorld::getRobotNodePose
Eigen::Matrix4f getRobotNodePose(const std::string &robotName, const std::string &robotNodeName) override
Definition: KinematicsWorld.cpp:466
armarx::KinematicsWorld::getObjectPose
Eigen::Matrix4f getObjectPose(const std::string &objectName) override
Definition: KinematicsWorld.cpp:704
armarx::SimulatedWorld::ScopedRecursiveLockPtr
std::shared_ptr< ScopedRecursiveLock > ScopedRecursiveLockPtr
Definition: SimulatedWorld.h:319
ARMARX_ERROR_S
#define ARMARX_ERROR_S
Definition: Logging.h:209
data
uint8_t data[1]
Definition: EtherCATFrame.h:68
ARMARX_DEBUG
#define ARMARX_DEBUG
Definition: Logging.h:177
armarx::KinematicsWorld::getRobotJointAngles
std::map< std::string, float > getRobotJointAngles(const std::string &robotName) override
Definition: KinematicsWorld.cpp:263
armarx::KinematicsWorld::getRobotNodeDistance
armarx::DistanceInfo getRobotNodeDistance(const std::string &robotName, const std::string &robotNodeName1, const std::string &robotNodeName2) override
Definition: KinematicsWorld.cpp:1477
armarx::KinematicsWorld::hasRobotNode
bool hasRobotNode(const std::string &robotName, const std::string &robotNodeName) override
Definition: KinematicsWorld.cpp:647
armarx::KinematicsWorld::addRobotEngine
bool addRobotEngine(VirtualRobot::RobotPtr robot, double pid_p, double pid_i, double pid_d, const std::string &filename, bool staticRobot, bool selfCollisions) override
Definition: KinematicsWorld.cpp:824
armarx::KinematicsWorld::KinematicRobotInfo::velTransTarget
Eigen::Vector3f velTransTarget
Definition: KinematicsWorld.h:195
armarx::KinematicsWorld::calculateActualVelocities
void calculateActualVelocities()
Definition: KinematicsWorld.cpp:911
armarx::KinematicsWorld::kinematicRobots
std::map< std::string, KinematicRobotInfo > kinematicRobots
Definition: KinematicsWorld.h:199
filename
std::string filename
Definition: VisualizationRobot.cpp:83
armarx::channels::KinematicUnitObserver::jointVelocities
const KinematicUnitDatafieldCreator jointVelocities("jointVelocities")
armarx::KinematicsWorld::getObjects
std::vector< VirtualRobot::SceneObjectPtr > getObjects() override
Definition: KinematicsWorld.cpp:1387
ARMARX_ERROR
#define ARMARX_ERROR
Definition: Logging.h:189
armarx::KinematicsWorld::synchronizeRobotNodePoses
bool synchronizeRobotNodePoses(const std::string &robotName, std::map< std::string, armarx::PoseBasePtr > &objMap) override
Definition: KinematicsWorld.cpp:888
armarx::KinematicsWorld::getRobotForceTorqueSensors
ForceTorqueDataSeq getRobotForceTorqueSensors(const std::string &) override
Definition: KinematicsWorld.cpp:364
armarx::KinematicsWorld::KinematicRobotInfo
Definition: KinematicsWorld.h:182
armarx::KinematicsWorld::groundObject
VirtualRobot::ObstaclePtr groundObject
Definition: KinematicsWorld.h:209
ARMARX_WARNING_S
#define ARMARX_WARNING_S
Definition: Logging.h:206
armarx::armem::Time
armarx::core::time::DateTime Time
Definition: forward_declarations.h:13
KinematicsWorld.h
armarx::KinematicsWorld::KinematicRobotInfo::velRotTarget
Eigen::Vector3f velRotTarget
Definition: KinematicsWorld.h:196
armarx::KinematicsWorld::stepStaticObjects
void stepStaticObjects(double deltaInSeconds)
Definition: KinematicsWorld.cpp:1344
A
class A(deque< T, A >)) ARMARX_OVERLOAD_STD_HASH_FOR_ITERABLE((class T
Enables hashing of std::list.
armarx::control::njoint_controller::platform::platform_follower_controller::NameValueMap
std::map< std::string, float > NameValueMap
Definition: PlatformFollowerController.h:91
armarx::channels::KinematicUnitObserver::jointAngles
const KinematicUnitDatafieldCreator jointAngles("jointAngles")
armarx::KinematicsWorld::getRobotAngularVelocity
Eigen::Vector3f getRobotAngularVelocity(const std::string &robotName, const std::string &nodeName) override
Definition: KinematicsWorld.cpp:505
armarx::KinematicsWorld::setupFloorEngine
void setupFloorEngine(bool enable, const std::string &floorTexture) override
Definition: KinematicsWorld.cpp:1392
GfxTL::Matrix3f
MatrixXX< 3, 3, float > Matrix3f
Definition: MatrixXX.h:600
GfxTL::Matrix4f
MatrixXX< 4, 4, float > Matrix4f
Definition: MatrixXX.h:601
armarx::KinematicsWorld::actuateRobotJointsTorque
void actuateRobotJointsTorque(const std::string &robotName, const std::map< std::string, float > &torques) override
Definition: KinematicsWorld.cpp:181
armarx::KinematicsWorld::getRobot
VirtualRobot::RobotPtr getRobot(const std::string &robotName) override
Definition: KinematicsWorld.cpp:662
armarx::viz::data::ElementFlags::names
const simox::meta::IntEnumNames names
Definition: json_elements.cpp:14
float
#define float
Definition: 16_Level.h:22
ARMARX_INFO
#define ARMARX_INFO
Definition: Logging.h:174
VAROUT
#define VAROUT(x)
Definition: StringHelpers.h:182
armarx::KinematicsWorld::getRobotPose
Eigen::Matrix4f getRobotPose(const std::string &robotName) override
Definition: KinematicsWorld.cpp:409
armarx::KinematicsWorld::getRobotJointAngle
float getRobotJointAngle(const std::string &robotName, const std::string &nodeName) override
Definition: KinematicsWorld.cpp:290
armarx::SimulatedWorld::currentSimTimeSec
double currentSimTimeSec
Definition: SimulatedWorld.h:433
armarx::KinematicsWorld::setRobotMaxTorque
void setRobotMaxTorque(const std::string &robotName, const std::string &nodeName, float maxTorque) override
Definition: KinematicsWorld.cpp:445
memoryx::KBM::Vector3
Eigen::Vector3d Vector3
Definition: kbm.h:41
armarx::KinematicsWorld::setRobotLinearVelocity
void setRobotLinearVelocity(const std::string &robotName, const std::string &robotNodeName, const Eigen::Vector3f &vel) override
Definition: KinematicsWorld.cpp:545
scene3D::SceneObjectPtr
boost::intrusive_ptr< SceneObject > SceneObjectPtr
Definition: PointerDefinitions.h:40
armarx::KinematicsWorld::getFixedTimeStepMS
int getFixedTimeStepMS() override
Definition: KinematicsWorld.cpp:1376
armarx::KinematicsWorld::setRobotAngularVelocityRobotRootFrame
void setRobotAngularVelocityRobotRootFrame(const std::string &robotName, const std::string &robotNodeName, const Eigen::Vector3f &vel) override
Definition: KinematicsWorld.cpp:606
armarx::KinematicsWorld::stepPhysicsRealTime
void stepPhysicsRealTime() override
Perform one simulation step.
Definition: KinematicsWorld.cpp:1239
ARMARX_VERBOSE_S
#define ARMARX_VERBOSE_S
Definition: Logging.h:200
armarx::Logging::deactivateSpam
SpamFilterDataPtr deactivateSpam(float deactivationDurationSec=10.0f, const std::string &identifier="", bool deactivate=true) const
disables the logging for the current line for the given amount of seconds.
Definition: Logging.cpp:92
armarx::KinematicsWorld::setRobotNodeSimType
void setRobotNodeSimType(const std::string &robotName, const std::string &robotNodeName, VirtualRobot::SceneObject::Physics::SimulationType simType) override
Definition: KinematicsWorld.cpp:1177
armarx::SimulatedWorld::setupFloor
virtual void setupFloor(bool enable, const std::string &floorTexture)
Definition: SimulatedWorld.cpp:780
armarx::KinematicsWorld::getRobotJointLimitHi
float getRobotJointLimitHi(const std::string &robotName, const std::string &nodeName) override
Definition: KinematicsWorld.cpp:389
armarx::KinematicsWorld::linearVelocityFilters
std::map< VirtualRobot::RobotPtr, std::pair< IceUtil::Time, Eigen::Vector3f > > linearVelocityFilters
Definition: KinematicsWorld.h:202
ARMARX_INFO_S
#define ARMARX_INFO_S
Definition: Logging.h:195
armarx::KinematicsWorld::applyTorqueObject
void applyTorqueObject(const std::string &objectName, const Eigen::Vector3f &torque) override
Definition: KinematicsWorld.cpp:222
Logging.h
ARMARX_WARNING
#define ARMARX_WARNING
Definition: Logging.h:186
armarx::KinematicsWorld::KinematicRobotInfo::robot
VirtualRobot::RobotPtr robot
Definition: KinematicsWorld.h:192
armarx::KinematicsWorld::floorUp
Eigen::Vector3f floorUp
Definition: KinematicsWorld.h:206
armarx::channels::KinematicUnitObserver::jointTorques
const KinematicUnitDatafieldCreator jointTorques("jointTorques")
armarx::KinematicsWorld::getRobotStatus
bool getRobotStatus(const std::string &robotName, NameValueMap &jointAngles, NameValueMap &jointVelocities, NameValueMap &jointTorques, Eigen::Vector3f &linearVelocity, Eigen::Vector3f &angularVelocity) override
Definition: KinematicsWorld.cpp:1032
ArmarXDataPath.h
armarx::KinematicsWorld::synchronizeSceneObjectPoses
bool synchronizeSceneObjectPoses(VirtualRobot::SceneObjectPtr currentObjEngine, std::map< std::string, armarx::PoseBasePtr > &objMap) override
Definition: KinematicsWorld.cpp:1417
armarx::ctrlutil::s
double s(double t, double s0, double v0, double a0, double j)
Definition: CtrlUtil.h:33
armarx::KinematicsWorld::getRobotLinearVelocity
Eigen::Vector3f getRobotLinearVelocity(const std::string &robotName, const std::string &nodeName) override
Definition: KinematicsWorld.cpp:488
armarx::KinematicsWorld::getRobotMass
float getRobotMass(const std::string &robotName) override
Definition: KinematicsWorld.cpp:249
armarx
This file offers overloads of toIce() and fromIce() functions for STL container types.
Definition: ArmarXTimeserver.cpp:28
armarx::KinematicsWorld::setRobotPose
void setRobotPose(const std::string &robotName, const Eigen::Matrix4f &globalPose) override
Definition: KinematicsWorld.cpp:189
armarx::KinematicsWorld::synchronizeObjects
bool synchronizeObjects() override
Definition: KinematicsWorld.cpp:1105
VirtualRobot::RobotPtr
std::shared_ptr< class Robot > RobotPtr
Definition: Bus.h:18
armarx::KinematicsWorld::removeRobotEngine
bool removeRobotEngine(const std::string &robotName) override
Definition: KinematicsWorld.cpp:804
armarx::KinematicsWorld::actuateRobotJointsPos
void actuateRobotJointsPos(const std::string &robotName, const std::map< std::string, float > &angles) override
Definition: KinematicsWorld.cpp:136
armarx::KinematicsWorld::KinematicRobotInfo::targetVelocities
std::map< std::string, float > targetVelocities
Definition: KinematicsWorld.h:193
armarx::KinematicsWorld::addObstacleEngine
bool addObstacleEngine(VirtualRobot::SceneObjectPtr o, VirtualRobot::SceneObject::Physics::SimulationType simType) override
Definition: KinematicsWorld.cpp:1135