Simulator.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 2015
21  * @copyright http://www.gnu.org/licenses/gpl-2.0.txt
22  * GNU General Public License
23  */
24 
25 #pragma once
26 
27 #include <condition_variable>
28 #include <mutex>
29 
30 #include <Eigen/Core>
31 #include <Eigen/Geometry>
32 
37 #include <ArmarXCore/interface/core/PackagePath.h>
38 #include <ArmarXCore/interface/core/TimeServerInterface.h>
39 #include <ArmarXCore/interface/events/SimulatorResetEvent.h>
40 
42 #include <RobotAPI/interface/core/RobotState.h>
45 
46 #include <ArmarXSimulation/interface/simulator/SimulatorInterface.h>
47 
48 #include "BulletPhysicsWorld.h"
49 #include "KinematicsWorld.h"
50 #include "SimulatedWorld.h"
53 #include <MemoryX/interface/components/LongtermMemoryInterface.h>
54 #include <MemoryX/interface/components/PriorKnowledgeInterface.h>
55 #include <MemoryX/interface/components/WorkingMemoryInterface.h>
56 #include <MemoryX/interface/gui/EntityDrawerInterface.h>
59 
60 
61 #define MAX_INITIAL_ROBOT_COUNT 4
62 
63 namespace armarx
64 {
65 
66  class SimulatorTimeServerProxy;
68 
69  enum class SimulatorType
70  {
71  Kinematics,
72  Bullet,
73  Mujoco
74  };
75 
76  /**
77  * @class SimulatorPropertyDefinitions
78  * @brief
79  */
81  {
82  public:
85  };
86 
87  /**
88  * @brief The Simulator class holds an instance of the AmrarXPhysicsWorld and communicates to ArmarX.
89  *
90  * The following optional parameters can be used.
91  * - RobotFileName<br>
92  * Simox/VirtualRobot robot file name, e.g. robot_model.xml.
93  * - InitialRobotPose.x/y/z/roll/pitch/yaw<br>
94  * The initial pose of the robot
95  * - LogRobot<br>
96  * Default: false, If true, the complete robot state is logged to a file.
97  * - RobotControllerPID.p/i/d<br>
98  * Setup robot controllers: PID paramters
99  * - LongtermMemory.SnapshotName<br>
100  * Name of snapshot to load the scene
101  * - SceneFileName<br>
102  * Simox/VirtualRobot scene file name, e.g. myScene.xml. Usually, sceneas are loaded via MemoryX-snapshots, but in order to test a setup, a scene can be imported directly.
103  * - FloorPlane<br>
104  * Indicates if the should be created or not. Default: true.
105  * - FloorTexture<br>
106  * The texture file for the floor. By default, a standard texture is used
107  * - FixedTimeStepLoopNrSteps<br>
108  * The maximal number of internal simulation loops (fixed time step mode). After the maximum number of internal steps is performed, the simulator interpolates the remaining time.
109  * - FixedTimeStepStepTimeMS<br>
110  * The simulation's internal timestep (fixed time step mode)
111  * - ReportVisuFrequency<br>
112  * How often should the visualization data be published. Value is given in Hz. (0 to disable, default: 30)
113  * - ReportVisuTopicName<br>
114  * The topic on which the visualization updates are published. Default: ReportVisuTopicName
115  * - ReportDataFrequency<br>
116  * How often should the robot data be published. Value is given in Hz. (0 to disable, default: 30)
117  */
118  class Simulator :
119  virtual public SimulatorInterface,
120  virtual public Component,
121  virtual protected IceUtil::Thread,
122  virtual public TimeServerInterface
123  {
124  public:
125  Simulator();
126  ~Simulator() override;
127 
128 
129  // inherited from Component
130  std::string getDefaultName() const override;
131 
132  void onInitComponent() override;
133  void onConnectComponent() override;
134  void onDisconnectComponent() override;
135  void onExitComponent() override;
136 
137  // inherited from Thread
138  void run() override;
139 
140  // inherited from TimeServerInterface
141  void stop(const Ice::Current& c = Ice::emptyCurrent) override;
142 
143  /**
144  * @brief setSpeed sets the scaling factor for the speed of passing of time
145  * e.g. setSpeed(2) leads to 2 virtual seconds passing every 1 real second
146  * (provided the simulation is able to keep up)
147  * @param newSpeed new scaling factor for speed
148  */
149  void setSpeed(Ice::Float newSpeed, const Ice::Current& c = Ice::emptyCurrent) override;
150  Ice::Float getSpeed(const Ice::Current& c = Ice::emptyCurrent) override;
151  Ice::Long getTime(const Ice::Current& c = Ice::emptyCurrent) override;
152  Ice::Int getStepTimeMS(const ::Ice::Current& = Ice::emptyCurrent) override;
153 
154  // inherited from SimulatorDataInterface
155  void actuateRobotJoints(const std::string& robotName,
156  const NameValueMap& angles,
157  const NameValueMap& velocities,
158  const Ice::Current& c = Ice::emptyCurrent) override;
159  void actuateRobotJointsPos(const std::string& robotName,
160  const NameValueMap& angles,
161  const Ice::Current& c = Ice::emptyCurrent) override;
162  void actuateRobotJointsVel(const std::string& robotName,
163  const NameValueMap& velocities,
164  const Ice::Current& c = Ice::emptyCurrent) override;
165  void actuateRobotJointsTorque(const std::string& robotName,
166  const NameValueMap& torques,
167  const Ice::Current& c = Ice::emptyCurrent) override;
168  void setRobotPose(const std::string& robotName,
169  const PoseBasePtr& globalPose,
170  const Ice::Current& c = Ice::emptyCurrent) override;
171 
172  void applyForceRobotNode(const std::string& robotName,
173  const std::string& robotNodeName,
174  const Vector3BasePtr& force,
175  const Ice::Current& c = Ice::emptyCurrent) override;
176  void applyTorqueRobotNode(const std::string& robotName,
177  const std::string& robotNodeName,
178  const Vector3BasePtr& torque,
179  const Ice::Current& c = Ice::emptyCurrent) override;
180 
181  void applyForceObject(const std::string& objectName,
182  const Vector3BasePtr& force,
183  const Ice::Current& c = Ice::emptyCurrent) override;
184  void applyTorqueObject(const std::string& objectName,
185  const Vector3BasePtr& torque,
186  const Ice::Current& c = Ice::emptyCurrent) override;
187 
188  // "old api => should be removed"
189  std::string addRobot(const std::string& filename,
190  const Ice::Current& c = Ice::emptyCurrent) override;
191  std::string addScaledRobot(const std::string& filename,
192  float scale,
193  const Ice::Current& c = Ice::emptyCurrent) override;
194  std::string addScaledRobotName(const std::string& instanceName,
195  const std::string& filename,
196  float scale,
197  const Ice::Current& c = Ice::emptyCurrent) override;
198  bool removeRobot(const std::string& robotName, const Ice::Current& c = Ice::emptyCurrent);
199  void addObject(const memoryx::ObjectClassBasePtr& objectClassBase,
200  const std::string& instanceName,
201  const PoseBasePtr& globalPose,
202  bool isStatic = false,
203  const Ice::Current& c = Ice::emptyCurrent) override;
204 
205  // "new api" =>
206  std::string addRobotFromFile(const armarx::data::PackagePath& packagePath,
207  const Ice::Current& c = Ice::emptyCurrent) override;
208  void addObjectFromFile(const armarx::data::PackagePath& packagePath,
209  const std::string& instanceName,
210  const PoseBasePtr& globalPose,
211  bool isStatic = false,
212  const Ice::Current& c = Ice::emptyCurrent) override;
213 
214 
215  void addBox(float width,
216  float height,
217  float depth,
218  float massKG,
219  const DrawColor& color,
220  const std::string& instanceName,
221  const PoseBasePtr& globalPose,
222  bool isStatic = false,
223  const Ice::Current& c = Ice::emptyCurrent) override;
224 
225  Ice::StringSeq getRobotNames(const Ice::Current&) override;
226  void removeObject(const std::string& instanceName, const Ice::Current&) override;
227 
228  bool hasObject(const std::string& instanceName,
229  const Ice::Current& c = Ice::emptyCurrent) override;
230  void setObjectPose(const std::string& objectName,
231  const PoseBasePtr& globalPose,
232  const Ice::Current& c = Ice::emptyCurrent) override;
233  void setObjectSimulationType(const std::string& objectName,
234  armarx::SimulationType type,
235  const Ice::Current& c = Ice::emptyCurrent) override;
236  void activateObject(const std::string& objectName,
237  const Ice::Current& c = Ice::emptyCurrent) override;
238 
239  bool hasRobot(const std::string& robotName,
240  const Ice::Current& c = Ice::emptyCurrent) override;
241  bool hasRobotNode(const std::string& robotName,
242  const std::string& robotNodeName,
243  const Ice::Current& c = Ice::emptyCurrent) override;
244  float getRobotMass(const std::string& robotName,
245  const Ice::Current& c = Ice::emptyCurrent) override;
246 
247  NameValueMap getRobotJointAngles(const std::string& robotName,
248  const Ice::Current& c = Ice::emptyCurrent) override;
249  float getRobotJointAngle(const std::string& robotName,
250  const std::string& nodeName,
251  const Ice::Current& c = Ice::emptyCurrent) override;
252  NameValueMap getRobotJointVelocities(const std::string& robotName,
253  const Ice::Current& c = Ice::emptyCurrent) override;
254  float getRobotJointVelocity(const std::string& robotName,
255  const std::string& nodeName,
256  const Ice::Current& c = Ice::emptyCurrent) override;
257  NameValueMap getRobotJointTorques(const std::string& robotName,
258  const Ice::Current& c = Ice::emptyCurrent) override;
259  ForceTorqueDataSeq
260  getRobotForceTorqueSensors(const std::string& robotName,
261  const Ice::Current& c = Ice::emptyCurrent) override;
262 
263  float getRobotJointLimitLo(const std::string& robotName,
264  const std::string& nodeName,
265  const Ice::Current& c = Ice::emptyCurrent) override;
266  float getRobotJointLimitHi(const std::string& robotName,
267  const std::string& nodeName,
268  const Ice::Current& c = Ice::emptyCurrent) override;
269  PoseBasePtr getRobotPose(const std::string& robotName,
270  const Ice::Current& c = Ice::emptyCurrent) override;
271  SimulatedRobotState getRobotState(const std::string& robotName,
272  const Ice::Current&) override;
273 
274  float getRobotMaxTorque(const std::string& robotName,
275  const std::string& nodeName,
276  const Ice::Current& c = Ice::emptyCurrent) override;
277  void setRobotMaxTorque(const std::string& robotName,
278  const std::string& nodeName,
279  float maxTorque,
280  const Ice::Current& c = Ice::emptyCurrent) override;
281 
282  PoseBasePtr getRobotNodePose(const std::string& robotName,
283  const std::string& robotNodeName,
284  const Ice::Current& c = Ice::emptyCurrent) override;
285 
286  Vector3BasePtr getRobotLinearVelocity(const std::string& robotName,
287  const std::string& nodeName,
288  const Ice::Current& c = Ice::emptyCurrent) override;
289  Vector3BasePtr getRobotAngularVelocity(const std::string& robotName,
290  const std::string& nodeName,
291  const Ice::Current& c = Ice::emptyCurrent) override;
292 
293  void setRobotLinearVelocity(const std::string& robotName,
294  const std::string& robotNodeName,
295  const Vector3BasePtr& vel,
296  const Ice::Current& c = Ice::emptyCurrent) override;
297  void setRobotAngularVelocity(const std::string& robotName,
298  const std::string& robotNodeName,
299  const Vector3BasePtr& vel,
300  const Ice::Current& c = Ice::emptyCurrent) override;
301  void
302  setRobotLinearVelocityRobotRootFrame(const std::string& robotName,
303  const std::string& robotNodeName,
304  const Vector3BasePtr& vel,
305  const Ice::Current& c = Ice::emptyCurrent) override;
306  void
307  setRobotAngularVelocityRobotRootFrame(const std::string& robotName,
308  const std::string& robotNodeName,
309  const Vector3BasePtr& vel,
310  const Ice::Current& c = Ice::emptyCurrent) override;
311 
312  //! create a joint
313  void objectGrasped(const std::string& robotName,
314  const std::string& robotNodeName,
315  const std::string& objectName,
316  const Ice::Current& c = Ice::emptyCurrent) override;
317 
318  //! remove a joint
319  void objectReleased(const std::string& robotName,
320  const std::string& robotNodeName,
321  const std::string& objectName,
322  const Ice::Current& c = Ice::emptyCurrent) override;
323 
324  PoseBasePtr getObjectPose(const std::string& objectName,
325  const Ice::Current& c = Ice::emptyCurrent) override;
326 
327  DistanceInfo getDistance(const std::string& robotName,
328  const std::string& robotNodeName,
329  const std::string& worldObjectName,
330  const Ice::Current& c = Ice::emptyCurrent) override;
331  DistanceInfo getRobotNodeDistance(const std::string& robotName,
332  const std::string& robotNodeName1,
333  const std::string& robotNodeName2,
334  const Ice::Current& c = Ice::emptyCurrent) override;
335  void showContacts(bool enable,
336  const std::string& layerName,
337  const Ice::Current& c = Ice::emptyCurrent) override;
338 
339  /*!
340  * \brief Returns a list of all contacts. Note that you must call updateContacts() first to enable
341  * contacts handling.
342  */
343  ContactInfoSequence getContacts(const Ice::Current& c = Ice::emptyCurrent) override;
344 
345  /*!
346  * \brief Enables the handling of contacts. If you intend to use getContacts(), call this method
347  * with enabled = true first.
348  */
349  void updateContacts(bool enable, const Ice::Current& c = Ice::emptyCurrent) override;
350 
351  ObjectClassInformationSequence
352  getObjectClassPoses(const std::string& robotName,
353  const std::string& frameName,
354  const std::string& className,
355  const Ice::Current& c = Ice::emptyCurrent) override;
356 
357 
358  /*!
359  * \brief reInitialize Re-initializes the scene.
360  * Removes all robots and objects (and, in case the scene was loaded via a MemoryX snapshot, the working memory is cleared)
361  * Then, the setup is re-loaded similar to the startup procedure.
362  */
363  void reInitialize(const Ice::Current& c = Ice::emptyCurrent) override;
364 
365 
366  float getSimTime(const Ice::Current& c = Ice::emptyCurrent) override;
367 
368 
369  SceneVisuData getScene(const Ice::Current& c = Ice::emptyCurrent) override;
370  SimulatorInformation
371  getSimulatorInformation(const ::Ice::Current& = Ice::emptyCurrent) override;
372 
373  /*!
374  * \brief
375  * \return The number of steps * the timestep in MS
376  */
377  int getFixedTimeStepMS(const Ice::Current& c = Ice::emptyCurrent) override;
378 
379  void start(const Ice::Current& c = Ice::emptyCurrent) override;
380  void pause(const Ice::Current& c = Ice::emptyCurrent) override;
381  void step(const Ice::Current& c = Ice::emptyCurrent) override;
382  bool isRunning(const Ice::Current& c = Ice::emptyCurrent) override;
383 
384  bool addSnapshot(memoryx::WorkingMemorySnapshotInterfacePrx snapshotInterfacePrx);
385  bool
386  loadAgentsFromSnapshot(memoryx::WorkingMemorySnapshotInterfacePrx snapshotInterfacePrx);
387 
388  /**
389  * @see PropertyUser::createPropertyDefinitions()
390  */
393  {
395  }
396 
397 
398  protected:
399  void simulationLoop();
400  void reportVisuLoop();
401  void reportDataLoop();
402  /**
403  * @brief stop the simulation and join the simulation thread
404  */
405  void shutdownSimulationLoop();
406 
407  /*!
408  * \brief resetData Clears all data
409  * \param clearWorkingMemory If set, the working memory is also cleared.
410  */
411  void resetData(bool clearWorkingMemory = false);
412 
413  void initializeData();
414 
415  SimulatedRobotState stateFromRobotInfo(RobotInfo const& robot, IceUtil::Time timestamp);
416 
417  /// Returns the name. On failure an empty string is returned.
418  std::string
419  addRobot(std::string robotInstanceName,
420  const std::string& robFileGlobal,
421  Eigen::Matrix4f gp,
422  const std::string& robFile,
423  double pid_p = 10.0,
424  double pid_i = 0.0,
425  double pid_d = 0.0,
426  bool isStatic = false,
427  float scaling = 1,
428  bool colModel = false,
429  std::map<std::string, float> initConfig = std::map<std::string, float>(),
430  bool selfCollisions = false);
431  bool updateRobotTopics();
432 
434 
435 
436  protected:
437  /// The sim task
439  /// The report visu task
441  /// The report data task
443 
444  // simulator thread control
448  std::condition_variable condSimulatorThreadRunning;
449 
451 
452 
453  /// Stores the time that was needed for communictaion
454  float currentComTimeMS = 0;
455  /// Stores the time that was needed to perform the last simulation loop
456  float currentSimTimeMS = 0;
457  /// stores the time that was needed to sync the data
458  float currentSyncTimeMS = 0;
459 
460  /// Scaling factor for the passing of time
461  float timeServerSpeed = 0;
462 
463  TimeServerListenerPrx timeTopicPrx;
464 
465  GlobalRobotPoseLocalizationListenerPrx globalRobotLocalization;
466  bool reportRobotPose = false;
467 
468  SimulatorListenerInterfacePrx simulatorVisuUpdateListenerPrx;
469 
470  std::atomic<float> reportVisuTimeMS = 0;
471 
472  std::string priorKnowledgeName;
473  std::string commonStorageName;
474  memoryx::WorkingMemoryInterfacePrx memoryPrx;
475  memoryx::PriorKnowledgeInterfacePrx priorKnowledgePrx;
476  memoryx::LongtermMemoryInterfacePrx longtermMemoryPrx;
478 
479  /// Constructed once based on the `ObjectPackage` property
481 
482  /// Drawing contacts
483  memoryx::EntityDrawerInterfacePrx entityDrawerPrx;
484 
485  bool publishContacts = false;
486  std::string contactLayerName;
487 
489 
490  /// Stores all instances that belong to a class
491  std::map<std::string, std::vector<std::string>> classInstanceMap;
492 
493  /**
494  * Proxy object to offer the Timeserver proxy
495  *
496  * This is a hack to allow offering the proxies "Simulator" and "MasterTimeServer" at once
497  */
499  SimulatorResetEventPrx simulatorResetEventTopic;
500 
501 
502  private:
503  void addRobotsFromProperties();
504  void addSceneFromFile(const std::string& sceneFile);
505  void addSceneFromMemorySnapshot(const std::string& snapshotName);
506 
507  /**
508  * Add a scene defined in the ArmarX JSON format to the simulation.
509  */
510  void addSceneFromJsonFile(const std::string& scenePath);
511 
512  /**
513  * Add a scene defined in the SDF format to the simulation.
514  */
515  void addSceneFromSdfFile(const std::string& scenePath);
516 
517  /**
518  * Add one object from an ArmarX JSON scene to the simulation.
519  */
520  void addJsonSceneObject(const armarx::objects::SceneObject object,
521  std::map<ObjectID, int>& idCounters);
522 
523  void fixateRobotNode(const std::string& robotName, const std::string& robotNodeName);
524  void fixateObject(const std::string& objectName);
525  };
526 
528 } // namespace armarx
armarx::Simulator::addBox
void addBox(float width, float height, float depth, float massKG, const DrawColor &color, const std::string &instanceName, const PoseBasePtr &globalPose, bool isStatic=false, const Ice::Current &c=Ice::emptyCurrent) override
Definition: Simulator.cpp:1563
armarx::Simulator::onExitComponent
void onExitComponent() override
Hook for subclass.
Definition: Simulator.cpp:1062
armarx::Simulator::Simulator
Simulator()
Definition: Simulator.cpp:247
armarx::Simulator::setRobotLinearVelocityRobotRootFrame
void setRobotLinearVelocityRobotRootFrame(const std::string &robotName, const std::string &robotNodeName, const Vector3BasePtr &vel, const Ice::Current &c=Ice::emptyCurrent) override
Definition: Simulator.cpp:1864
armarx::Simulator::reportDataLoop
void reportDataLoop()
Definition: Simulator.cpp:2508
armarx::Simulator::reportVisuTask
PeriodicTask< Simulator >::pointer_type reportVisuTask
The report visu task.
Definition: Simulator.h:440
armarx::Simulator::getObjectPose
PoseBasePtr getObjectPose(const std::string &objectName, const Ice::Current &c=Ice::emptyCurrent) override
Definition: Simulator.cpp:1899
armarx::Simulator::reportVisuLoop
void reportVisuLoop()
Definition: Simulator.cpp:2365
armarx::VariantType::Float
const VariantTypeId Float
Definition: Variant.h:919
armarx::Simulator::timeserverProxy
SimulatorTimeServerProxyPtr timeserverProxy
Proxy object to offer the Timeserver proxy.
Definition: Simulator.h:498
armarx::Simulator::stop
void stop(const Ice::Current &c=Ice::emptyCurrent) override
Definition: Simulator.cpp:2292
armarx::Simulator::lastPublishedContacts
int lastPublishedContacts
Definition: Simulator.h:488
armarx::Simulator::actuateRobotJointsTorque
void actuateRobotJointsTorque(const std::string &robotName, const NameValueMap &torques, const Ice::Current &c=Ice::emptyCurrent) override
Definition: Simulator.cpp:1350
armarx::Simulator::addRobot
std::string addRobot(const std::string &filename, const Ice::Current &c=Ice::emptyCurrent) override
Definition: Simulator.cpp:2618
armarx::Simulator::onInitComponent
void onInitComponent() override
Pure virtual hook for the subclass.
Definition: Simulator.cpp:276
armarx::Simulator::setRobotAngularVelocityRobotRootFrame
void setRobotAngularVelocityRobotRootFrame(const std::string &robotName, const std::string &robotNodeName, const Vector3BasePtr &vel, const Ice::Current &c=Ice::emptyCurrent) override
Definition: Simulator.cpp:1874
armarx::Simulator::getRobotPose
PoseBasePtr getRobotPose(const std::string &robotName, const Ice::Current &c=Ice::emptyCurrent) override
Definition: Simulator.cpp:1793
armarx::Simulator::getRobotAngularVelocity
Vector3BasePtr getRobotAngularVelocity(const std::string &robotName, const std::string &nodeName, const Ice::Current &c=Ice::emptyCurrent) override
Definition: Simulator.cpp:1835
GfxTL::Matrix4f
MatrixXX< 4, 4, float > Matrix4f
Definition: MatrixXX.h:650
armarx::Simulator::applyForceObject
void applyForceObject(const std::string &objectName, const Vector3BasePtr &force, const Ice::Current &c=Ice::emptyCurrent) override
Definition: Simulator.cpp:1395
armarx::Simulator::run
void run() override
Definition: Simulator.cpp:2248
Pose.h
armarx::Simulator::condSimulatorThreadRunning
std::condition_variable condSimulatorThreadRunning
Definition: Simulator.h:448
armarx::Simulator::hasRobotNode
bool hasRobotNode(const std::string &robotName, const std::string &robotNodeName, const Ice::Current &c=Ice::emptyCurrent) override
Definition: Simulator.cpp:1890
armarx::Simulator::getRobotMaxTorque
float getRobotMaxTorque(const std::string &robotName, const std::string &nodeName, const Ice::Current &c=Ice::emptyCurrent) override
Definition: Simulator.cpp:1800
armarx::Simulator::getSimulatorInformation
SimulatorInformation getSimulatorInformation(const ::Ice::Current &=Ice::emptyCurrent) override
Definition: Simulator.cpp:1941
Properties.h
armarx::SimulatorPropertyDefinitions::~SimulatorPropertyDefinitions
~SimulatorPropertyDefinitions() override
Definition: Simulator.cpp:243
armarx::Simulator::simulationTask
PeriodicTask< Simulator >::pointer_type simulationTask
The sim task.
Definition: Simulator.h:438
armarx::Simulator::getSpeed
Ice::Float getSpeed(const Ice::Current &c=Ice::emptyCurrent) override
Definition: Simulator.cpp:2304
armarx::PropertyDefinitionContainer::prefix
std::string prefix
Prefix of the properties such as namespace, domain, component name, etc.
Definition: PropertyDefinitionContainer.h:345
GridFileManager.h
armarx::Simulator::getRobotJointTorques
NameValueMap getRobotJointTorques(const std::string &robotName, const Ice::Current &c=Ice::emptyCurrent) override
Definition: Simulator.cpp:1765
PeriodicTask.h
armarx::Simulator::timeServerSpeed
float timeServerSpeed
Scaling factor for the passing of time.
Definition: Simulator.h:461
armarx::Simulator::currentComTimeMS
float currentComTimeMS
Stores the time that was needed for communictaion.
Definition: Simulator.h:454
armarx::SimulatorType::Bullet
@ Bullet
armarx::Simulator::reportVisuTimeMS
std::atomic< float > reportVisuTimeMS
Definition: Simulator.h:470
armarx::Simulator::addObjectFromFile
void addObjectFromFile(const armarx::data::PackagePath &packagePath, const std::string &instanceName, const PoseBasePtr &globalPose, bool isStatic=false, const Ice::Current &c=Ice::emptyCurrent) override
Definition: Simulator.cpp:1490
c
constexpr T c
Definition: UnscentedKalmanFilterTest.cpp:46
armarx::Simulator::getRobotMass
float getRobotMass(const std::string &robotName, const Ice::Current &c=Ice::emptyCurrent) override
Definition: Simulator.cpp:1731
armarx::Simulator::addScaledRobotName
std::string addScaledRobotName(const std::string &instanceName, const std::string &filename, float scale, const Ice::Current &c=Ice::emptyCurrent) override
Definition: Simulator.cpp:2599
armarx::Simulator::resetData
void resetData(bool clearWorkingMemory=false)
resetData Clears all data
Definition: Simulator.cpp:1106
ObjectClass.h
armarx::Simulator::isRunning
bool isRunning(const Ice::Current &c=Ice::emptyCurrent) override
Definition: Simulator.cpp:2359
armarx::Simulator::actuateRobotJointsPos
void actuateRobotJointsPos(const std::string &robotName, const NameValueMap &angles, const Ice::Current &c=Ice::emptyCurrent) override
Definition: Simulator.cpp:1334
armarx::objects::SceneObject
Definition: Scene.h:37
armarx::Simulator::updateRobotTopics
bool updateRobotTopics()
Definition: Simulator.cpp:2084
armarx::Simulator::actuateRobotJointsVel
void actuateRobotJointsVel(const std::string &robotName, const NameValueMap &velocities, const Ice::Current &c=Ice::emptyCurrent) override
Definition: Simulator.cpp:1342
armarx::Simulator::actuateRobotJoints
void actuateRobotJoints(const std::string &robotName, const NameValueMap &angles, const NameValueMap &velocities, const Ice::Current &c=Ice::emptyCurrent) override
Definition: Simulator.cpp:1325
armarx::Simulator::hasRobot
bool hasRobot(const std::string &robotName, const Ice::Current &c=Ice::emptyCurrent) override
Definition: Simulator.cpp:1884
armarx::Simulator::getDistance
DistanceInfo getDistance(const std::string &robotName, const std::string &robotNodeName, const std::string &worldObjectName, const Ice::Current &c=Ice::emptyCurrent) override
Definition: Simulator.cpp:2170
armarx::Simulator::getRobotJointLimitHi
float getRobotJointLimitHi(const std::string &robotName, const std::string &nodeName, const Ice::Current &c=Ice::emptyCurrent) override
Definition: Simulator.cpp:1785
armarx::Simulator::createPropertyDefinitions
PropertyDefinitionsPtr createPropertyDefinitions() override
Definition: Simulator.h:392
armarx::Simulator::getObjectClassPoses
ObjectClassInformationSequence getObjectClassPoses(const std::string &robotName, const std::string &frameName, const std::string &className, const Ice::Current &c=Ice::emptyCurrent) override
Definition: Simulator.cpp:2131
armarx::Simulator::pause
void pause(const Ice::Current &c=Ice::emptyCurrent) override
Definition: Simulator.cpp:2286
armarx::Simulator::activateObject
void activateObject(const std::string &objectName, const Ice::Current &c=Ice::emptyCurrent) override
Definition: Simulator.cpp:1719
armarx::Simulator::initializeData
void initializeData()
Definition: Simulator.cpp:854
armarx::Simulator::fileManager
memoryx::GridFileManagerPtr fileManager
Definition: Simulator.h:477
armarx::Simulator::start
void start(const Ice::Current &c=Ice::emptyCurrent) override
Definition: Simulator.cpp:2230
armarx::Simulator::contactLayerName
std::string contactLayerName
Definition: Simulator.h:486
IceSharedMemoryProvider.h
armarx::Simulator::requestFileManager
memoryx::GridFileManagerPtr requestFileManager()
Definition: Simulator.cpp:953
IceInternal::Handle< SimulatorTimeServerProxy >
armarx::Simulator::simulatorResetEventTopic
SimulatorResetEventPrx simulatorResetEventTopic
Definition: Simulator.h:499
armarx::Simulator::addSnapshot
bool addSnapshot(memoryx::WorkingMemorySnapshotInterfacePrx snapshotInterfacePrx)
Definition: Simulator.cpp:1137
armarx::Simulator::getRobotNodeDistance
DistanceInfo getRobotNodeDistance(const std::string &robotName, const std::string &robotNodeName1, const std::string &robotNodeName2, const Ice::Current &c=Ice::emptyCurrent) override
Definition: Simulator.cpp:2179
armarx::Simulator::removeRobot
bool removeRobot(const std::string &robotName, const Ice::Current &c=Ice::emptyCurrent)
Definition: Simulator.cpp:2612
armarx::Simulator::setRobotPose
void setRobotPose(const std::string &robotName, const PoseBasePtr &globalPose, const Ice::Current &c=Ice::emptyCurrent) override
Definition: Simulator.cpp:1358
armarx::Simulator::getFixedTimeStepMS
int getFixedTimeStepMS(const Ice::Current &c=Ice::emptyCurrent) override
Definition: Simulator.cpp:1725
armarx::ObjectFinder
Used to find objects in the ArmarX objects repository [1] (formerly [2]).
Definition: ObjectFinder.h:22
armarx::Simulator::getRobotJointAngle
float getRobotJointAngle(const std::string &robotName, const std::string &nodeName, const Ice::Current &c=Ice::emptyCurrent) override
Definition: Simulator.cpp:1743
armarx::Simulator::entityDrawerPrx
memoryx::EntityDrawerInterfacePrx entityDrawerPrx
Drawing contacts.
Definition: Simulator.h:483
armarx::Simulator::getTime
Ice::Long getTime(const Ice::Current &c=Ice::emptyCurrent) override
Definition: Simulator.cpp:2316
armarx::Simulator::getRobotNodePose
PoseBasePtr getRobotNodePose(const std::string &robotName, const std::string &robotNodeName, const Ice::Current &c=Ice::emptyCurrent) override
Definition: Simulator.cpp:1817
armarx::SimulatorPropertyDefinitions
Definition: Simulator.h:80
armarx::SimulatorType
SimulatorType
Definition: Simulator.h:69
armarx::Simulator::simulatorThreadRunning
bool simulatorThreadRunning
Definition: Simulator.h:445
armarx::Simulator::currentSimTimeMS
float currentSimTimeMS
Stores the time that was needed to perform the last simulation loop.
Definition: Simulator.h:456
armarx::VariantType::Long
const VariantTypeId Long
Definition: Variant.h:918
armarx::Simulator::setRobotAngularVelocity
void setRobotAngularVelocity(const std::string &robotName, const std::string &robotNodeName, const Vector3BasePtr &vel, const Ice::Current &c=Ice::emptyCurrent) override
Definition: Simulator.cpp:1854
armarx::Simulator::stateFromRobotInfo
SimulatedRobotState stateFromRobotInfo(RobotInfo const &robot, IceUtil::Time timestamp)
Definition: Simulator.cpp:922
armarx::Simulator::getDefaultName
std::string getDefaultName() const override
Retrieve default name of component.
Definition: Simulator.cpp:270
armarx::Simulator::showContacts
void showContacts(bool enable, const std::string &layerName, const Ice::Current &c=Ice::emptyCurrent) override
Definition: Simulator.cpp:2188
filename
std::string filename
Definition: VisualizationRobot.cpp:86
armarx::Simulator::getContacts
ContactInfoSequence getContacts(const Ice::Current &c=Ice::emptyCurrent) override
Returns a list of all contacts. Note that you must call updateContacts() first to enable contacts han...
Definition: Simulator.cpp:2566
armarx::Simulator::getStepTimeMS
Ice::Int getStepTimeMS(const ::Ice::Current &=Ice::emptyCurrent) override
Definition: Simulator.cpp:2310
armarx::Simulator::priorKnowledgePrx
memoryx::PriorKnowledgeInterfacePrx priorKnowledgePrx
Definition: Simulator.h:475
armarx::SimulatorType::Kinematics
@ Kinematics
armarx::Simulator::addScaledRobot
std::string addScaledRobot(const std::string &filename, float scale, const Ice::Current &c=Ice::emptyCurrent) override
Definition: Simulator.cpp:2589
armarx::Simulator::~Simulator
~Simulator() override
Definition: Simulator.cpp:264
armarx::Simulator::simulatorThreadShutdown
bool simulatorThreadShutdown
Definition: Simulator.h:446
armarx::Simulator::memoryPrx
memoryx::WorkingMemoryInterfacePrx memoryPrx
Definition: Simulator.h:474
armarx::Simulator::onDisconnectComponent
void onDisconnectComponent() override
Hook for subclass.
Definition: Simulator.cpp:1042
armarx::Simulator::reportDataTask
PeriodicTask< Simulator >::pointer_type reportDataTask
The report data task.
Definition: Simulator.h:442
armarx::Simulator::removeObject
void removeObject(const std::string &instanceName, const Ice::Current &) override
Definition: Simulator.cpp:1656
armarx::Simulator::getRobotJointVelocity
float getRobotJointVelocity(const std::string &robotName, const std::string &nodeName, const Ice::Current &c=Ice::emptyCurrent) override
Definition: Simulator.cpp:1757
armarx::Simulator::getRobotNames
Ice::StringSeq getRobotNames(const Ice::Current &) override
Definition: Simulator.cpp:1647
armarx::Simulator::setRobotLinearVelocity
void setRobotLinearVelocity(const std::string &robotName, const std::string &robotNodeName, const Vector3BasePtr &vel, const Ice::Current &c=Ice::emptyCurrent) override
Definition: Simulator.cpp:1844
armarx::armem::Time
armarx::core::time::DateTime Time
Definition: forward_declarations.h:13
KinematicsWorld.h
armarx::Simulator::commonStorageName
std::string commonStorageName
Definition: Simulator.h:473
Component.h
armarx::Component
Baseclass for all ArmarX ManagedIceObjects requiring properties.
Definition: Component.h:91
armarx::Simulator::applyTorqueObject
void applyTorqueObject(const std::string &objectName, const Vector3BasePtr &torque, const Ice::Current &c=Ice::emptyCurrent) override
Definition: Simulator.cpp:1404
armarx::RobotInfo
Definition: SimulatedWorld.h:71
armarx::Simulator::simulatorRunningMutex
std::mutex simulatorRunningMutex
Definition: Simulator.h:447
armarx::Simulator::reportRobotPose
bool reportRobotPose
Definition: Simulator.h:466
armarx::Simulator::addRobotFromFile
std::string addRobotFromFile(const armarx::data::PackagePath &packagePath, const Ice::Current &c=Ice::emptyCurrent) override
Definition: Simulator.cpp:2014
SimulatorTimeServerProxy.h
armarx::control::njoint_controller::platform::platform_follower_controller::NameValueMap
std::map< std::string, float > NameValueMap
Definition: PlatformFollowerController.h:88
armarx::Simulator
The Simulator class holds an instance of the AmrarXPhysicsWorld and communicates to ArmarX.
Definition: Simulator.h:118
armarx::Simulator::objectReleased
void objectReleased(const std::string &robotName, const std::string &robotNodeName, const std::string &objectName, const Ice::Current &c=Ice::emptyCurrent) override
remove a joint
Definition: Simulator.cpp:1906
armarx::Component::getConfigIdentifier
std::string getConfigIdentifier()
Retrieve config identifier for this component as set in constructor.
Definition: Component.cpp:79
armarx::Simulator::addObject
void addObject(const memoryx::ObjectClassBasePtr &objectClassBase, const std::string &instanceName, const PoseBasePtr &globalPose, bool isStatic=false, const Ice::Current &c=Ice::emptyCurrent) override
Definition: Simulator.cpp:1413
SimoxObjectWrapper.h
armarx::Simulator::classInstanceMap
std::map< std::string, std::vector< std::string > > classInstanceMap
Stores all instances that belong to a class.
Definition: Simulator.h:491
armarx::SimulatedWorldPtr
std::shared_ptr< SimulatedWorld > SimulatedWorldPtr
Definition: SimulatedWorld.h:523
armarx::Simulator::hasObject
bool hasObject(const std::string &instanceName, const Ice::Current &c=Ice::emptyCurrent) override
Definition: Simulator.cpp:2224
forward_declarations.h
armarx::Simulator::timeTopicPrx
TimeServerListenerPrx timeTopicPrx
Definition: Simulator.h:463
armarx::Simulator::onConnectComponent
void onConnectComponent() override
Pure virtual hook for the subclass.
Definition: Simulator.cpp:981
armarx::Simulator::getRobotJointAngles
NameValueMap getRobotJointAngles(const std::string &robotName, const Ice::Current &c=Ice::emptyCurrent) override
Definition: Simulator.cpp:1737
armarx::ComponentPropertyDefinitions
Default component property definition container.
Definition: Component.h:69
armarx::Simulator::priorKnowledgeName
std::string priorKnowledgeName
Definition: Simulator.h:472
memoryx::GridFileManagerPtr
std::shared_ptr< GridFileManager > GridFileManagerPtr
Definition: AbstractEntityWrapper.h:33
armarx::Simulator::applyTorqueRobotNode
void applyTorqueRobotNode(const std::string &robotName, const std::string &robotNodeName, const Vector3BasePtr &torque, const Ice::Current &c=Ice::emptyCurrent) override
Definition: Simulator.cpp:1385
armarx::Simulator::shutdownSimulationLoop
void shutdownSimulationLoop()
stop the simulation and join the simulation thread
Definition: Simulator.cpp:1087
armarx::Simulator::setRobotMaxTorque
void setRobotMaxTorque(const std::string &robotName, const std::string &nodeName, float maxTorque, const Ice::Current &c=Ice::emptyCurrent) override
Definition: Simulator.cpp:1808
IceUtil::Handle< class PropertyDefinitionContainer >
armarx::Simulator::getRobotJointVelocities
NameValueMap getRobotJointVelocities(const std::string &robotName, const Ice::Current &c=Ice::emptyCurrent) override
Definition: Simulator.cpp:1751
armarx::SimulatorPropertyDefinitions::SimulatorPropertyDefinitions
SimulatorPropertyDefinitions(std::string prefix)
Definition: Simulator.cpp:72
armarx::Simulator::getSimTime
float getSimTime(const Ice::Current &c=Ice::emptyCurrent) override
Definition: Simulator.cpp:1926
armarx::Simulator::setSpeed
void setSpeed(Ice::Float newSpeed, const Ice::Current &c=Ice::emptyCurrent) override
setSpeed sets the scaling factor for the speed of passing of time e.g.
Definition: Simulator.cpp:2298
armarx::Simulator::reInitialize
void reInitialize(const Ice::Current &c=Ice::emptyCurrent) override
reInitialize Re-initializes the scene. Removes all robots and objects (and, in case the scene was loa...
Definition: Simulator.cpp:2215
armarx::VariantType::Int
const VariantTypeId Int
Definition: Variant.h:917
armarx::Simulator::setObjectPose
void setObjectPose(const std::string &objectName, const PoseBasePtr &globalPose, const Ice::Current &c=Ice::emptyCurrent) override
Definition: Simulator.cpp:1686
SimulatedWorld.h
armarx::Simulator::publishContacts
bool publishContacts
Definition: Simulator.h:485
armarx::Simulator::getRobotLinearVelocity
Vector3BasePtr getRobotLinearVelocity(const std::string &robotName, const std::string &nodeName, const Ice::Current &c=Ice::emptyCurrent) override
Definition: Simulator.cpp:1826
armarx::Simulator::getRobotState
SimulatedRobotState getRobotState(const std::string &robotName, const Ice::Current &) override
Definition: Simulator.cpp:2628
armarx::Simulator::getRobotForceTorqueSensors
ForceTorqueDataSeq getRobotForceTorqueSensors(const std::string &robotName, const Ice::Current &c=Ice::emptyCurrent) override
Definition: Simulator.cpp:1771
armarx::Simulator::step
void step(const Ice::Current &c=Ice::emptyCurrent) override
Definition: Simulator.cpp:2322
armarx::Simulator::physicsWorld
SimulatedWorldPtr physicsWorld
Definition: Simulator.h:450
armarx::PropertyDefinitionsPtr
IceUtil::Handle< class PropertyDefinitionContainer > PropertyDefinitionsPtr
PropertyDefinitions smart pointer type.
Definition: forward_declarations.h:35
armarx::Simulator::objectFinder
ObjectFinder objectFinder
Constructed once based on the ObjectPackage property.
Definition: Simulator.h:480
armarx::Simulator::simulatorVisuUpdateListenerPrx
SimulatorListenerInterfacePrx simulatorVisuUpdateListenerPrx
Definition: Simulator.h:468
armarx::Simulator::objectGrasped
void objectGrasped(const std::string &robotName, const std::string &robotNodeName, const std::string &objectName, const Ice::Current &c=Ice::emptyCurrent) override
create a joint
Definition: Simulator.cpp:1916
armarx::Simulator::getRobotJointLimitLo
float getRobotJointLimitLo(const std::string &robotName, const std::string &nodeName, const Ice::Current &c=Ice::emptyCurrent) override
Definition: Simulator.cpp:1777
armarx::Simulator::globalRobotLocalization
GlobalRobotPoseLocalizationListenerPrx globalRobotLocalization
Definition: Simulator.h:465
armarx::Simulator::getScene
SceneVisuData getScene(const Ice::Current &c=Ice::emptyCurrent) override
Definition: Simulator.cpp:1932
armarx
This file offers overloads of toIce() and fromIce() functions for STL container types.
Definition: ArmarXTimeserver.cpp:27
BulletPhysicsWorld.h
armarx::Simulator::currentSyncTimeMS
float currentSyncTimeMS
stores the time that was needed to sync the data
Definition: Simulator.h:458
ObjectFinder.h
armarx::Simulator::simulationLoop
void simulationLoop()
Definition: Simulator.cpp:2125
armarx::Simulator::loadAgentsFromSnapshot
bool loadAgentsFromSnapshot(memoryx::WorkingMemorySnapshotInterfacePrx snapshotInterfacePrx)
Definition: Simulator.cpp:1270
armarx::Simulator::setObjectSimulationType
void setObjectSimulationType(const std::string &objectName, armarx::SimulationType type, const Ice::Current &c=Ice::emptyCurrent) override
Definition: Simulator.cpp:1704
armarx::SimulatorType::Mujoco
@ Mujoco
armarx::Simulator::applyForceRobotNode
void applyForceRobotNode(const std::string &robotName, const std::string &robotNodeName, const Vector3BasePtr &force, const Ice::Current &c=Ice::emptyCurrent) override
Definition: Simulator.cpp:1375
armarx::Simulator::updateContacts
void updateContacts(bool enable, const Ice::Current &c=Ice::emptyCurrent) override
Enables the handling of contacts. If you intend to use getContacts(), call this method with enabled =...
Definition: Simulator.cpp:2583
armarx::Simulator::longtermMemoryPrx
memoryx::LongtermMemoryInterfacePrx longtermMemoryPrx
Definition: Simulator.h:476