SimulatedWorld.h
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 ( vahrenkamp at kit dot edu )
20  * @date 2016
21  * @copyright http://www.gnu.org/licenses/gpl-2.0.txt
22  * GNU General Public License
23  */
24 
25 #pragma once
26 
27 
28 
29 // just needed for SceneData
30 #include <ArmarXSimulation/interface/simulator/SimulatorInterface.h>
31 
34 
36 
37 // only needed for contact info, could be replaced with a generic struct
38 #include <SimDynamics/DynamicsEngine/DynamicsEngine.h>
39 
40 #include <Eigen/Core>
41 #include <Eigen/Geometry>
42 
43 #include <mutex>
44 
45 namespace armarx
46 {
47 
49  {
51  {
52  currentForce.setZero();
53  currentTorque.setZero();
54  enable = true;
55  }
56 
57  std::string robotName;
58  std::string robotNodeName;
59  std::string sensorName;
60  VirtualRobot::ForceTorqueSensorPtr ftSensor; // be sure to just access this object when the engine mutex is set!
61  bool enable;
62  Eigen::Vector3f currentForce;
63  Eigen::Vector3f currentTorque;
64 
65  std::string topicName;
66  SimulatorForceTorqueListenerInterfacePrx prx;
67  };
68  using ForceTorqueInfoPtr = std::shared_ptr<ForceTorqueInfo>;
69 
70  struct RobotInfo
71  {
72  public:
73  EIGEN_MAKE_ALIGNED_OPERATOR_NEW
74 
76  {
77  linearVelocity.setZero();
78  angularVelocity.setZero();
79  pose.setIdentity();
80  }
81 
83  std::map< std::string, Eigen::Matrix4f > robotNodePoses;
84 
85  // the topic on which we publish the robot's data
86  std::string robotName;
87  std::string robotTopicName;
88  SimulatorRobotListenerInterfacePrx simulatorRobotListenerPrx;
89 
90  // current values to be reported
94 
95  Eigen::Vector3f linearVelocity;
96  Eigen::Vector3f angularVelocity;
97 
98  std::vector<ForceTorqueInfo> forceTorqueSensors;
99  };
100  using RobotInfoPtr = std::shared_ptr<RobotInfo>;
101 
102  /*!
103  * \brief The SimulatedWorldData class This data is queried by the simulated in order to offer it via topics.
104  */
106  {
107  public:
108  EIGEN_MAKE_ALIGNED_OPERATOR_NEW
109 
110  std::vector<RobotInfo> robots;
112  // todo: objects (currently no need to populate objects via this channel)
113  };
114  using SimualtedWorldDataPtr = std::shared_ptr<SimulatedWorldData>;
115 
116  template <typename>
117  struct argType;
118 
119  template <typename R, typename A>
120  struct argType<R(SimDynamics::DynamicsEngine::*)(A)>
121  {
122  using type = A;
123  };
124  /*!
125  * \brief The SimulatedWorld class encapsulates the whole physics simulation and the corresponding data
126  *
127  */
129  public Logging
130  {
131  public:
132 
133  SimulatedWorld();
134  virtual ~SimulatedWorld() override = default;
135 
136 
137  // needs to be implemented by derived classes
138  virtual void actuateRobotJoints(const std::string& robotName,
139  const std::map< std::string, float>& angles,
140  const std::map<std::string, float>& velocities) = 0;
141  virtual void actuateRobotJointsPos(const std::string& robotName,
142  const std::map< std::string, float>& angles) = 0;
143  virtual void actuateRobotJointsVel(const std::string& robotName,
144  const std::map< std::string, float>& velocities) = 0;
145  virtual void actuateRobotJointsTorque(const std::string& robotName,
146  const std::map< std::string, float>& torques) = 0;
147  virtual void setRobotPose(const std::string& robotName, const Eigen::Matrix4f& globalPose) = 0;
148 
149  virtual void applyForceRobotNode(const std::string& robotName, const std::string& robotNodeName,
150  const Eigen::Vector3f& force) = 0;
151  virtual void applyTorqueRobotNode(const std::string& robotName, const std::string& robotNodeName,
152  const Eigen::Vector3f& torque) = 0;
153 
154  virtual void applyForceObject(const std::string& objectName, const Eigen::Vector3f& force) = 0;
155  virtual void applyTorqueObject(const std::string& objectName, const Eigen::Vector3f& torque) = 0;
156 
157  virtual bool hasObject(const std::string& instanceName) = 0;
158 
159  virtual std::map< std::string, float> getRobotJointAngles(const std::string& robotName) = 0;
160  virtual float getRobotJointAngle(const std::string& robotName, const std::string& nodeName) = 0;
161  virtual std::map< std::string, float> getRobotJointVelocities(const std::string& robotName) = 0;
162  virtual float getRobotJointVelocity(const std::string& robotName, const std::string& nodeName) = 0;
163  virtual std::map< std::string, float> getRobotJointTorques(const std::string& robotName) = 0;
164  virtual ForceTorqueDataSeq getRobotForceTorqueSensors(const std::string& robotName) = 0;
165 
166  virtual float getRobotJointLimitLo(const std::string& robotName, const std::string& nodeName) = 0;
167  virtual float getRobotJointLimitHi(const std::string& robotName, const std::string& nodeName) = 0;
168  virtual Eigen::Matrix4f getRobotPose(const std::string& robotName) = 0;
169 
170  virtual float getRobotMaxTorque(const std::string& robotName, const std::string& nodeName) = 0;
171  virtual void setRobotMaxTorque(const std::string& robotName, const std::string& nodeName, float maxTorque) = 0;
172 
173  virtual Eigen::Matrix4f getRobotNodePose(const std::string& robotName, const std::string& robotNodeName) = 0;
174 
175  virtual Eigen::Vector3f getRobotLinearVelocity(const std::string& robotName, const std::string& nodeName) = 0;
176  virtual Eigen::Vector3f getRobotAngularVelocity(const std::string& robotName, const std::string& nodeName) = 0;
177 
178  virtual void setRobotLinearVelocity(const std::string& robotName, const std::string& robotNodeName,
179  const Eigen::Vector3f& vel) = 0;
180  virtual void setRobotAngularVelocity(const std::string& robotName, const std::string& robotNodeName,
181  const Eigen::Vector3f& vel) = 0;
183  const std::string& robotName, const std::string& robotNodeName, const Eigen::Vector3f& vel) = 0;
185  const std::string& robotName, const std::string& robotNodeName, const Eigen::Vector3f& vel) = 0;
186 
187  virtual Eigen::Matrix4f getObjectPose(const std::string& objectName) = 0;
188 
189  virtual void setObjectPose(const std::string& objectName, const Eigen::Matrix4f& globalPose) = 0;
190  virtual void activateObject(const std::string& objectName);
191 
192 
193  virtual VirtualRobot::RobotPtr getRobot(const std::string& robotName) = 0;
194  virtual std::map<std::string, VirtualRobot::RobotPtr> getRobots() = 0;
195  virtual bool hasRobot(const std::string& robotName) = 0;
196  virtual bool hasRobotNode(const std::string& robotName, const std::string& robotNodeName) = 0;
197  virtual float getRobotMass(const std::string& robotName) = 0;
198 
199  virtual armarx::DistanceInfo getRobotNodeDistance(
200  const std::string& robotName, const std::string& robotNodeName1, const std::string& robotNodeName2) = 0;
201  virtual armarx::DistanceInfo getDistance(
202  const std::string& robotName, const std::string& robotNodeName, const std::string& worldObjectName) = 0;
203 
204 
205  //! create a joint
206  virtual void objectGrasped(const std::string& robotName, const std::string& robotNodeName,
207  const std::string& objectName);
208 
209  //! remove a joint
210  virtual void objectReleased(const std::string& robotName, const std::string& robotNodeName,
211  const std::string& objectName);
212 
213 
214  virtual std::vector<SimDynamics::DynamicsEngine::DynamicsContactInfo> copyContacts() = 0;
215 
216  /**
217  * Load and add a robot
218  */
219  /*!
220  * \brief addRobot Load and add int to the scene
221  * \param filename The absolute filename
222  * \param pose The initial pose (4x4matrix, in MM)
223  * \param filenameLocal The local filename (i.e. not the absolute one)
224  * \param pid_p PID control paramters, currently all joints use the same pid values
225  * \param pid_i PID control paramters, currently all joints use the same pid values
226  * \param pid_d PID control paramters, currently all joints use the same pid values
227  * \param staticRobot If set, the robot is added as a static/fixed kinematic object which does not move due to physics (it may be actuated by setting the position of the joints)
228  * \param scaling The scaling of the robot (1 = no scaling).
229  * \param colModel Use the collision model for visualization.
230  * \return
231  */
232  virtual bool addRobot(std::string& robotInstanceName, const std::string& filename,
234  const std::string& filenameLocal = "",
235  double pid_p = 10.0, double pid_i = 0, double pid_d = 0,
236  bool staticRobot = false, float scaling = 1.0f, bool colModel = false,
237  const std::map<std::string, float>& initConfig = {},
238  bool selfCollisions = false);
239  virtual bool addRobot(VirtualRobot::RobotPtr robot,
240  double pid_p, double pid_i, double pid_d,
241  const std::string& filename, bool staticRobot = false,
242  float scaling = 1.0f,
243  bool colModel = false, bool selfCollisions = false);
245 
246  /*!
247  * \brief toFramedPose Constructs a framed pose
248  * \param globalPose
249  * \param robotName
250  * \param frameName
251  * \return
252  */
253  virtual FramedPosePtr toFramedPose(const Eigen::Matrix4f& globalPose,
254  const std::string& robotName,
255  const std::string& frameName) = 0;
256 
257  /**
258  * Load and add an Obstacle (VirtualRobot xml file).
259  * \param filename The obstacle xml file
260  * \param pose The inital pose (mm)
261  * \param simType eUnknown: use sim type of SceneObject,
262  to overwrite internal simType use:
263  eStatic: cannot move, but collide;
264  eKinematic: can be moved, but no dynamics;
265  eDynamic: full dynamic simulation
266  */
267  virtual bool addObstacle(const std::string& filename,
269  VirtualRobot::SceneObject::Physics::SimulationType simType = VirtualRobot::SceneObject::Physics::eUnknown,
270  const std::string& localFilename = "");
271 
272  virtual bool addObstacle(
274  VirtualRobot::SceneObject::Physics::SimulationType simType = VirtualRobot::SceneObject::Physics::eUnknown,
275  const std::string& filename = "",
276  const std::string& objectClassName = "",
277  ObjectVisuPrimitivePtr primitiveData = {},
278  const std::string& project = ""
279  );
280 
281  /**
282  * Load and add an Scene (VirtualRobot xml file).
283  * \param filename The scene xml fil
284  * \param simType eStatic: cannot move, but collide; eKinematic: can be moved, but no dynamics; eDynamic: full dynamic simulation
285  */
286  virtual bool addScene(const std::string& filename,
287  VirtualRobot::SceneObject::Physics::SimulationType simType = VirtualRobot::SceneObject::Physics::eUnknown);
288  virtual bool addScene(VirtualRobot::ScenePtr scene,
289  VirtualRobot::SceneObject::Physics::SimulationType simType = VirtualRobot::SceneObject::Physics::eUnknown);
290 
291  virtual void setRobotNodeSimType(const std::string& robotName, const std::string& robotNodeName,
292  VirtualRobot::SceneObject::Physics::SimulationType simType) = 0;
293  virtual void setObjectSimType(const std::string& objectName, VirtualRobot::SceneObject::Physics::SimulationType simType) = 0;
294  virtual std::vector<VirtualRobot::SceneObjectPtr> getObjects() = 0;
295 
296  /**
297  * Perform one simulation step. Calculates the delta update time from the time that has passed since the last call.
298  * This updates all models.
299  */
300  virtual void stepPhysicsRealTime() = 0;
301 
302  /**
303  * Perform one simulation step.
304  * This updates all models.
305  */
306  virtual void stepPhysicsFixedTimeStep() = 0;
307 
308  /*!
309  * \brief
310  * \return The number of steps * the timestep in MS
311  */
312  virtual int getFixedTimeStepMS() = 0;
313 
314  using setMutexFunc = decltype(&SimDynamics::DynamicsEngine::setMutex);
316  using MutexType = MutexPtrType::element_type;
317 
318  using ScopedRecursiveLock = std::scoped_lock<MutexType>;
319  using ScopedRecursiveLockPtr = std::shared_ptr<ScopedRecursiveLock>;
320 
321 
322  virtual ScopedRecursiveLockPtr getScopedEngineLock(const std::string& callStr);
323 
324  virtual ScopedRecursiveLockPtr getScopedSyncLock(const std::string& callStr);
325 
326  virtual void enableLogging(const std::string& robotName, const std::string& logFile);
327 
328  virtual float getSimTime();
329  virtual float getSyncEngineTime();
330 
331  virtual bool removeObstacles();
332  virtual bool removeRobots();
333  virtual bool removeRobot(const std::string& robotName);
334 
335  virtual bool removeObstacle(const std::string& name);
336 
337 
338  virtual double getCurrentSimTime();
339  virtual void resetSimTime();
340 
341  virtual int getRobotJointAngleCount();//Data->robotJointAngles.size();
342  virtual int getContactCount();//contacts.size();
343  virtual int getObjectCount();//objects.size();
344 
345 
346  // protect access with mutex or use copyReportData
348 
350 
351  /*!
352  * \brief resetData Clears all data
353  */
354  virtual bool resetData();
355 
356  /*!
357  * \brief copySceneVisuData Creates a copy of the visualization data
358  * \return The copy
359  */
360  virtual SceneVisuData copySceneVisuData();
361 
362  /*!
363  * \brief synchronizeSimulationData Update the sim data according to the internal physics models.
364  * \return true on success.
365  */
366  virtual bool synchronizeSimulationData();
367 
368  virtual void updateContacts(bool enable);
369 
370  virtual void setupFloor(bool enable, const std::string& floorTexture);
371 
372  /*!
373  * \brief getSimulationStepDuration
374  * \return The requested duration of the last simulation step (in ms)
375  */
376  virtual float getSimulationStepDuration();
377 
378  /*!
379  * \brief getSimulationStepTimeMeasured
380  * \return How long it took to simulate the last sim step.
381  */
382  virtual float getSimulationStepTimeMeasured();
383 
384  virtual std::vector<std::string> getObstacleNames() = 0;
385  virtual std::vector<std::string> getRobotNames() = 0;
386 
387 
388  protected:
389 
390  // needs to be implemented in derived classes
392  VirtualRobot::SceneObject::Physics::SimulationType simType) = 0;
393  virtual bool removeObstacleEngine(const std::string& name) = 0;
394 
395  virtual bool addRobotEngine(VirtualRobot::RobotPtr robot, double pid_p, double pid_i, double pid_d,
396  const std::string& filename, bool staticRobot, bool selfCollisions) = 0;
397  virtual bool removeRobotEngine(const std::string& robotName) = 0;
398 
399 
400  //! create a joint
401  virtual bool objectGraspedEngine(const std::string& robotName, const std::string& robotNodeName,
402  const std::string& objectName, Eigen::Matrix4f& storeLocalTransform) = 0;
403  //! remove a joint
404  virtual bool objectReleasedEngine(const std::string& robotName, const std::string& robotNodeName,
405  const std::string& objectName) = 0;
406 
408  virtual void setupFloorEngine(bool enable, const std::string& floorTexture) = 0;
409  virtual bool synchronizeSimulationDataEngine() = 0;
410 
411 
412  // synchronize visu data
413  virtual bool synchronizeObjects() = 0;
414 
415  virtual bool synchronizeRobotNodePoses(const std::string& robotName,
416  std::map<std::string, armarx::PoseBasePtr>& objMap) = 0;
417 
418  virtual bool getRobotStatus(const std::string& robotName,
422  Eigen::Vector3f& linearVelocity,
423  Eigen::Vector3f& angularVelocity) = 0;
424 
425  virtual bool updateForceTorqueSensor(ForceTorqueInfo& ftInfo) = 0;
426 
427  virtual bool synchronizeSceneObjectPoses(VirtualRobot::SceneObjectPtr currentObjEngine,
428  std::map< std::string, armarx::PoseBasePtr >& objMap) = 0;
429 
430  // synchronize visu data (and robot report data for topics)
431  virtual bool synchronizeRobots();
432 
433  double currentSimTimeSec = 0.0;
434  double currentSyncTimeSec = 0.0;
435 
438 
440 
442  {
443  std::string robotName;
444  std::string robotNodeName;
445  std::string objectName;
447  };
448 
449  std::vector<GraspingInfo> attachedObjects;
450 
451  SceneVisuData simVisuData;
454  float simTimeStepMS; // simulation step in MS
455 
456 
458 
460 
461 
462  std::map< std::string, int > engineMtxAccCalls;
463  std::map< std::string, float > engineMtxAccTime;
464  std::map< std::string, IceUtil::Time > engineMtxLastTime;
465  std::map< std::string, int > syncMtxAccCalls;
466  std::map< std::string, float > syncMtxAccTime;
467  std::map< std::string, IceUtil::Time > syncMtxLastTime;
468 
469  };
470 
471  using SimulatedWorldPtr = std::shared_ptr<SimulatedWorld>;
472 }
473 
474 
armarx::SimulatedWorld::getRobotNodeDistance
virtual armarx::DistanceInfo getRobotNodeDistance(const std::string &robotName, const std::string &robotNodeName1, const std::string &robotNodeName2)=0
armarx::SimulatedWorld::simStepExecutionDurationMS
float simStepExecutionDurationMS
Definition: SimulatedWorld.h:457
armarx::SimulatedWorld::engineMtxAccCalls
std::map< std::string, int > engineMtxAccCalls
Definition: SimulatedWorld.h:462
armarx::SimulatedWorldData::robots
EIGEN_MAKE_ALIGNED_OPERATOR_NEW std::vector< RobotInfo > robots
Definition: SimulatedWorld.h:110
armarx::SimulatedWorld::MutexPtrType
typename argType< setMutexFunc >::type MutexPtrType
Definition: SimulatedWorld.h:315
armarx::SimulatedWorld::getFixedTimeStepMS
virtual int getFixedTimeStepMS()=0
armarx::SimulatedWorld::syncMtxLastTime
std::map< std::string, IceUtil::Time > syncMtxLastTime
Definition: SimulatedWorld.h:467
armarx::SimulatedWorld::adaptRobotToWorld
virtual VirtualRobot::RobotPtr adaptRobotToWorld(VirtualRobot::RobotPtr)
Definition: SimulatedWorld.cpp:458
armarx::ForceTorqueInfo::sensorName
std::string sensorName
Definition: SimulatedWorld.h:59
armarx::RobotInfo::jointTorques
NameValueMap jointTorques
Definition: SimulatedWorld.h:93
armarx::SimulatedWorld::synchronizeSceneObjectPoses
virtual bool synchronizeSceneObjectPoses(VirtualRobot::SceneObjectPtr currentObjEngine, std::map< std::string, armarx::PoseBasePtr > &objMap)=0
armarx::SimulatedWorld::simVisuData
SceneVisuData simVisuData
Definition: SimulatedWorld.h:451
armarx::SimulatedWorld::setMutexFunc
decltype(&SimDynamics::DynamicsEngine::setMutex) setMutexFunc
Definition: SimulatedWorld.h:314
armarx::SimulatedWorld::SimulatedWorld
SimulatedWorld()
Definition: SimulatedWorld.cpp:52
armarx::SimulatedWorld::objectGraspedEngine
virtual bool objectGraspedEngine(const std::string &robotName, const std::string &robotNodeName, const std::string &objectName, Eigen::Matrix4f &storeLocalTransform)=0
create a joint
armarx::SimulatedWorld::GraspingInfo::node2objectTransformation
Eigen::Matrix4f node2objectTransformation
Definition: SimulatedWorld.h:446
armarx::SimulatedWorld::getScopedSyncLock
virtual ScopedRecursiveLockPtr getScopedSyncLock(const std::string &callStr)
Definition: SimulatedWorld.cpp:747
armarx::SimulatedWorld::collectContacts
bool collectContacts
Definition: SimulatedWorld.h:439
armarx::ForceTorqueInfo::robotName
std::string robotName
Definition: SimulatedWorld.h:57
armarx::SimulatedWorld::getRobotForceTorqueSensors
virtual ForceTorqueDataSeq getRobotForceTorqueSensors(const std::string &robotName)=0
armarx::SimulatedWorld::setObjectPose
virtual void setObjectPose(const std::string &objectName, const Eigen::Matrix4f &globalPose)=0
armarx::SimulatedWorld::addRobot
virtual bool addRobot(std::string &robotInstanceName, const std::string &filename, Eigen::Matrix4f pose=Eigen::Matrix4f::Identity(), const std::string &filenameLocal="", double pid_p=10.0, double pid_i=0, double pid_d=0, bool staticRobot=false, float scaling=1.0f, bool colModel=false, const std::map< std::string, float > &initConfig={}, bool selfCollisions=false)
Load and add a robot.
Definition: SimulatedWorld.cpp:335
armarx::SimulatedWorld::~SimulatedWorld
virtual ~SimulatedWorld() override=default
armarx::SimulatedWorld::engineMtxAccTime
std::map< std::string, float > engineMtxAccTime
Definition: SimulatedWorld.h:463
armarx::SimulatedWorld::updateContacts
virtual void updateContacts(bool enable)
Definition: SimulatedWorld.cpp:932
armarx::RobotInfo::robotNodePoses
std::map< std::string, Eigen::Matrix4f > robotNodePoses
Definition: SimulatedWorld.h:83
armarx::SimulatedWorld::synchronizeMutex
MutexPtrType synchronizeMutex
Definition: SimulatedWorld.h:437
armarx::RobotInfo::jointVelocities
NameValueMap jointVelocities
Definition: SimulatedWorld.h:92
armarx::SimulatedWorld::hasObject
virtual bool hasObject(const std::string &instanceName)=0
armarx::SimulatedWorld::getRobotJointAngleCount
virtual int getRobotJointAngleCount()
Definition: SimulatedWorld.cpp:945
armarx::SimulatedWorld::applyForceRobotNode
virtual void applyForceRobotNode(const std::string &robotName, const std::string &robotNodeName, const Eigen::Vector3f &force)=0
armarx::SimulatedWorld::setRobotPose
virtual void setRobotPose(const std::string &robotName, const Eigen::Matrix4f &globalPose)=0
Pose.h
armarx::RobotInfoPtr
std::shared_ptr< RobotInfo > RobotInfoPtr
Definition: SimulatedWorld.h:100
armarx::ForceTorqueInfo::topicName
std::string topicName
Definition: SimulatedWorld.h:65
armarx::SimulatedWorld::maxRealTimeSimSpeed
float maxRealTimeSimSpeed
Definition: SimulatedWorld.h:453
armarx::SimulatedWorld::GraspingInfo::robotName
std::string robotName
Definition: SimulatedWorld.h:443
armarx::SimulatedWorld::applyTorqueObject
virtual void applyTorqueObject(const std::string &objectName, const Eigen::Vector3f &torque)=0
armarx::RobotInfo::angularVelocity
Eigen::Vector3f angularVelocity
Definition: SimulatedWorld.h:96
armarx::SimulatedWorldData::timestamp
IceUtil::Time timestamp
Definition: SimulatedWorld.h:111
armarx::ForceTorqueInfo
Definition: SimulatedWorld.h:48
armarx::SimulatedWorld::setRobotMaxTorque
virtual void setRobotMaxTorque(const std::string &robotName, const std::string &nodeName, float maxTorque)=0
armarx::SimulatedWorld::synchronizeRobots
virtual bool synchronizeRobots()
Definition: SimulatedWorld.cpp:822
armarx::SimulatedWorld::enableLogging
virtual void enableLogging(const std::string &robotName, const std::string &logFile)
Definition: SimulatedWorld.cpp:804
armarx::SimulatedWorld::synchronizeSimulationData
virtual bool synchronizeSimulationData()
synchronizeSimulationData Update the sim data according to the internal physics models.
Definition: SimulatedWorld.cpp:880
armarx::SimulatedWorld::setRobotAngularVelocityRobotRootFrame
virtual void setRobotAngularVelocityRobotRootFrame(const std::string &robotName, const std::string &robotNodeName, const Eigen::Vector3f &vel)=0
armarx::RobotInfo::robotName
std::string robotName
Definition: SimulatedWorld.h:86
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::SimulatedWorld::getCurrentSimTime
virtual double getCurrentSimTime()
Definition: SimulatedWorld.cpp:80
armarx::SimulatedWorld::attachedObjects
std::vector< GraspingInfo > attachedObjects
Definition: SimulatedWorld.h:449
armarx::SimulatedWorld::setRobotLinearVelocity
virtual void setRobotLinearVelocity(const std::string &robotName, const std::string &robotNodeName, const Eigen::Vector3f &vel)=0
armarx::SimulatedWorld::addObstacle
virtual bool addObstacle(const std::string &filename, const Eigen::Matrix4f &pose=Eigen::Matrix4f::Identity(), VirtualRobot::SceneObject::Physics::SimulationType simType=VirtualRobot::SceneObject::Physics::eUnknown, const std::string &localFilename="")
Load and add an Obstacle (VirtualRobot xml file).
Definition: SimulatedWorld.cpp:601
armarx::SimulatedWorld::resetData
virtual bool resetData()
resetData Clears all data
Definition: SimulatedWorld.cpp:70
armarx::SimulatedWorld::getSimTime
virtual float getSimTime()
Definition: SimulatedWorld.cpp:810
armarx::SimulatedWorld::getRobotMaxTorque
virtual float getRobotMaxTorque(const std::string &robotName, const std::string &nodeName)=0
scene3D::ScenePtr
std::shared_ptr< Scene > ScenePtr
Definition: PointerDefinitions.h:36
armarx::SimulatedWorld::objectReleasedEngine
virtual bool objectReleasedEngine(const std::string &robotName, const std::string &robotNodeName, const std::string &objectName)=0
remove a joint
armarx::SimulatedWorld::synchronizeDurationMS
float synchronizeDurationMS
Definition: SimulatedWorld.h:459
armarx::SimualtedWorldDataPtr
std::shared_ptr< SimulatedWorldData > SimualtedWorldDataPtr
Definition: SimulatedWorld.h:114
armarx::SimulatedWorld::synchronizeRobotNodePoses
virtual bool synchronizeRobotNodePoses(const std::string &robotName, std::map< std::string, armarx::PoseBasePtr > &objMap)=0
armarx::SimulatedWorld::updateForceTorqueSensor
virtual bool updateForceTorqueSensor(ForceTorqueInfo &ftInfo)=0
armarx::SimulatedWorld::removeRobotEngine
virtual bool removeRobotEngine(const std::string &robotName)=0
armarx::SimulatedWorld::getRobotNodePose
virtual Eigen::Matrix4f getRobotNodePose(const std::string &robotName, const std::string &robotNodeName)=0
armarx::SimulatedWorld::getRobotNames
virtual std::vector< std::string > getRobotNames()=0
armarx::SimulatedWorld::simReportData
SimulatedWorldData simReportData
Definition: SimulatedWorld.h:452
project
std::string project
Definition: VisualizationRobot.cpp:82
armarx::SimulatedWorld::activateObject
virtual void activateObject(const std::string &objectName)
Definition: SimulatedWorld.cpp:64
armarx::SimulatedWorld::getScopedEngineLock
virtual ScopedRecursiveLockPtr getScopedEngineLock(const std::string &callStr)
Definition: SimulatedWorld.cpp:714
armarx::ForceTorqueInfo::robotNodeName
std::string robotNodeName
Definition: SimulatedWorld.h:58
armarx::ForceTorqueInfo::prx
SimulatorForceTorqueListenerInterfacePrx prx
Definition: SimulatedWorld.h:66
IceInternal::Handle< FramedPose >
armarx::SimulatedWorld::objectReleased
virtual void objectReleased(const std::string &robotName, const std::string &robotNodeName, const std::string &objectName)
remove a joint
Definition: SimulatedWorld.cpp:206
armarx::SimulatedWorld::getFloor
virtual VirtualRobot::SceneObjectPtr getFloor()=0
armarx::SimulatedWorld::copyReportData
virtual SimulatedWorldData copyReportData()
Definition: SimulatedWorld.cpp:118
armarx::SimulatedWorld::getRobotPose
virtual Eigen::Matrix4f getRobotPose(const std::string &robotName)=0
armarx::SimulatedWorld::syncMtxAccCalls
std::map< std::string, int > syncMtxAccCalls
Definition: SimulatedWorld.h:465
armarx::SimulatedWorld::addObstacleEngine
virtual bool addObstacleEngine(VirtualRobot::SceneObjectPtr o, VirtualRobot::SceneObject::Physics::SimulationType simType)=0
armarx::SimulatedWorld::getObstacleNames
virtual std::vector< std::string > getObstacleNames()=0
armarx::SimulatedWorld::getSyncEngineTime
virtual float getSyncEngineTime()
Definition: SimulatedWorld.cpp:816
armarx::RobotInfo::jointAngles
NameValueMap jointAngles
Definition: SimulatedWorld.h:91
GfxTL::Identity
void Identity(MatrixXX< N, N, T > *a)
Definition: MatrixXX.h:523
armarx::SimulatedWorld::removeObstacle
virtual bool removeObstacle(const std::string &name)
Definition: SimulatedWorld.cpp:299
armarx::SimulatedWorld::setRobotAngularVelocity
virtual void setRobotAngularVelocity(const std::string &robotName, const std::string &robotNodeName, const Eigen::Vector3f &vel)=0
armarx::SimulatedWorld::toFramedPose
virtual FramedPosePtr toFramedPose(const Eigen::Matrix4f &globalPose, const std::string &robotName, const std::string &frameName)=0
toFramedPose Constructs a framed pose
armarx::ForceTorqueInfo::currentForce
Eigen::Vector3f currentForce
Definition: SimulatedWorld.h:62
armarx::ForceTorqueInfo::currentTorque
Eigen::Vector3f currentTorque
Definition: SimulatedWorld.h:63
armarx::SimulatedWorld::GraspingInfo
Definition: SimulatedWorld.h:441
armarx::SimulatedWorld::getRobotAngularVelocity
virtual Eigen::Vector3f getRobotAngularVelocity(const std::string &robotName, const std::string &nodeName)=0
armarx::SimulatedWorld::getRobotJointLimitLo
virtual float getRobotJointLimitLo(const std::string &robotName, const std::string &nodeName)=0
FramedPose.h
armarx::SimulatedWorld::getRobot
virtual VirtualRobot::RobotPtr getRobot(const std::string &robotName)=0
armarx::SimulatedWorld::engineMutex
MutexPtrType engineMutex
Definition: SimulatedWorld.h:436
armarx::SimulatedWorld::removeObstacleEngine
virtual bool removeObstacleEngine(const std::string &name)=0
armarx::SimulatedWorld::setRobotNodeSimType
virtual void setRobotNodeSimType(const std::string &robotName, const std::string &robotNodeName, VirtualRobot::SceneObject::Physics::SimulationType simType)=0
armarx::SimulatedWorld::setupFloorEngine
virtual void setupFloorEngine(bool enable, const std::string &floorTexture)=0
armarx::SimulatedWorld::ScopedRecursiveLockPtr
std::shared_ptr< ScopedRecursiveLock > ScopedRecursiveLockPtr
Definition: SimulatedWorld.h:319
armarx::argType
Definition: SimulatedWorld.h:117
armarx::SimulatedWorld::objectGrasped
virtual void objectGrasped(const std::string &robotName, const std::string &robotNodeName, const std::string &objectName)
create a joint
Definition: SimulatedWorld.cpp:243
armarx::SimulatedWorld::hasRobot
virtual bool hasRobot(const std::string &robotName)=0
armarx::SimulatedWorld::ScopedRecursiveLock
std::scoped_lock< MutexType > ScopedRecursiveLock
Definition: SimulatedWorld.h:318
armarx::ForceTorqueInfo::ftSensor
VirtualRobot::ForceTorqueSensorPtr ftSensor
Definition: SimulatedWorld.h:60
armarx::SimulatedWorld::getDistance
virtual armarx::DistanceInfo getDistance(const std::string &robotName, const std::string &robotNodeName, const std::string &worldObjectName)=0
armarx::SimulatedWorld::getRobotJointAngles
virtual std::map< std::string, float > getRobotJointAngles(const std::string &robotName)=0
armarx::ForceTorqueInfo::ForceTorqueInfo
ForceTorqueInfo()
Definition: SimulatedWorld.h:50
filename
std::string filename
Definition: VisualizationRobot.cpp:83
armarx::RobotInfo::forceTorqueSensors
std::vector< ForceTorqueInfo > forceTorqueSensors
Definition: SimulatedWorld.h:98
armarx::SimulatedWorld::stepPhysicsFixedTimeStep
virtual void stepPhysicsFixedTimeStep()=0
Perform one simulation step.
armarx::channels::KinematicUnitObserver::jointVelocities
const KinematicUnitDatafieldCreator jointVelocities("jointVelocities")
armarx::SimulatedWorld::removeRobot
virtual bool removeRobot(const std::string &robotName)
Definition: SimulatedWorld.cpp:464
armarx::SimulatedWorld::actuateRobotJointsTorque
virtual void actuateRobotJointsTorque(const std::string &robotName, const std::map< std::string, float > &torques)=0
armarx::SimulatedWorld::getRobotMass
virtual float getRobotMass(const std::string &robotName)=0
armarx::RobotInfo::linearVelocity
Eigen::Vector3f linearVelocity
Definition: SimulatedWorld.h:95
armarx::SimulatedWorld::getRobotJointTorques
virtual std::map< std::string, float > getRobotJointTorques(const std::string &robotName)=0
armarx::SimulatedWorld::stepPhysicsRealTime
virtual void stepPhysicsRealTime()=0
Perform one simulation step.
armarx::SimulatedWorld::GraspingInfo::robotNodeName
std::string robotNodeName
Definition: SimulatedWorld.h:444
armarx::SimulatedWorld::copyContacts
virtual std::vector< SimDynamics::DynamicsEngine::DynamicsContactInfo > copyContacts()=0
armarx::SimulatedWorld::getSimulationStepTimeMeasured
virtual float getSimulationStepTimeMeasured()
getSimulationStepTimeMeasured
Definition: SimulatedWorld.cpp:798
armarx::SimulatedWorld::getSimulationStepDuration
virtual float getSimulationStepDuration()
getSimulationStepDuration
Definition: SimulatedWorld.cpp:792
armarx::SimulatedWorld::synchronizeSimulationDataEngine
virtual bool synchronizeSimulationDataEngine()=0
armarx::SimulatedWorld::setRobotLinearVelocityRobotRootFrame
virtual void setRobotLinearVelocityRobotRootFrame(const std::string &robotName, const std::string &robotNodeName, const Eigen::Vector3f &vel)=0
armarx::armem::Time
armarx::core::time::DateTime Time
Definition: forward_declarations.h:13
armarx::SimulatedWorld::copySceneVisuData
virtual SceneVisuData copySceneVisuData()
copySceneVisuData Creates a copy of the visualization data
Definition: SimulatedWorld.cpp:938
armarx::SimulatedWorld::hasRobotNode
virtual bool hasRobotNode(const std::string &robotName, const std::string &robotNodeName)=0
armarx::SimulatedWorld::getRobotLinearVelocity
virtual Eigen::Vector3f getRobotLinearVelocity(const std::string &robotName, const std::string &nodeName)=0
armarx::SimulatedWorld::applyTorqueRobotNode
virtual void applyTorqueRobotNode(const std::string &robotName, const std::string &robotNodeName, const Eigen::Vector3f &torque)=0
armarx::RobotInfo::simulatorRobotListenerPrx
SimulatorRobotListenerInterfacePrx simulatorRobotListenerPrx
Definition: SimulatedWorld.h:88
armarx::RobotInfo
Definition: SimulatedWorld.h:70
armarx::RobotInfo::RobotInfo
EIGEN_MAKE_ALIGNED_OPERATOR_NEW RobotInfo()
Definition: SimulatedWorld.h:75
armarx::SimulatedWorld::getObjects
virtual std::vector< VirtualRobot::SceneObjectPtr > getObjects()=0
armarx::SimulatedWorld::actuateRobotJointsVel
virtual void actuateRobotJointsVel(const std::string &robotName, const std::map< std::string, float > &velocities)=0
armarx::SimulatedWorld::removeRobots
virtual bool removeRobots()
Definition: SimulatedWorld.cpp:96
A
class A(deque< T, A >)) ARMARX_OVERLOAD_STD_HASH_FOR_ITERABLE((class T
Enables hashing of std::list.
armarx::argType< R(SimDynamics::DynamicsEngine::*)(A)>::type
A type
Definition: SimulatedWorld.h:122
armarx::SimulatedWorld::getObjectCount
virtual int getObjectCount()
Definition: SimulatedWorld.cpp:965
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::SimulatedWorld::getRobotJointLimitHi
virtual float getRobotJointLimitHi(const std::string &robotName, const std::string &nodeName)=0
armarx::SimulatedWorld::actuateRobotJointsPos
virtual void actuateRobotJointsPos(const std::string &robotName, const std::map< std::string, float > &angles)=0
armarx::SimulatedWorld::applyForceObject
virtual void applyForceObject(const std::string &objectName, const Eigen::Vector3f &force)=0
armarx::SimulatedWorldPtr
std::shared_ptr< SimulatedWorld > SimulatedWorldPtr
Definition: SimulatedWorld.h:471
armarx::SimulatedWorld::addRobotEngine
virtual bool addRobotEngine(VirtualRobot::RobotPtr robot, double pid_p, double pid_i, double pid_d, const std::string &filename, bool staticRobot, bool selfCollisions)=0
GfxTL::Matrix4f
MatrixXX< 4, 4, float > Matrix4f
Definition: MatrixXX.h:601
armarx::Logging
Base Class for all Logging classes.
Definition: Logging.h:232
armarx::RobotInfo::robotTopicName
std::string robotTopicName
Definition: SimulatedWorld.h:87
armarx::SimulatedWorld::currentSyncTimeSec
double currentSyncTimeSec
Definition: SimulatedWorld.h:434
armarx::SimulatedWorld::setObjectSimType
virtual void setObjectSimType(const std::string &objectName, VirtualRobot::SceneObject::Physics::SimulationType simType)=0
armarx::SimulatedWorld::addScene
virtual bool addScene(const std::string &filename, VirtualRobot::SceneObject::Physics::SimulationType simType=VirtualRobot::SceneObject::Physics::eUnknown)
Load and add an Scene (VirtualRobot xml file).
Definition: SimulatedWorld.cpp:530
armarx::SimulatedWorld::currentSimTimeSec
double currentSimTimeSec
Definition: SimulatedWorld.h:433
armarx::SimulatedWorld::resetSimTime
virtual void resetSimTime()
Definition: SimulatedWorld.cpp:90
scene3D::SceneObjectPtr
boost::intrusive_ptr< SceneObject > SceneObjectPtr
Definition: PointerDefinitions.h:40
armarx::SimulatedWorld::MutexType
MutexPtrType::element_type MutexType
Definition: SimulatedWorld.h:316
armarx::SimulatedWorld::getObjectPose
virtual Eigen::Matrix4f getObjectPose(const std::string &objectName)=0
armarx::SimulatedWorld::setupFloor
virtual void setupFloor(bool enable, const std::string &floorTexture)
Definition: SimulatedWorld.cpp:780
armarx::SimulatedWorld::getReportData
virtual SimulatedWorldData & getReportData()
Definition: SimulatedWorld.cpp:112
armarx::SimulatedWorld::GraspingInfo::objectName
std::string objectName
Definition: SimulatedWorld.h:445
Logging.h
armarx::SimulatedWorld::actuateRobotJoints
virtual void actuateRobotJoints(const std::string &robotName, const std::map< std::string, float > &angles, const std::map< std::string, float > &velocities)=0
armarx::SimulatedWorld::getRobotStatus
virtual bool getRobotStatus(const std::string &robotName, NameValueMap &jointAngles, NameValueMap &jointVelocities, NameValueMap &jointTorques, Eigen::Vector3f &linearVelocity, Eigen::Vector3f &angularVelocity)=0
armarx::SimulatedWorld::getRobotJointVelocity
virtual float getRobotJointVelocity(const std::string &robotName, const std::string &nodeName)=0
armarx::channels::KinematicUnitObserver::jointTorques
const KinematicUnitDatafieldCreator jointTorques("jointTorques")
armarx::SimulatedWorld::removeObstacles
virtual bool removeObstacles()
Definition: SimulatedWorld.cpp:280
armarx::ForceTorqueInfo::enable
bool enable
Definition: SimulatedWorld.h:61
armarx::SimulatedWorld::engineMtxLastTime
std::map< std::string, IceUtil::Time > engineMtxLastTime
Definition: SimulatedWorld.h:464
armarx::SimulatedWorld::getRobots
virtual std::map< std::string, VirtualRobot::RobotPtr > getRobots()=0
armarx::SimulatedWorld::getRobotJointAngle
virtual float getRobotJointAngle(const std::string &robotName, const std::string &nodeName)=0
armarx
This file offers overloads of toIce() and fromIce() functions for STL container types.
Definition: ArmarXTimeserver.cpp:28
armarx::SimulatedWorld::syncMtxAccTime
std::map< std::string, float > syncMtxAccTime
Definition: SimulatedWorld.h:466
armarx::RobotInfo::pose
Eigen::Matrix4f pose
Definition: SimulatedWorld.h:82
armarx::SimulatedWorld::getRobotJointVelocities
virtual std::map< std::string, float > getRobotJointVelocities(const std::string &robotName)=0
armarx::SimulatedWorld::getContactCount
virtual int getContactCount()
Definition: SimulatedWorld.cpp:958
VirtualRobot::RobotPtr
std::shared_ptr< class Robot > RobotPtr
Definition: Bus.h:18
armarx::ForceTorqueInfoPtr
std::shared_ptr< ForceTorqueInfo > ForceTorqueInfoPtr
Definition: SimulatedWorld.h:68
armarx::SimulatedWorld::synchronizeObjects
virtual bool synchronizeObjects()=0
armarx::SimulatedWorldData
The SimulatedWorldData class This data is queried by the simulated in order to offer it via topics.
Definition: SimulatedWorld.h:105