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 
43 #include <RobotAPI/interface/core/RobotState.h>
44 #include <MemoryX/interface/components/WorkingMemoryInterface.h>
45 #include <MemoryX/interface/components/LongtermMemoryInterface.h>
46 #include <MemoryX/interface/components/PriorKnowledgeInterface.h>
48 #include <MemoryX/interface/gui/EntityDrawerInterface.h>
49 
52 
53 #include <ArmarXSimulation/interface/simulator/SimulatorInterface.h>
54 
55 #include "BulletPhysicsWorld.h"
56 #include "KinematicsWorld.h"
58 #include "SimulatedWorld.h"
60 
61 
62 #define MAX_INITIAL_ROBOT_COUNT 4
63 
64 
65 namespace armarx
66 {
67 
68  class SimulatorTimeServerProxy;
70 
71  enum class SimulatorType
72  {
73  Kinematics,
74  Bullet,
75  Mujoco
76  };
77 
78  /**
79  * @class SimulatorPropertyDefinitions
80  * @brief
81  */
84  {
85  public:
86 
89 
90  };
91 
92 
93  /**
94  * @brief The Simulator class holds an instance of the AmrarXPhysicsWorld and communicates to ArmarX.
95  *
96  * The following optional parameters can be used.
97  * - RobotFileName<br>
98  * Simox/VirtualRobot robot file name, e.g. robot_model.xml.
99  * - InitialRobotPose.x/y/z/roll/pitch/yaw<br>
100  * The initial pose of the robot
101  * - LogRobot<br>
102  * Default: false, If true, the complete robot state is logged to a file.
103  * - RobotControllerPID.p/i/d<br>
104  * Setup robot controllers: PID paramters
105  * - LongtermMemory.SnapshotName<br>
106  * Name of snapshot to load the scene
107  * - SceneFileName<br>
108  * 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.
109  * - FloorPlane<br>
110  * Indicates if the should be created or not. Default: true.
111  * - FloorTexture<br>
112  * The texture file for the floor. By default, a standard texture is used
113  * - FixedTimeStepLoopNrSteps<br>
114  * 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.
115  * - FixedTimeStepStepTimeMS<br>
116  * The simulation's internal timestep (fixed time step mode)
117  * - ReportVisuFrequency<br>
118  * How often should the visualization data be published. Value is given in Hz. (0 to disable, default: 30)
119  * - ReportVisuTopicName<br>
120  * The topic on which the visualization updates are published. Default: ReportVisuTopicName
121  * - ReportDataFrequency<br>
122  * How often should the robot data be published. Value is given in Hz. (0 to disable, default: 30)
123  */
124  class Simulator :
125  virtual public SimulatorInterface,
126  virtual public Component,
127  virtual protected IceUtil::Thread,
128  virtual public TimeServerInterface
129  {
130  public:
131 
132  Simulator();
133  ~Simulator() override;
134 
135 
136  // inherited from Component
137  std::string getDefaultName() const override;
138 
139  void onInitComponent() override;
140  void onConnectComponent() override;
141  void onDisconnectComponent() override;
142  void onExitComponent() override;
143 
144  // inherited from Thread
145  void run() override;
146 
147  // inherited from TimeServerInterface
148  void stop(const Ice::Current& c = Ice::emptyCurrent) override;
149 
150  /**
151  * @brief setSpeed sets the scaling factor for the speed of passing of time
152  * e.g. setSpeed(2) leads to 2 virtual seconds passing every 1 real second
153  * (provided the simulation is able to keep up)
154  * @param newSpeed new scaling factor for speed
155  */
156  void setSpeed(Ice::Float newSpeed, const Ice::Current& c = Ice::emptyCurrent) override;
157  Ice::Float getSpeed(const Ice::Current& c = Ice::emptyCurrent) override;
158  Ice::Long getTime(const Ice::Current& c = Ice::emptyCurrent) override;
159  Ice::Int getStepTimeMS(const ::Ice::Current& = Ice::emptyCurrent) override;
160 
161  // inherited from SimulatorDataInterface
162  void actuateRobotJoints(const std::string& robotName, const NameValueMap& angles, const NameValueMap& velocities, const Ice::Current& c = Ice::emptyCurrent) override;
163  void actuateRobotJointsPos(const std::string& robotName, const NameValueMap& angles, const Ice::Current& c = Ice::emptyCurrent) override;
164  void actuateRobotJointsVel(const std::string& robotName, const NameValueMap& velocities, const Ice::Current& c = Ice::emptyCurrent) override;
165  void actuateRobotJointsTorque(const std::string& robotName, const NameValueMap& torques, const Ice::Current& c = Ice::emptyCurrent) override;
166  void setRobotPose(const std::string& robotName, const PoseBasePtr& globalPose, const Ice::Current& c = Ice::emptyCurrent) override;
167 
168  void applyForceRobotNode(const std::string& robotName, const std::string& robotNodeName, const Vector3BasePtr& force, const Ice::Current& c = Ice::emptyCurrent) override;
169  void applyTorqueRobotNode(const std::string& robotName, const std::string& robotNodeName, const Vector3BasePtr& torque, const Ice::Current& c = Ice::emptyCurrent) override;
170 
171  void applyForceObject(const std::string& objectName, const Vector3BasePtr& force, const Ice::Current& c = Ice::emptyCurrent) override;
172  void applyTorqueObject(const std::string& objectName, const Vector3BasePtr& torque, const Ice::Current& c = Ice::emptyCurrent) override;
173 
174  // "old api => should be removed"
175  std::string addRobot(const std::string& filename, const Ice::Current& c = Ice::emptyCurrent) override;
176  std::string addScaledRobot(const std::string& filename, float scale, const Ice::Current& c = Ice::emptyCurrent) override;
177  std::string addScaledRobotName(const std::string& instanceName, const std::string& filename, float scale, const Ice::Current& c = Ice::emptyCurrent) override;
178  bool removeRobot(const std::string& robotName, const Ice::Current& c = Ice::emptyCurrent);
179  void addObject(const memoryx::ObjectClassBasePtr& objectClassBase, const std::string& instanceName, const PoseBasePtr& globalPose, bool isStatic = false, const Ice::Current& c = Ice::emptyCurrent) override;
180 
181  // "new api" =>
182  std::string addRobotFromFile(const armarx::data::PackagePath& packagePath, const Ice::Current& c = Ice::emptyCurrent) override;
183  void addObjectFromFile(const armarx::data::PackagePath& packagePath, const std::string& instanceName, const PoseBasePtr& globalPose, bool isStatic = false, const Ice::Current& c = Ice::emptyCurrent) override;
184 
185 
186  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;
187 
188  Ice::StringSeq getRobotNames(const Ice::Current&) override;
189  void removeObject(const std::string& instanceName, const Ice::Current&) override;
190 
191  bool hasObject(const std::string& instanceName, const Ice::Current& c = Ice::emptyCurrent) override;
192  void setObjectPose(const std::string& objectName, const PoseBasePtr& globalPose, const Ice::Current& c = Ice::emptyCurrent) override;
193  void setObjectSimulationType(const std::string& objectName, armarx::SimulationType type, const Ice::Current& c = Ice::emptyCurrent) override;
194  void activateObject(const std::string& objectName, const Ice::Current& c = Ice::emptyCurrent) override;
195 
196  bool hasRobot(const std::string& robotName, const Ice::Current& c = Ice::emptyCurrent) override;
197  bool hasRobotNode(const std::string& robotName, const std::string& robotNodeName, const Ice::Current& c = Ice::emptyCurrent) override;
198  float getRobotMass(const std::string& robotName, const Ice::Current& c = Ice::emptyCurrent) override;
199 
200  NameValueMap getRobotJointAngles(const std::string& robotName, const Ice::Current& c = Ice::emptyCurrent) override;
201  float getRobotJointAngle(const std::string& robotName, const std::string& nodeName, const Ice::Current& c = Ice::emptyCurrent) override;
202  NameValueMap getRobotJointVelocities(const std::string& robotName, const Ice::Current& c = Ice::emptyCurrent) override;
203  float getRobotJointVelocity(const std::string& robotName, const std::string& nodeName, const Ice::Current& c = Ice::emptyCurrent) override;
204  NameValueMap getRobotJointTorques(const std::string& robotName, const Ice::Current& c = Ice::emptyCurrent) override;
205  ForceTorqueDataSeq getRobotForceTorqueSensors(const std::string& robotName, const Ice::Current& c = Ice::emptyCurrent) override;
206 
207  float getRobotJointLimitLo(const std::string& robotName, const std::string& nodeName, const Ice::Current& c = Ice::emptyCurrent) override;
208  float getRobotJointLimitHi(const std::string& robotName, const std::string& nodeName, const Ice::Current& c = Ice::emptyCurrent) override;
209  PoseBasePtr getRobotPose(const std::string& robotName, const Ice::Current& c = Ice::emptyCurrent) override;
210  SimulatedRobotState getRobotState(const std::string& robotName, const Ice::Current&) override;
211 
212  float getRobotMaxTorque(const std::string& robotName, const std::string& nodeName, const Ice::Current& c = Ice::emptyCurrent) override;
213  void setRobotMaxTorque(const std::string& robotName, const std::string& nodeName, float maxTorque, const Ice::Current& c = Ice::emptyCurrent) override;
214 
215  PoseBasePtr getRobotNodePose(const std::string& robotName, const std::string& robotNodeName, const Ice::Current& c = Ice::emptyCurrent) override;
216 
217  Vector3BasePtr getRobotLinearVelocity(const std::string& robotName, const std::string& nodeName, const Ice::Current& c = Ice::emptyCurrent) override;
218  Vector3BasePtr getRobotAngularVelocity(const std::string& robotName, const std::string& nodeName, const Ice::Current& c = Ice::emptyCurrent) override;
219 
220  void setRobotLinearVelocity(const std::string& robotName, const std::string& robotNodeName, const Vector3BasePtr& vel, const Ice::Current& c = Ice::emptyCurrent) override;
221  void setRobotAngularVelocity(const std::string& robotName, const std::string& robotNodeName, const Vector3BasePtr& vel, const Ice::Current& c = Ice::emptyCurrent) override;
222  void setRobotLinearVelocityRobotRootFrame(const std::string& robotName, const std::string& robotNodeName, const Vector3BasePtr& vel, const Ice::Current& c = Ice::emptyCurrent) override;
223  void setRobotAngularVelocityRobotRootFrame(const std::string& robotName, const std::string& robotNodeName, const Vector3BasePtr& vel, const Ice::Current& c = Ice::emptyCurrent) override;
224 
225  //! create a joint
226  void objectGrasped(const std::string& robotName, const std::string& robotNodeName, const std::string& objectName, const Ice::Current& c = Ice::emptyCurrent) override;
227 
228  //! remove a joint
229  void objectReleased(const std::string& robotName, const std::string& robotNodeName, const std::string& objectName, const Ice::Current& c = Ice::emptyCurrent) override;
230 
231  PoseBasePtr getObjectPose(const std::string& objectName, const Ice::Current& c = Ice::emptyCurrent) override;
232 
233  DistanceInfo getDistance(const std::string& robotName, const std::string& robotNodeName, const std::string& worldObjectName, const Ice::Current& c = Ice::emptyCurrent) override;
234  DistanceInfo getRobotNodeDistance(const std::string& robotName, const std::string& robotNodeName1, const std::string& robotNodeName2, const Ice::Current& c = Ice::emptyCurrent) override;
235  void showContacts(bool enable, const std::string& layerName, const Ice::Current& c = Ice::emptyCurrent) override;
236 
237  /*!
238  * \brief Returns a list of all contacts. Note that you must call updateContacts() first to enable
239  * contacts handling.
240  */
241  ContactInfoSequence getContacts(const Ice::Current& c = Ice::emptyCurrent) override;
242 
243  /*!
244  * \brief Enables the handling of contacts. If you intend to use getContacts(), call this method
245  * with enabled = true first.
246  */
247  void updateContacts(bool enable, const Ice::Current& c = Ice::emptyCurrent) override;
248 
249  ObjectClassInformationSequence getObjectClassPoses(
250  const std::string& robotName, const std::string& frameName, const std::string& className,
251  const Ice::Current& c = Ice::emptyCurrent) override;
252 
253 
254  /*!
255  * \brief reInitialize Re-initializes the scene.
256  * Removes all robots and objects (and, in case the scene was loaded via a MemoryX snapshot, the working memory is cleared)
257  * Then, the setup is re-loaded similar to the startup procedure.
258  */
259  void reInitialize(const Ice::Current& c = Ice::emptyCurrent) override;
260 
261 
262  float getSimTime(const Ice::Current& c = Ice::emptyCurrent) override;
263 
264 
265  SceneVisuData getScene(const Ice::Current& c = Ice::emptyCurrent) override;
266  SimulatorInformation getSimulatorInformation(const ::Ice::Current& = Ice::emptyCurrent) override;
267 
268  /*!
269  * \brief
270  * \return The number of steps * the timestep in MS
271  */
272  int getFixedTimeStepMS(const Ice::Current& c = Ice::emptyCurrent) override;
273 
274  void start(const Ice::Current& c = Ice::emptyCurrent) override;
275  void pause(const Ice::Current& c = Ice::emptyCurrent) override;
276  void step(const Ice::Current& c = Ice::emptyCurrent) override;
277  bool isRunning(const Ice::Current& c = Ice::emptyCurrent) override;
278 
279  bool addSnapshot(memoryx::WorkingMemorySnapshotInterfacePrx snapshotInterfacePrx);
280  bool loadAgentsFromSnapshot(memoryx::WorkingMemorySnapshotInterfacePrx snapshotInterfacePrx);
281 
282  /**
283  * @see PropertyUser::createPropertyDefinitions()
284  */
286  {
289  }
290 
291 
292  protected:
293 
294  void simulationLoop();
295  void reportVisuLoop();
296  void reportDataLoop();
297  /**
298  * @brief stop the simulation and join the simulation thread
299  */
300  void shutdownSimulationLoop();
301 
302  /*!
303  * \brief resetData Clears all data
304  * \param clearWorkingMemory If set, the working memory is also cleared.
305  */
306  void resetData(bool clearWorkingMemory = false);
307 
308  void initializeData();
309 
310  SimulatedRobotState stateFromRobotInfo(RobotInfo const& robot, IceUtil::Time timestamp);
311 
312  /// Returns the name. On failure an empty string is returned.
313  std::string addRobot(std::string robotInstanceName, const std::string& robFileGlobal, Eigen::Matrix4f gp, const std::string& robFile, double pid_p = 10.0, double pid_i = 0.0, double pid_d = 0.0, bool isStatic = false, float scaling = 1, bool colModel = false, std::map<std::string, float> initConfig = std::map<std::string, float>(), bool selfCollisions = false);
314  bool updateRobotTopics();
315 
317 
318 
319  protected:
320 
321  /// The sim task
323  /// The report visu task
325  /// The report data task
327 
328  // simulator thread control
332  std::condition_variable condSimulatorThreadRunning;
333 
335 
336 
337  /// Stores the time that was needed for communictaion
338  float currentComTimeMS = 0;
339  /// Stores the time that was needed to perform the last simulation loop
340  float currentSimTimeMS = 0;
341  /// stores the time that was needed to sync the data
342  float currentSyncTimeMS = 0;
343 
344  /// Scaling factor for the passing of time
345  float timeServerSpeed = 0;
346 
347  TimeServerListenerPrx timeTopicPrx;
348 
349  GlobalRobotPoseLocalizationListenerPrx globalRobotLocalization;
350  bool reportRobotPose = false;
351 
352  SimulatorListenerInterfacePrx simulatorVisuUpdateListenerPrx;
353 
354  std::atomic<float> reportVisuTimeMS = 0;
355 
356  std::string priorKnowledgeName;
357  std::string commonStorageName;
358  memoryx::WorkingMemoryInterfacePrx memoryPrx;
359  memoryx::PriorKnowledgeInterfacePrx priorKnowledgePrx;
360  memoryx::LongtermMemoryInterfacePrx longtermMemoryPrx;
362 
363  /// Constructed once based on the `ObjectPackage` property
365 
366  /// Drawing contacts
367  memoryx::EntityDrawerInterfacePrx entityDrawerPrx;
368 
369  bool publishContacts = false;
370  std::string contactLayerName;
371 
373 
374  /// Stores all instances that belong to a class
375  std::map< std::string, std::vector< std::string > > classInstanceMap;
376 
377  /**
378  * Proxy object to offer the Timeserver proxy
379  *
380  * This is a hack to allow offering the proxies "Simulator" and "MasterTimeServer" at once
381  */
383  SimulatorResetEventPrx simulatorResetEventTopic;
384 
385 
386  private:
387 
388  void addRobotsFromProperties();
389  void addSceneFromFile(const std::string& sceneFile);
390  void addSceneFromMemorySnapshot(const std::string& snapshotName);
391 
392  /**
393  * Add a scene defined in the ArmarX JSON format to the simulation.
394  */
395  void addSceneFromJsonFile(const std::string& scenePath);
396 
397  /**
398  * Add a scene defined in the SDF format to the simulation.
399  */
400  void addSceneFromSdfFile(const std::string& scenePath);
401 
402  /**
403  * Add one object from an ArmarX JSON scene to the simulation.
404  */
405  void addJsonSceneObject(const armarx::objects::SceneObject object,
406  std::map<ObjectID, int>& idCounters);
407 
408  void fixateRobotNode(const std::string& robotName, const std::string& robotNodeName);
409  void fixateObject(const std::string& objectName);
410 
411  };
412 
414 }
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:1515
armarx::Simulator::onExitComponent
void onExitComponent() override
Hook for subclass.
Definition: Simulator.cpp:1014
armarx::Simulator::Simulator
Simulator()
Definition: Simulator.cpp:235
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:1816
armarx::Simulator::reportDataLoop
void reportDataLoop()
Definition: Simulator.cpp:2460
armarx::Simulator::reportVisuTask
PeriodicTask< Simulator >::pointer_type reportVisuTask
The report visu task.
Definition: Simulator.h:324
armarx::Simulator::getObjectPose
PoseBasePtr getObjectPose(const std::string &objectName, const Ice::Current &c=Ice::emptyCurrent) override
Definition: Simulator.cpp:1851
armarx::Simulator::reportVisuLoop
void reportVisuLoop()
Definition: Simulator.cpp:2317
armarx::VariantType::Float
const VariantTypeId Float
Definition: Variant.h:918
armarx::Simulator::timeserverProxy
SimulatorTimeServerProxyPtr timeserverProxy
Proxy object to offer the Timeserver proxy.
Definition: Simulator.h:382
armarx::Simulator::stop
void stop(const Ice::Current &c=Ice::emptyCurrent) override
Definition: Simulator.cpp:2244
armarx::Simulator::lastPublishedContacts
int lastPublishedContacts
Definition: Simulator.h:372
armarx::Simulator::actuateRobotJointsTorque
void actuateRobotJointsTorque(const std::string &robotName, const NameValueMap &torques, const Ice::Current &c=Ice::emptyCurrent) override
Definition: Simulator.cpp:1302
armarx::Simulator::addRobot
std::string addRobot(const std::string &filename, const Ice::Current &c=Ice::emptyCurrent) override
Definition: Simulator.cpp:2570
armarx::Simulator::onInitComponent
void onInitComponent() override
Pure virtual hook for the subclass.
Definition: Simulator.cpp:264
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:1826
armarx::Simulator::classInstanceMap
std::map< std::string, std::vector< std::string > > classInstanceMap
Stores all instances that belong to a class.
Definition: Simulator.h:375
armarx::Simulator::getRobotPose
PoseBasePtr getRobotPose(const std::string &robotName, const Ice::Current &c=Ice::emptyCurrent) override
Definition: Simulator.cpp:1745
armarx::Simulator::getRobotAngularVelocity
Vector3BasePtr getRobotAngularVelocity(const std::string &robotName, const std::string &nodeName, const Ice::Current &c=Ice::emptyCurrent) override
Definition: Simulator.cpp:1787
armarx::Simulator::applyForceObject
void applyForceObject(const std::string &objectName, const Vector3BasePtr &force, const Ice::Current &c=Ice::emptyCurrent) override
Definition: Simulator.cpp:1347
armarx::Simulator::run
void run() override
Definition: Simulator.cpp:2200
Pose.h
armarx::Simulator::condSimulatorThreadRunning
std::condition_variable condSimulatorThreadRunning
Definition: Simulator.h:332
armarx::Simulator::hasRobotNode
bool hasRobotNode(const std::string &robotName, const std::string &robotNodeName, const Ice::Current &c=Ice::emptyCurrent) override
Definition: Simulator.cpp:1842
armarx::Simulator::getRobotMaxTorque
float getRobotMaxTorque(const std::string &robotName, const std::string &nodeName, const Ice::Current &c=Ice::emptyCurrent) override
Definition: Simulator.cpp:1752
armarx::Simulator::getSimulatorInformation
SimulatorInformation getSimulatorInformation(const ::Ice::Current &=Ice::emptyCurrent) override
Definition: Simulator.cpp:1893
Properties.h
armarx::SimulatorPropertyDefinitions::~SimulatorPropertyDefinitions
~SimulatorPropertyDefinitions() override
Definition: Simulator.cpp:231
armarx::Simulator::simulationTask
PeriodicTask< Simulator >::pointer_type simulationTask
The sim task.
Definition: Simulator.h:322
armarx::Simulator::getSpeed
Ice::Float getSpeed(const Ice::Current &c=Ice::emptyCurrent) override
Definition: Simulator.cpp:2256
armarx::PropertyDefinitionContainer::prefix
std::string prefix
Prefix of the properties such as namespace, domain, component name, etc.
Definition: PropertyDefinitionContainer.h:333
GridFileManager.h
armarx::Simulator::getRobotJointTorques
NameValueMap getRobotJointTorques(const std::string &robotName, const Ice::Current &c=Ice::emptyCurrent) override
Definition: Simulator.cpp:1717
PeriodicTask.h
armarx::Simulator::timeServerSpeed
float timeServerSpeed
Scaling factor for the passing of time.
Definition: Simulator.h:345
armarx::Simulator::currentComTimeMS
float currentComTimeMS
Stores the time that was needed for communictaion.
Definition: Simulator.h:338
armarx::SimulatorType::Bullet
@ Bullet
armarx::Simulator::reportVisuTimeMS
std::atomic< float > reportVisuTimeMS
Definition: Simulator.h:354
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:1442
c
constexpr T c
Definition: UnscentedKalmanFilterTest.cpp:43
armarx::Simulator::getRobotMass
float getRobotMass(const std::string &robotName, const Ice::Current &c=Ice::emptyCurrent) override
Definition: Simulator.cpp:1683
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:2551
armarx::Simulator::resetData
void resetData(bool clearWorkingMemory=false)
resetData Clears all data
Definition: Simulator.cpp:1058
ObjectClass.h
armarx::Simulator::isRunning
bool isRunning(const Ice::Current &c=Ice::emptyCurrent) override
Definition: Simulator.cpp:2311
armarx::Simulator::actuateRobotJointsPos
void actuateRobotJointsPos(const std::string &robotName, const NameValueMap &angles, const Ice::Current &c=Ice::emptyCurrent) override
Definition: Simulator.cpp:1286
armarx::objects::SceneObject
Definition: Scene.h:38
armarx::Simulator::updateRobotTopics
bool updateRobotTopics()
Definition: Simulator.cpp:2036
armarx::Simulator::actuateRobotJointsVel
void actuateRobotJointsVel(const std::string &robotName, const NameValueMap &velocities, const Ice::Current &c=Ice::emptyCurrent) override
Definition: Simulator.cpp:1294
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:1277
armarx::Simulator::hasRobot
bool hasRobot(const std::string &robotName, const Ice::Current &c=Ice::emptyCurrent) override
Definition: Simulator.cpp:1836
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:2122
armarx::Simulator::getRobotJointLimitHi
float getRobotJointLimitHi(const std::string &robotName, const std::string &nodeName, const Ice::Current &c=Ice::emptyCurrent) override
Definition: Simulator.cpp:1737
armarx::Simulator::createPropertyDefinitions
PropertyDefinitionsPtr createPropertyDefinitions() override
Definition: Simulator.h:285
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:2083
armarx::Simulator::pause
void pause(const Ice::Current &c=Ice::emptyCurrent) override
Definition: Simulator.cpp:2238
armarx::Simulator::activateObject
void activateObject(const std::string &objectName, const Ice::Current &c=Ice::emptyCurrent) override
Definition: Simulator.cpp:1671
armarx::Simulator::initializeData
void initializeData()
Definition: Simulator.cpp:806
armarx::Simulator::fileManager
memoryx::GridFileManagerPtr fileManager
Definition: Simulator.h:361
armarx::Simulator::start
void start(const Ice::Current &c=Ice::emptyCurrent) override
Definition: Simulator.cpp:2182
armarx::Simulator::contactLayerName
std::string contactLayerName
Definition: Simulator.h:370
IceSharedMemoryProvider.h
armarx::Simulator::requestFileManager
memoryx::GridFileManagerPtr requestFileManager()
Definition: Simulator.cpp:905
IceInternal::Handle< SimulatorTimeServerProxy >
armarx::Simulator::simulatorResetEventTopic
SimulatorResetEventPrx simulatorResetEventTopic
Definition: Simulator.h:383
armarx::Simulator::addSnapshot
bool addSnapshot(memoryx::WorkingMemorySnapshotInterfacePrx snapshotInterfacePrx)
Definition: Simulator.cpp:1089
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:2131
armarx::Simulator::removeRobot
bool removeRobot(const std::string &robotName, const Ice::Current &c=Ice::emptyCurrent)
Definition: Simulator.cpp:2564
armarx::Simulator::setRobotPose
void setRobotPose(const std::string &robotName, const PoseBasePtr &globalPose, const Ice::Current &c=Ice::emptyCurrent) override
Definition: Simulator.cpp:1310
armarx::Simulator::getFixedTimeStepMS
int getFixedTimeStepMS(const Ice::Current &c=Ice::emptyCurrent) override
Definition: Simulator.cpp:1677
armarx::ObjectFinder
Used to find objects in the ArmarX objects repository [1] (formerly [2]).
Definition: ObjectFinder.h:23
armarx::Simulator::getRobotJointAngle
float getRobotJointAngle(const std::string &robotName, const std::string &nodeName, const Ice::Current &c=Ice::emptyCurrent) override
Definition: Simulator.cpp:1695
armarx::Simulator::entityDrawerPrx
memoryx::EntityDrawerInterfacePrx entityDrawerPrx
Drawing contacts.
Definition: Simulator.h:367
armarx::Simulator::getTime
Ice::Long getTime(const Ice::Current &c=Ice::emptyCurrent) override
Definition: Simulator.cpp:2268
armarx::Simulator::getRobotNodePose
PoseBasePtr getRobotNodePose(const std::string &robotName, const std::string &robotNodeName, const Ice::Current &c=Ice::emptyCurrent) override
Definition: Simulator.cpp:1769
armarx::SimulatorPropertyDefinitions
Definition: Simulator.h:82
armarx::SimulatorType
SimulatorType
Definition: Simulator.h:71
armarx::Simulator::simulatorThreadRunning
bool simulatorThreadRunning
Definition: Simulator.h:329
armarx::Simulator::currentSimTimeMS
float currentSimTimeMS
Stores the time that was needed to perform the last simulation loop.
Definition: Simulator.h:340
armarx::VariantType::Long
const VariantTypeId Long
Definition: Variant.h:917
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:1806
armarx::Simulator::stateFromRobotInfo
SimulatedRobotState stateFromRobotInfo(RobotInfo const &robot, IceUtil::Time timestamp)
Definition: Simulator.cpp:874
armarx::Simulator::getDefaultName
std::string getDefaultName() const override
Retrieve default name of component.
Definition: Simulator.cpp:258
armarx::Simulator::showContacts
void showContacts(bool enable, const std::string &layerName, const Ice::Current &c=Ice::emptyCurrent) override
Definition: Simulator.cpp:2140
filename
std::string filename
Definition: VisualizationRobot.cpp:83
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:2518
armarx::Simulator::getStepTimeMS
Ice::Int getStepTimeMS(const ::Ice::Current &=Ice::emptyCurrent) override
Definition: Simulator.cpp:2262
armarx::Simulator::priorKnowledgePrx
memoryx::PriorKnowledgeInterfacePrx priorKnowledgePrx
Definition: Simulator.h:359
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:2541
armarx::Simulator::~Simulator
~Simulator() override
Definition: Simulator.cpp:252
armarx::Simulator::simulatorThreadShutdown
bool simulatorThreadShutdown
Definition: Simulator.h:330
armarx::Simulator::memoryPrx
memoryx::WorkingMemoryInterfacePrx memoryPrx
Definition: Simulator.h:358
armarx::Simulator::onDisconnectComponent
void onDisconnectComponent() override
Hook for subclass.
Definition: Simulator.cpp:994
armarx::Simulator::reportDataTask
PeriodicTask< Simulator >::pointer_type reportDataTask
The report data task.
Definition: Simulator.h:326
armarx::Simulator::removeObject
void removeObject(const std::string &instanceName, const Ice::Current &) override
Definition: Simulator.cpp:1608
armarx::Simulator::getRobotJointVelocity
float getRobotJointVelocity(const std::string &robotName, const std::string &nodeName, const Ice::Current &c=Ice::emptyCurrent) override
Definition: Simulator.cpp:1709
armarx::Simulator::getRobotNames
Ice::StringSeq getRobotNames(const Ice::Current &) override
Definition: Simulator.cpp:1599
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:1796
armarx::armem::Time
armarx::core::time::DateTime Time
Definition: forward_declarations.h:13
KinematicsWorld.h
armarx::Simulator::commonStorageName
std::string commonStorageName
Definition: Simulator.h:357
Component.h
armarx::Component
Baseclass for all ArmarX ManagedIceObjects requiring properties.
Definition: Component.h:95
armarx::Simulator::applyTorqueObject
void applyTorqueObject(const std::string &objectName, const Vector3BasePtr &torque, const Ice::Current &c=Ice::emptyCurrent) override
Definition: Simulator.cpp:1356
armarx::RobotInfo
Definition: SimulatedWorld.h:70
armarx::Simulator::simulatorRunningMutex
std::mutex simulatorRunningMutex
Definition: Simulator.h:331
armarx::Simulator::reportRobotPose
bool reportRobotPose
Definition: Simulator.h:350
armarx::Simulator::addRobotFromFile
std::string addRobotFromFile(const armarx::data::PackagePath &packagePath, const Ice::Current &c=Ice::emptyCurrent) override
Definition: Simulator.cpp:1966
SimulatorTimeServerProxy.h
armarx::control::njoint_controller::platform::platform_follower_controller::NameValueMap
std::map< std::string, float > NameValueMap
Definition: PlatformFollowerController.h:91
armarx::Simulator
The Simulator class holds an instance of the AmrarXPhysicsWorld and communicates to ArmarX.
Definition: Simulator.h:124
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:1858
armarx::Component::getConfigIdentifier
std::string getConfigIdentifier()
Retrieve config identifier for this component as set in constructor.
Definition: Component.cpp:74
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:1365
SimoxObjectWrapper.h
armarx::SimulatedWorldPtr
std::shared_ptr< SimulatedWorld > SimulatedWorldPtr
Definition: SimulatedWorld.h:471
armarx::Simulator::hasObject
bool hasObject(const std::string &instanceName, const Ice::Current &c=Ice::emptyCurrent) override
Definition: Simulator.cpp:2176
forward_declarations.h
armarx::Simulator::timeTopicPrx
TimeServerListenerPrx timeTopicPrx
Definition: Simulator.h:347
armarx::Simulator::onConnectComponent
void onConnectComponent() override
Pure virtual hook for the subclass.
Definition: Simulator.cpp:933
GfxTL::Matrix4f
MatrixXX< 4, 4, float > Matrix4f
Definition: MatrixXX.h:601
armarx::Simulator::getRobotJointAngles
NameValueMap getRobotJointAngles(const std::string &robotName, const Ice::Current &c=Ice::emptyCurrent) override
Definition: Simulator.cpp:1689
armarx::ComponentPropertyDefinitions
Default component property definition container.
Definition: Component.h:70
armarx::Simulator::priorKnowledgeName
std::string priorKnowledgeName
Definition: Simulator.h:356
memoryx::GridFileManagerPtr
std::shared_ptr< GridFileManager > GridFileManagerPtr
Definition: AbstractEntityWrapper.h:32
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:1337
armarx::Simulator::shutdownSimulationLoop
void shutdownSimulationLoop()
stop the simulation and join the simulation thread
Definition: Simulator.cpp:1039
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:1760
IceUtil::Handle< class PropertyDefinitionContainer >
armarx::Simulator::getRobotJointVelocities
NameValueMap getRobotJointVelocities(const std::string &robotName, const Ice::Current &c=Ice::emptyCurrent) override
Definition: Simulator.cpp:1703
armarx::SimulatorPropertyDefinitions::SimulatorPropertyDefinitions
SimulatorPropertyDefinitions(std::string prefix)
Definition: Simulator.cpp:66
armarx::Simulator::getSimTime
float getSimTime(const Ice::Current &c=Ice::emptyCurrent) override
Definition: Simulator.cpp:1878
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:2250
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:2167
armarx::VariantType::Int
const VariantTypeId Int
Definition: Variant.h:916
armarx::Simulator::setObjectPose
void setObjectPose(const std::string &objectName, const PoseBasePtr &globalPose, const Ice::Current &c=Ice::emptyCurrent) override
Definition: Simulator.cpp:1638
SimulatedWorld.h
armarx::Simulator::publishContacts
bool publishContacts
Definition: Simulator.h:369
armarx::Simulator::getRobotLinearVelocity
Vector3BasePtr getRobotLinearVelocity(const std::string &robotName, const std::string &nodeName, const Ice::Current &c=Ice::emptyCurrent) override
Definition: Simulator.cpp:1778
armarx::Simulator::getRobotState
SimulatedRobotState getRobotState(const std::string &robotName, const Ice::Current &) override
Definition: Simulator.cpp:2580
armarx::Simulator::getRobotForceTorqueSensors
ForceTorqueDataSeq getRobotForceTorqueSensors(const std::string &robotName, const Ice::Current &c=Ice::emptyCurrent) override
Definition: Simulator.cpp:1723
armarx::Simulator::step
void step(const Ice::Current &c=Ice::emptyCurrent) override
Definition: Simulator.cpp:2274
armarx::Simulator::physicsWorld
SimulatedWorldPtr physicsWorld
Definition: Simulator.h:334
armarx::PropertyDefinitionsPtr
IceUtil::Handle< class PropertyDefinitionContainer > PropertyDefinitionsPtr
PropertyDefinitions smart pointer type.
Definition: forward_declarations.h:34
armarx::Simulator::objectFinder
ObjectFinder objectFinder
Constructed once based on the ObjectPackage property.
Definition: Simulator.h:364
armarx::Simulator::simulatorVisuUpdateListenerPrx
SimulatorListenerInterfacePrx simulatorVisuUpdateListenerPrx
Definition: Simulator.h:352
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:1868
armarx::Simulator::getRobotJointLimitLo
float getRobotJointLimitLo(const std::string &robotName, const std::string &nodeName, const Ice::Current &c=Ice::emptyCurrent) override
Definition: Simulator.cpp:1729
armarx::Simulator::globalRobotLocalization
GlobalRobotPoseLocalizationListenerPrx globalRobotLocalization
Definition: Simulator.h:349
armarx::Simulator::getScene
SceneVisuData getScene(const Ice::Current &c=Ice::emptyCurrent) override
Definition: Simulator.cpp:1884
armarx
This file offers overloads of toIce() and fromIce() functions for STL container types.
Definition: ArmarXTimeserver.cpp:28
BulletPhysicsWorld.h
armarx::Simulator::currentSyncTimeMS
float currentSyncTimeMS
stores the time that was needed to sync the data
Definition: Simulator.h:342
ObjectFinder.h
armarx::Simulator::simulationLoop
void simulationLoop()
Definition: Simulator.cpp:2077
armarx::Simulator::loadAgentsFromSnapshot
bool loadAgentsFromSnapshot(memoryx::WorkingMemorySnapshotInterfacePrx snapshotInterfacePrx)
Definition: Simulator.cpp:1222
armarx::Simulator::setObjectSimulationType
void setObjectSimulationType(const std::string &objectName, armarx::SimulationType type, const Ice::Current &c=Ice::emptyCurrent) override
Definition: Simulator.cpp:1656
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:1327
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:2535
armarx::Simulator::longtermMemoryPrx
memoryx::LongtermMemoryInterfacePrx longtermMemoryPrx
Definition: Simulator.h:360