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 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 */
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 */
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
455 /// Stores the time that was needed to perform the last simulation loop
457 /// stores the time that was needed to sync the data
459
460 /// Scaling factor for the passing of time
462
463 TimeServerListenerPrx timeTopicPrx;
464
465 GlobalRobotPoseLocalizationListenerPrx globalRobotLocalization;
466 bool reportRobotPose = false;
467
468 SimulatorListenerInterfacePrx simulatorVisuUpdateListenerPrx;
469
470 std::atomic<float> reportVisuTimeMS = 0;
471
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
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:75
std::mutex simulatorRunningMutex
Definition Simulator.h:447
memoryx::LongtermMemoryInterfacePrx longtermMemoryPrx
Definition Simulator.h:476
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:474
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:498
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:465
void onDisconnectComponent() override
Hook for subclass.
SimulatorResetEventPrx simulatorResetEventTopic
Definition Simulator.h:499
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:461
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:454
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:477
memoryx::PriorKnowledgeInterfacePrx priorKnowledgePrx
Definition Simulator.h:475
SimulatorListenerInterfacePrx simulatorVisuUpdateListenerPrx
Definition Simulator.h:468
std::condition_variable condSimulatorThreadRunning
Definition Simulator.h:448
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:440
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:486
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:442
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:456
Vector3BasePtr getRobotLinearVelocity(const std::string &robotName, const std::string &nodeName, const Ice::Current &c=Ice::emptyCurrent) override
SimulatedWorldPtr physicsWorld
Definition Simulator.h:450
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:480
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:470
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:392
memoryx::GridFileManagerPtr requestFileManager()
float currentSyncTimeMS
stores the time that was needed to sync the data
Definition Simulator.h:458
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:446
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:463
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:438
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:473
void activateObject(const std::string &objectName, const Ice::Current &c=Ice::emptyCurrent) override
bool simulatorThreadRunning
Definition Simulator.h:445
std::string priorKnowledgeName
Definition Simulator.h:472
Ice::StringSeq getRobotNames(const Ice::Current &) override
memoryx::EntityDrawerInterfacePrx entityDrawerPrx
Drawing contacts.
Definition Simulator.h:483
std::map< std::string, std::vector< std::string > > classInstanceMap
Stores all instances that belong to a class.
Definition Simulator.h:491
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:527
std::shared_ptr< GridFileManager > GridFileManagerPtr