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
63namespace armarx
64{
65
66 class SimulatorTimeServerProxy;
68
75
76 /**
77 * @class SimulatorPropertyDefinitions
78 * @brief
79 */
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 static std::string GetDefaultName();
131 std::string getDefaultName() const override;
132
133 void onInitComponent() override;
134 void onConnectComponent() override;
135 void onDisconnectComponent() override;
136 void onExitComponent() override;
137
138 // inherited from Thread
139 void run() override;
140
141 // inherited from TimeServerInterface
142 void stop(const Ice::Current& c = Ice::emptyCurrent) override;
143
144 /**
145 * @brief setSpeed sets the scaling factor for the speed of passing of time
146 * e.g. setSpeed(2) leads to 2 virtual seconds passing every 1 real second
147 * (provided the simulation is able to keep up)
148 * @param newSpeed new scaling factor for speed
149 */
150 void setSpeed(Ice::Float newSpeed, const Ice::Current& c = Ice::emptyCurrent) override;
151 Ice::Float getSpeed(const Ice::Current& c = Ice::emptyCurrent) override;
152 Ice::Long getTime(const Ice::Current& c = Ice::emptyCurrent) override;
153 Ice::Int getStepTimeMS(const ::Ice::Current& = Ice::emptyCurrent) override;
154
155 // inherited from SimulatorDataInterface
156 void actuateRobotJoints(const std::string& robotName,
157 const NameValueMap& angles,
158 const NameValueMap& velocities,
159 const Ice::Current& c = Ice::emptyCurrent) override;
160 void actuateRobotJointsPos(const std::string& robotName,
161 const NameValueMap& angles,
162 const Ice::Current& c = Ice::emptyCurrent) override;
163 void actuateRobotJointsVel(const std::string& robotName,
164 const NameValueMap& velocities,
165 const Ice::Current& c = Ice::emptyCurrent) override;
166 void actuateRobotJointsTorque(const std::string& robotName,
167 const NameValueMap& torques,
168 const Ice::Current& c = Ice::emptyCurrent) override;
169 void setRobotPose(const std::string& robotName,
170 const PoseBasePtr& globalPose,
171 const Ice::Current& c = Ice::emptyCurrent) override;
172
173 void applyForceRobotNode(const std::string& robotName,
174 const std::string& robotNodeName,
175 const Vector3BasePtr& force,
176 const Ice::Current& c = Ice::emptyCurrent) override;
177 void applyTorqueRobotNode(const std::string& robotName,
178 const std::string& robotNodeName,
179 const Vector3BasePtr& torque,
180 const Ice::Current& c = Ice::emptyCurrent) override;
181
182 void applyForceObject(const std::string& objectName,
183 const Vector3BasePtr& force,
184 const Ice::Current& c = Ice::emptyCurrent) override;
185 void applyTorqueObject(const std::string& objectName,
186 const Vector3BasePtr& torque,
187 const Ice::Current& c = Ice::emptyCurrent) override;
188
189 // "old api => should be removed"
190 std::string addRobot(const std::string& filename,
191 const Ice::Current& c = Ice::emptyCurrent) override;
192 std::string addScaledRobot(const std::string& filename,
193 float scale,
194 const Ice::Current& c = Ice::emptyCurrent) override;
195 std::string addScaledRobotName(const std::string& instanceName,
196 const std::string& filename,
197 float scale,
198 const Ice::Current& c = Ice::emptyCurrent) override;
199 bool removeRobot(const std::string& robotName, const Ice::Current& c = Ice::emptyCurrent);
200 void addObject(const memoryx::ObjectClassBasePtr& objectClassBase,
201 const std::string& instanceName,
202 const PoseBasePtr& globalPose,
203 bool isStatic = false,
204 const Ice::Current& c = Ice::emptyCurrent) override;
205
206 // "new api" =>
207 std::string addRobotFromFile(const armarx::data::PackagePath& packagePath,
208 const Ice::Current& c = Ice::emptyCurrent) override;
209 void addObjectFromFile(const armarx::data::PackagePath& packagePath,
210 const std::string& instanceName,
211 const PoseBasePtr& globalPose,
212 bool isStatic = false,
213 const Ice::Current& c = Ice::emptyCurrent) override;
214
215
216 void addBox(float width,
217 float height,
218 float depth,
219 float massKG,
220 const DrawColor& color,
221 const std::string& instanceName,
222 const PoseBasePtr& globalPose,
223 bool isStatic = false,
224 const Ice::Current& c = Ice::emptyCurrent) override;
225
226 Ice::StringSeq getRobotNames(const Ice::Current&) override;
227 void removeObject(const std::string& instanceName, const Ice::Current&) override;
228
229 bool hasObject(const std::string& instanceName,
230 const Ice::Current& c = Ice::emptyCurrent) override;
231 void setObjectPose(const std::string& objectName,
232 const PoseBasePtr& globalPose,
233 const Ice::Current& c = Ice::emptyCurrent) override;
234 void setObjectSimulationType(const std::string& objectName,
235 armarx::SimulationType type,
236 const Ice::Current& c = Ice::emptyCurrent) override;
237 void activateObject(const std::string& objectName,
238 const Ice::Current& c = Ice::emptyCurrent) override;
239
240 bool hasRobot(const std::string& robotName,
241 const Ice::Current& c = Ice::emptyCurrent) override;
242 bool hasRobotNode(const std::string& robotName,
243 const std::string& robotNodeName,
244 const Ice::Current& c = Ice::emptyCurrent) override;
245 float getRobotMass(const std::string& robotName,
246 const Ice::Current& c = Ice::emptyCurrent) override;
247
248 NameValueMap getRobotJointAngles(const std::string& robotName,
249 const Ice::Current& c = Ice::emptyCurrent) override;
250 float getRobotJointAngle(const std::string& robotName,
251 const std::string& nodeName,
252 const Ice::Current& c = Ice::emptyCurrent) override;
253 NameValueMap getRobotJointVelocities(const std::string& robotName,
254 const Ice::Current& c = Ice::emptyCurrent) override;
255 float getRobotJointVelocity(const std::string& robotName,
256 const std::string& nodeName,
257 const Ice::Current& c = Ice::emptyCurrent) override;
258 NameValueMap getRobotJointTorques(const std::string& robotName,
259 const Ice::Current& c = Ice::emptyCurrent) override;
260 ForceTorqueDataSeq
261 getRobotForceTorqueSensors(const std::string& robotName,
262 const Ice::Current& c = Ice::emptyCurrent) override;
263
264 float getRobotJointLimitLo(const std::string& robotName,
265 const std::string& nodeName,
266 const Ice::Current& c = Ice::emptyCurrent) override;
267 float getRobotJointLimitHi(const std::string& robotName,
268 const std::string& nodeName,
269 const Ice::Current& c = Ice::emptyCurrent) override;
270 PoseBasePtr getRobotPose(const std::string& robotName,
271 const Ice::Current& c = Ice::emptyCurrent) override;
272 SimulatedRobotState getRobotState(const std::string& robotName,
273 const Ice::Current&) override;
274
275 float getRobotMaxTorque(const std::string& robotName,
276 const std::string& nodeName,
277 const Ice::Current& c = Ice::emptyCurrent) override;
278 void setRobotMaxTorque(const std::string& robotName,
279 const std::string& nodeName,
280 float maxTorque,
281 const Ice::Current& c = Ice::emptyCurrent) override;
282
283 PoseBasePtr getRobotNodePose(const std::string& robotName,
284 const std::string& robotNodeName,
285 const Ice::Current& c = Ice::emptyCurrent) override;
286
287 Vector3BasePtr getRobotLinearVelocity(const std::string& robotName,
288 const std::string& nodeName,
289 const Ice::Current& c = Ice::emptyCurrent) override;
290 Vector3BasePtr getRobotAngularVelocity(const std::string& robotName,
291 const std::string& nodeName,
292 const Ice::Current& c = Ice::emptyCurrent) override;
293
294 void setRobotLinearVelocity(const std::string& robotName,
295 const std::string& robotNodeName,
296 const Vector3BasePtr& vel,
297 const Ice::Current& c = Ice::emptyCurrent) override;
298 void setRobotAngularVelocity(const std::string& robotName,
299 const std::string& robotNodeName,
300 const Vector3BasePtr& vel,
301 const Ice::Current& c = Ice::emptyCurrent) override;
302 void
303 setRobotLinearVelocityRobotRootFrame(const std::string& robotName,
304 const std::string& robotNodeName,
305 const Vector3BasePtr& vel,
306 const Ice::Current& c = Ice::emptyCurrent) override;
307 void
308 setRobotAngularVelocityRobotRootFrame(const std::string& robotName,
309 const std::string& robotNodeName,
310 const Vector3BasePtr& vel,
311 const Ice::Current& c = Ice::emptyCurrent) override;
312
313 //! create a joint
314 void objectGrasped(const std::string& robotName,
315 const std::string& robotNodeName,
316 const std::string& objectName,
317 const Ice::Current& c = Ice::emptyCurrent) override;
318
319 //! remove a joint
320 void objectReleased(const std::string& robotName,
321 const std::string& robotNodeName,
322 const std::string& objectName,
323 const Ice::Current& c = Ice::emptyCurrent) override;
324
325 PoseBasePtr getObjectPose(const std::string& objectName,
326 const Ice::Current& c = Ice::emptyCurrent) override;
327
328 DistanceInfo getDistance(const std::string& robotName,
329 const std::string& robotNodeName,
330 const std::string& worldObjectName,
331 const Ice::Current& c = Ice::emptyCurrent) override;
332 DistanceInfo getRobotNodeDistance(const std::string& robotName,
333 const std::string& robotNodeName1,
334 const std::string& robotNodeName2,
335 const Ice::Current& c = Ice::emptyCurrent) override;
336 void showContacts(bool enable,
337 const std::string& layerName,
338 const Ice::Current& c = Ice::emptyCurrent) override;
339
340 /*!
341 * \brief Returns a list of all contacts. Note that you must call updateContacts() first to enable
342 * contacts handling.
343 */
344 ContactInfoSequence getContacts(const Ice::Current& c = Ice::emptyCurrent) override;
345
346 /*!
347 * \brief Enables the handling of contacts. If you intend to use getContacts(), call this method
348 * with enabled = true first.
349 */
350 void updateContacts(bool enable, const Ice::Current& c = Ice::emptyCurrent) override;
351
352 ObjectClassInformationSequence
353 getObjectClassPoses(const std::string& robotName,
354 const std::string& frameName,
355 const std::string& className,
356 const Ice::Current& c = Ice::emptyCurrent) override;
357
358
359 /*!
360 * \brief reInitialize Re-initializes the scene.
361 * Removes all robots and objects (and, in case the scene was loaded via a MemoryX snapshot, the working memory is cleared)
362 * Then, the setup is re-loaded similar to the startup procedure.
363 */
364 void reInitialize(const Ice::Current& c = Ice::emptyCurrent) override;
365
366
367 float getSimTime(const Ice::Current& c = Ice::emptyCurrent) override;
368
369
370 SceneVisuData getScene(const Ice::Current& c = Ice::emptyCurrent) override;
371 SimulatorInformation
372 getSimulatorInformation(const ::Ice::Current& = Ice::emptyCurrent) override;
373
374 /*!
375 * \brief
376 * \return The number of steps * the timestep in MS
377 */
378 int getFixedTimeStepMS(const Ice::Current& c = Ice::emptyCurrent) override;
379
380 void start(const Ice::Current& c = Ice::emptyCurrent) override;
381 void pause(const Ice::Current& c = Ice::emptyCurrent) override;
382 void step(const Ice::Current& c = Ice::emptyCurrent) override;
383 bool isRunning(const Ice::Current& c = Ice::emptyCurrent) override;
384
385 bool addSnapshot(memoryx::WorkingMemorySnapshotInterfacePrx snapshotInterfacePrx);
386 bool
387 loadAgentsFromSnapshot(memoryx::WorkingMemorySnapshotInterfacePrx snapshotInterfacePrx);
388
389 /**
390 * @see PropertyUser::createPropertyDefinitions()
391 */
397
398
399 protected:
400 void simulationLoop();
401 void reportVisuLoop();
402 void reportDataLoop();
403 /**
404 * @brief stop the simulation and join the simulation thread
405 */
407
408 /*!
409 * \brief resetData Clears all data
410 * \param clearWorkingMemory If set, the working memory is also cleared.
411 */
412 void resetData(bool clearWorkingMemory = false);
413
414 void initializeData();
415
416 SimulatedRobotState stateFromRobotInfo(RobotInfo const& robot, IceUtil::Time timestamp);
417
418 /// Returns the name. On failure an empty string is returned.
419 std::string
420 addRobot(std::string robotInstanceName,
421 const std::string& robFileGlobal,
422 Eigen::Matrix4f gp,
423 const std::string& robFile,
424 double pid_p = 10.0,
425 double pid_i = 0.0,
426 double pid_d = 0.0,
427 bool isStatic = false,
428 float scaling = 1,
429 bool colModel = false,
430 std::map<std::string, float> initConfig = std::map<std::string, float>(),
431 bool selfCollisions = false);
432 bool updateRobotTopics();
433
435
436
437 protected:
438 /// The sim task
440 /// The report visu task
442 /// The report data task
444
445 // simulator thread control
449 std::condition_variable condSimulatorThreadRunning;
450
452
453
454 /// Stores the time that was needed for communictaion
456 /// Stores the time that was needed to perform the last simulation loop
458 /// stores the time that was needed to sync the data
460
461 /// Scaling factor for the passing of time
463
464 TimeServerListenerPrx timeTopicPrx;
465
466 GlobalRobotPoseLocalizationListenerPrx globalRobotLocalization;
467 bool reportRobotPose = false;
468
469 SimulatorListenerInterfacePrx simulatorVisuUpdateListenerPrx;
470
471 std::atomic<float> reportVisuTimeMS = 0;
472
474 std::string commonStorageName;
475 memoryx::WorkingMemoryInterfacePrx memoryPrx;
476 memoryx::PriorKnowledgeInterfacePrx priorKnowledgePrx;
477 memoryx::LongtermMemoryInterfacePrx longtermMemoryPrx;
479
480 /// Constructed once based on the `ObjectPackage` property
482
483 /// Drawing contacts
484 memoryx::EntityDrawerInterfacePrx entityDrawerPrx;
485
486 bool publishContacts = false;
487 std::string contactLayerName;
488
490
491 /// Stores all instances that belong to a class
492 std::map<std::string, std::vector<std::string>> classInstanceMap;
493
494 /**
495 * Proxy object to offer the Timeserver proxy
496 *
497 * This is a hack to allow offering the proxies "Simulator" and "MasterTimeServer" at once
498 */
500 SimulatorResetEventPrx simulatorResetEventTopic;
501
502
503 private:
504 void addRobotsFromProperties();
505 void addSceneFromFile(const std::string& sceneFile);
506 void addSceneFromMemorySnapshot(const std::string& snapshotName);
507
508 /**
509 * Add a scene defined in the ArmarX JSON format to the simulation.
510 */
511 void addSceneFromJsonFile(const std::string& scenePath);
512
513 /**
514 * Add a scene defined in the SDF format to the simulation.
515 */
516 void addSceneFromSdfFile(const std::string& scenePath);
517
518 /**
519 * Add one object from an ArmarX JSON scene to the simulation.
520 */
521 void addJsonSceneObject(const armarx::objects::SceneObject object,
522 std::map<ObjectID, int>& idCounters);
523
524 void fixateRobotNode(const std::string& robotName, const std::string& robotNodeName);
525 void fixateObject(const std::string& objectName);
526 };
527
529} // namespace armarx
std::string timestamp()
constexpr T c
ComponentPropertyDefinitions(std::string prefix, bool hasObjectNameParameter=true)
Definition Component.cpp:46
Component()
Protected default constructor. Used for virtual inheritance. Use createManagedIceObject() instead.
Definition Component.cpp:66
std::string getConfigIdentifier()
Retrieve config identifier for this component as set in constructor.
Definition Component.cpp:90
Used to find objects in the ArmarX objects repository [1] (formerly [2]).
IceUtil::Handle< PeriodicTask< T > > pointer_type
Shared pointer type for convenience.
std::string prefix
Prefix of the properties such as namespace, domain, component name, etc.
SimulatorPropertyDefinitions(std::string prefix)
Definition Simulator.cpp:79
std::mutex simulatorRunningMutex
Definition Simulator.h:448
memoryx::LongtermMemoryInterfacePrx longtermMemoryPrx
Definition Simulator.h:477
void applyForceObject(const std::string &objectName, const Vector3BasePtr &force, const Ice::Current &c=Ice::emptyCurrent) override
void setRobotLinearVelocity(const std::string &robotName, const std::string &robotNodeName, const Vector3BasePtr &vel, const Ice::Current &c=Ice::emptyCurrent) override
std::string addScaledRobot(const std::string &filename, float scale, const Ice::Current &c=Ice::emptyCurrent) override
void onInitComponent() override
Pure virtual hook for the subclass.
memoryx::WorkingMemoryInterfacePrx memoryPrx
Definition Simulator.h:475
void setObjectSimulationType(const std::string &objectName, armarx::SimulationType type, const Ice::Current &c=Ice::emptyCurrent) override
SimulatorTimeServerProxyPtr timeserverProxy
Proxy object to offer the Timeserver proxy.
Definition Simulator.h:499
Ice::Long getTime(const Ice::Current &c=Ice::emptyCurrent) override
void showContacts(bool enable, const std::string &layerName, const Ice::Current &c=Ice::emptyCurrent) override
Vector3BasePtr getRobotAngularVelocity(const std::string &robotName, const std::string &nodeName, const Ice::Current &c=Ice::emptyCurrent) override
void start(const Ice::Current &c=Ice::emptyCurrent) override
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
float getRobotJointAngle(const std::string &robotName, const std::string &nodeName, const Ice::Current &c=Ice::emptyCurrent) override
void actuateRobotJointsTorque(const std::string &robotName, const NameValueMap &torques, const Ice::Current &c=Ice::emptyCurrent) override
~Simulator() override
SimulatorInformation getSimulatorInformation(const ::Ice::Current &=Ice::emptyCurrent) override
void resetData(bool clearWorkingMemory=false)
resetData Clears all data
bool hasRobotNode(const std::string &robotName, const std::string &robotNodeName, const Ice::Current &c=Ice::emptyCurrent) override
PoseBasePtr getRobotPose(const std::string &robotName, const Ice::Current &c=Ice::emptyCurrent) override
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...
Ice::Int getStepTimeMS(const ::Ice::Current &=Ice::emptyCurrent) override
void shutdownSimulationLoop()
stop the simulation and join the simulation thread
GlobalRobotPoseLocalizationListenerPrx globalRobotLocalization
Definition Simulator.h:466
void onDisconnectComponent() override
Hook for subclass.
SimulatorResetEventPrx simulatorResetEventTopic
Definition Simulator.h:500
void applyTorqueRobotNode(const std::string &robotName, const std::string &robotNodeName, const Vector3BasePtr &torque, const Ice::Current &c=Ice::emptyCurrent) override
float timeServerSpeed
Scaling factor for the passing of time.
Definition Simulator.h:462
PoseBasePtr getObjectPose(const std::string &objectName, const Ice::Current &c=Ice::emptyCurrent) override
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...
float currentComTimeMS
Stores the time that was needed for communictaion.
Definition Simulator.h:455
void applyForceRobotNode(const std::string &robotName, const std::string &robotNodeName, const Vector3BasePtr &force, const Ice::Current &c=Ice::emptyCurrent) override
float getRobotJointVelocity(const std::string &robotName, const std::string &nodeName, const Ice::Current &c=Ice::emptyCurrent) override
void addObjectFromFile(const armarx::data::PackagePath &packagePath, const std::string &instanceName, const PoseBasePtr &globalPose, bool isStatic=false, const Ice::Current &c=Ice::emptyCurrent) override
NameValueMap getRobotJointAngles(const std::string &robotName, const Ice::Current &c=Ice::emptyCurrent) override
void step(const Ice::Current &c=Ice::emptyCurrent) override
void setRobotAngularVelocityRobotRootFrame(const std::string &robotName, const std::string &robotNodeName, const Vector3BasePtr &vel, const Ice::Current &c=Ice::emptyCurrent) override
std::string addRobotFromFile(const armarx::data::PackagePath &packagePath, const Ice::Current &c=Ice::emptyCurrent) override
memoryx::GridFileManagerPtr fileManager
Definition Simulator.h:478
memoryx::PriorKnowledgeInterfacePrx priorKnowledgePrx
Definition Simulator.h:476
SimulatorListenerInterfacePrx simulatorVisuUpdateListenerPrx
Definition Simulator.h:469
std::condition_variable condSimulatorThreadRunning
Definition Simulator.h:449
bool hasObject(const std::string &instanceName, const Ice::Current &c=Ice::emptyCurrent) override
Ice::Float getSpeed(const Ice::Current &c=Ice::emptyCurrent) override
NameValueMap getRobotJointTorques(const std::string &robotName, const Ice::Current &c=Ice::emptyCurrent) override
bool loadAgentsFromSnapshot(memoryx::WorkingMemorySnapshotInterfacePrx snapshotInterfacePrx)
void removeObject(const std::string &instanceName, const Ice::Current &) override
DistanceInfo getDistance(const std::string &robotName, const std::string &robotNodeName, const std::string &worldObjectName, const Ice::Current &c=Ice::emptyCurrent) override
float getSimTime(const Ice::Current &c=Ice::emptyCurrent) override
void stop(const Ice::Current &c=Ice::emptyCurrent) override
NameValueMap getRobotJointVelocities(const std::string &robotName, const Ice::Current &c=Ice::emptyCurrent) override
PeriodicTask< Simulator >::pointer_type reportVisuTask
The report visu task.
Definition Simulator.h:441
bool addSnapshot(memoryx::WorkingMemorySnapshotInterfacePrx snapshotInterfacePrx)
float getRobotJointLimitHi(const std::string &robotName, const std::string &nodeName, const Ice::Current &c=Ice::emptyCurrent) override
bool hasRobot(const std::string &robotName, const Ice::Current &c=Ice::emptyCurrent) override
std::string contactLayerName
Definition Simulator.h:487
void pause(const Ice::Current &c=Ice::emptyCurrent) override
void setRobotAngularVelocity(const std::string &robotName, const std::string &robotNodeName, const Vector3BasePtr &vel, const Ice::Current &c=Ice::emptyCurrent) override
PeriodicTask< Simulator >::pointer_type reportDataTask
The report data task.
Definition Simulator.h:443
void setRobotLinearVelocityRobotRootFrame(const std::string &robotName, const std::string &robotNodeName, const Vector3BasePtr &vel, const Ice::Current &c=Ice::emptyCurrent) override
float currentSimTimeMS
Stores the time that was needed to perform the last simulation loop.
Definition Simulator.h:457
Vector3BasePtr getRobotLinearVelocity(const std::string &robotName, const std::string &nodeName, const Ice::Current &c=Ice::emptyCurrent) override
SimulatedWorldPtr physicsWorld
Definition Simulator.h:451
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.
std::string addScaledRobotName(const std::string &instanceName, const std::string &filename, float scale, const Ice::Current &c=Ice::emptyCurrent) override
ObjectFinder objectFinder
Constructed once based on the ObjectPackage property.
Definition Simulator.h:481
void onConnectComponent() override
Pure virtual hook for the subclass.
void objectReleased(const std::string &robotName, const std::string &robotNodeName, const std::string &objectName, const Ice::Current &c=Ice::emptyCurrent) override
remove a joint
bool isRunning(const Ice::Current &c=Ice::emptyCurrent) override
std::atomic< float > reportVisuTimeMS
Definition Simulator.h:471
float getRobotMaxTorque(const std::string &robotName, const std::string &nodeName, const Ice::Current &c=Ice::emptyCurrent) override
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 =...
PropertyDefinitionsPtr createPropertyDefinitions() override
Definition Simulator.h:393
memoryx::GridFileManagerPtr requestFileManager()
float currentSyncTimeMS
stores the time that was needed to sync the data
Definition Simulator.h:459
static std::string GetDefaultName()
SimulatedRobotState getRobotState(const std::string &robotName, const Ice::Current &) override
bool removeRobot(const std::string &robotName, const Ice::Current &c=Ice::emptyCurrent)
float getRobotMass(const std::string &robotName, const Ice::Current &c=Ice::emptyCurrent) override
bool simulatorThreadShutdown
Definition Simulator.h:447
SceneVisuData getScene(const Ice::Current &c=Ice::emptyCurrent) override
float getRobotJointLimitLo(const std::string &robotName, const std::string &nodeName, const Ice::Current &c=Ice::emptyCurrent) override
void setObjectPose(const std::string &objectName, const PoseBasePtr &globalPose, const Ice::Current &c=Ice::emptyCurrent) override
DistanceInfo getRobotNodeDistance(const std::string &robotName, const std::string &robotNodeName1, const std::string &robotNodeName2, const Ice::Current &c=Ice::emptyCurrent) override
void objectGrasped(const std::string &robotName, const std::string &robotNodeName, const std::string &objectName, const Ice::Current &c=Ice::emptyCurrent) override
create a joint
TimeServerListenerPrx timeTopicPrx
Definition Simulator.h:464
void setRobotPose(const std::string &robotName, const PoseBasePtr &globalPose, const Ice::Current &c=Ice::emptyCurrent) override
std::string addRobot(const std::string &filename, const Ice::Current &c=Ice::emptyCurrent) override
void run() override
void onExitComponent() override
Hook for subclass.
void addObject(const memoryx::ObjectClassBasePtr &objectClassBase, const std::string &instanceName, const PoseBasePtr &globalPose, bool isStatic=false, const Ice::Current &c=Ice::emptyCurrent) override
SimulatedRobotState stateFromRobotInfo(RobotInfo const &robot, IceUtil::Time timestamp)
void actuateRobotJoints(const std::string &robotName, const NameValueMap &angles, const NameValueMap &velocities, const Ice::Current &c=Ice::emptyCurrent) override
ForceTorqueDataSeq getRobotForceTorqueSensors(const std::string &robotName, const Ice::Current &c=Ice::emptyCurrent) override
void setRobotMaxTorque(const std::string &robotName, const std::string &nodeName, float maxTorque, const Ice::Current &c=Ice::emptyCurrent) override
ObjectClassInformationSequence getObjectClassPoses(const std::string &robotName, const std::string &frameName, const std::string &className, const Ice::Current &c=Ice::emptyCurrent) override
void actuateRobotJointsPos(const std::string &robotName, const NameValueMap &angles, const Ice::Current &c=Ice::emptyCurrent) override
PeriodicTask< Simulator >::pointer_type simulationTask
The sim task.
Definition Simulator.h:439
PoseBasePtr getRobotNodePose(const std::string &robotName, const std::string &robotNodeName, const Ice::Current &c=Ice::emptyCurrent) override
void actuateRobotJointsVel(const std::string &robotName, const NameValueMap &velocities, const Ice::Current &c=Ice::emptyCurrent) override
std::string commonStorageName
Definition Simulator.h:474
void activateObject(const std::string &objectName, const Ice::Current &c=Ice::emptyCurrent) override
bool simulatorThreadRunning
Definition Simulator.h:446
std::string priorKnowledgeName
Definition Simulator.h:473
Ice::StringSeq getRobotNames(const Ice::Current &) override
memoryx::EntityDrawerInterfacePrx entityDrawerPrx
Drawing contacts.
Definition Simulator.h:484
std::map< std::string, std::vector< std::string > > classInstanceMap
Stores all instances that belong to a class.
Definition Simulator.h:492
std::string getDefaultName() const override
Retrieve default name of component.
int getFixedTimeStepMS(const Ice::Current &c=Ice::emptyCurrent) override
void applyTorqueObject(const std::string &objectName, const Vector3BasePtr &torque, const Ice::Current &c=Ice::emptyCurrent) override
This file offers overloads of toIce() and fromIce() functions for STL container types.
IceInternal::Handle< SimulatorTimeServerProxy > SimulatorTimeServerProxyPtr
Definition Simulator.h:67
std::shared_ptr< SimulatedWorld > SimulatedWorldPtr
SimulatorType
Definition Simulator.h:70
IceUtil::Handle< class PropertyDefinitionContainer > PropertyDefinitionsPtr
PropertyDefinitions smart pointer type.
IceInternal::Handle< Simulator > SimulatorPtr
Definition Simulator.h:528
std::shared_ptr< GridFileManager > GridFileManagerPtr