Simulator Class Reference

The Simulator class holds an instance of the AmrarXPhysicsWorld and communicates to ArmarX. More...

#include <ArmarXSimulation/components/Simulator/Simulator.h>

+ Inheritance diagram for Simulator:

Public Member Functions

void activateObject (const std::string &objectName, const Ice::Current &c=Ice::emptyCurrent) override
 
void actuateRobotJoints (const std::string &robotName, const NameValueMap &angles, const NameValueMap &velocities, const Ice::Current &c=Ice::emptyCurrent) override
 
void actuateRobotJointsPos (const std::string &robotName, const NameValueMap &angles, const Ice::Current &c=Ice::emptyCurrent) override
 
void actuateRobotJointsTorque (const std::string &robotName, const NameValueMap &torques, const Ice::Current &c=Ice::emptyCurrent) override
 
void actuateRobotJointsVel (const std::string &robotName, const NameValueMap &velocities, 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
 
void addObject (const memoryx::ObjectClassBasePtr &objectClassBase, const std::string &instanceName, const PoseBasePtr &globalPose, bool isStatic=false, 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
 
std::string addRobot (const std::string &filename, const Ice::Current &c=Ice::emptyCurrent) override
 
std::string addRobotFromFile (const armarx::data::PackagePath &packagePath, const Ice::Current &c=Ice::emptyCurrent) override
 
std::string addScaledRobot (const std::string &filename, float scale, const Ice::Current &c=Ice::emptyCurrent) override
 
std::string addScaledRobotName (const std::string &instanceName, const std::string &filename, float scale, const Ice::Current &c=Ice::emptyCurrent) override
 
bool addSnapshot (memoryx::WorkingMemorySnapshotInterfacePrx snapshotInterfacePrx)
 
void applyForceObject (const std::string &objectName, const Vector3BasePtr &force, const Ice::Current &c=Ice::emptyCurrent) override
 
void applyForceRobotNode (const std::string &robotName, const std::string &robotNodeName, const Vector3BasePtr &force, const Ice::Current &c=Ice::emptyCurrent) override
 
void applyTorqueObject (const std::string &objectName, const Vector3BasePtr &torque, const Ice::Current &c=Ice::emptyCurrent) override
 
void applyTorqueRobotNode (const std::string &robotName, const std::string &robotNodeName, const Vector3BasePtr &torque, const Ice::Current &c=Ice::emptyCurrent) override
 
PropertyDefinitionsPtr createPropertyDefinitions () 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 handling.
 
std::string getDefaultName () const override
 Retrieve default name of component.
 
DistanceInfo getDistance (const std::string &robotName, const std::string &robotNodeName, const std::string &worldObjectName, const Ice::Current &c=Ice::emptyCurrent) override
 
int getFixedTimeStepMS (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
 
PoseBasePtr getObjectPose (const std::string &objectName, const Ice::Current &c=Ice::emptyCurrent) override
 
Vector3BasePtr getRobotAngularVelocity (const std::string &robotName, const std::string &nodeName, const Ice::Current &c=Ice::emptyCurrent) override
 
ForceTorqueDataSeq getRobotForceTorqueSensors (const std::string &robotName, const Ice::Current &c=Ice::emptyCurrent) override
 
float getRobotJointAngle (const std::string &robotName, const std::string &nodeName, const Ice::Current &c=Ice::emptyCurrent) override
 
NameValueMap getRobotJointAngles (const std::string &robotName, const Ice::Current &c=Ice::emptyCurrent) override
 
float getRobotJointLimitHi (const std::string &robotName, const std::string &nodeName, const Ice::Current &c=Ice::emptyCurrent) override
 
float getRobotJointLimitLo (const std::string &robotName, const std::string &nodeName, const Ice::Current &c=Ice::emptyCurrent) override
 
NameValueMap getRobotJointTorques (const std::string &robotName, const Ice::Current &c=Ice::emptyCurrent) override
 
NameValueMap getRobotJointVelocities (const std::string &robotName, const Ice::Current &c=Ice::emptyCurrent) override
 
float getRobotJointVelocity (const std::string &robotName, const std::string &nodeName, const Ice::Current &c=Ice::emptyCurrent) override
 
Vector3BasePtr getRobotLinearVelocity (const std::string &robotName, const std::string &nodeName, const Ice::Current &c=Ice::emptyCurrent) override
 
float getRobotMass (const std::string &robotName, const Ice::Current &c=Ice::emptyCurrent) override
 
float getRobotMaxTorque (const std::string &robotName, const std::string &nodeName, const Ice::Current &c=Ice::emptyCurrent) override
 
Ice::StringSeq getRobotNames (const Ice::Current &) override
 
DistanceInfo getRobotNodeDistance (const std::string &robotName, const std::string &robotNodeName1, const std::string &robotNodeName2, const Ice::Current &c=Ice::emptyCurrent) override
 
PoseBasePtr getRobotNodePose (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
 
SimulatedRobotState getRobotState (const std::string &robotName, const Ice::Current &) override
 
SceneVisuData getScene (const Ice::Current &c=Ice::emptyCurrent) override
 
float getSimTime (const Ice::Current &c=Ice::emptyCurrent) override
 
SimulatorInformation getSimulatorInformation (const ::Ice::Current &=Ice::emptyCurrent) override
 
Ice::Float getSpeed (const Ice::Current &c=Ice::emptyCurrent) override
 
Ice::Int getStepTimeMS (const ::Ice::Current &=Ice::emptyCurrent) override
 
Ice::Long getTime (const Ice::Current &c=Ice::emptyCurrent) override
 
bool hasObject (const std::string &instanceName, const Ice::Current &c=Ice::emptyCurrent) override
 
bool hasRobot (const std::string &robotName, const Ice::Current &c=Ice::emptyCurrent) override
 
bool hasRobotNode (const std::string &robotName, const std::string &robotNodeName, const Ice::Current &c=Ice::emptyCurrent) override
 
bool isRunning (const Ice::Current &c=Ice::emptyCurrent) override
 
bool loadAgentsFromSnapshot (memoryx::WorkingMemorySnapshotInterfacePrx snapshotInterfacePrx)
 
void objectGrasped (const std::string &robotName, const std::string &robotNodeName, const std::string &objectName, const Ice::Current &c=Ice::emptyCurrent) override
 create a joint
 
void objectReleased (const std::string &robotName, const std::string &robotNodeName, const std::string &objectName, const Ice::Current &c=Ice::emptyCurrent) override
 remove a joint
 
void onConnectComponent () override
 Pure virtual hook for the subclass.
 
void onDisconnectComponent () override
 Hook for subclass.
 
void onExitComponent () override
 Hook for subclass.
 
void onInitComponent () override
 Pure virtual hook for the subclass.
 
void pause (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 loaded via a MemoryX snapshot, the working memory is cleared) Then, the setup is re-loaded similar to the startup procedure.
 
void removeObject (const std::string &instanceName, const Ice::Current &) override
 
bool removeRobot (const std::string &robotName, const Ice::Current &c=Ice::emptyCurrent)
 
void run () override
 
void setObjectPose (const std::string &objectName, const PoseBasePtr &globalPose, const Ice::Current &c=Ice::emptyCurrent) override
 
void setObjectSimulationType (const std::string &objectName, armarx::SimulationType type, 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
 
void setRobotAngularVelocityRobotRootFrame (const std::string &robotName, const std::string &robotNodeName, const Vector3BasePtr &vel, 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
 
void setRobotLinearVelocityRobotRootFrame (const std::string &robotName, const std::string &robotNodeName, const Vector3BasePtr &vel, 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
 
void setRobotPose (const std::string &robotName, const PoseBasePtr &globalPose, const Ice::Current &c=Ice::emptyCurrent) override
 
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.
 
void showContacts (bool enable, const std::string &layerName, const Ice::Current &c=Ice::emptyCurrent) override
 
 Simulator ()
 
void start (const Ice::Current &c=Ice::emptyCurrent) override
 
void step (const Ice::Current &c=Ice::emptyCurrent) override
 
void stop (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 = true first.
 
 ~Simulator () override
 
- Public Member Functions inherited from Component
virtual void componentPropertiesUpdated (const std::set< std::string > &changedProperties)
 Implement this function if you would like to react to changes in the properties.
 
void forceComponentCreatedByComponentCreateFunc ()
 forces the flag to be set to true that the object instance was created by the Component::create function
 
std::vector< PropertyUserPtr > getAdditionalPropertyUsers () const
 
template<typename PropertyType>
Property< PropertyType > getProperty (const std::string &name)
 
template<typename PropertyType>
Property< PropertyType > getProperty (const std::string &name) const
 
template<class T>
void getProperty (std::atomic< T > &val, const std::string &name) const
 
template<class T>
void getProperty (T &val, const std::string &name) const
 
template<class ProxyType>
ProxyType getProxyFromProperty (const std::string &propertyName, bool addToDependencies=false, const std::string &endpoints="", bool throwOnProxyError=true)
 Get a proxy whose name is specified by the given property.
 
template<class ProxyType>
void getProxyFromProperty (ProxyType &proxy, const std::string &propertyName, bool addToDependencies=false, const std::string &endpoints="", bool throwOnProxyError=true)
 
template<class TopicProxyType>
TopicProxyType getTopicFromProperty (const std::string &propertyName)
 Get a topic proxy whose name is specified by the given property.
 
template<class TopicProxyType>
void getTopicFromProperty (TopicProxyType &top, const std::string &propertyName)
 
void initializeProperties (const std::string &configName, Ice::PropertiesPtr const &properties, const std::string &configDomain)
 initializes the properties of this component.
 
void injectPropertyDefinitions (PropertyDefinitionsPtr &props) override
 
void offeringTopicFromProperty (const std::string &propertyName)
 Offer a topic whose name is specified by the given property.
 
virtual void preOnConnectComponent () override
 
virtual void preOnInitComponent () override
 
bool usingProxyFromProperty (const std::string &propertyName, const std::string &endpoints="")
 Use a proxy whose name is specified by the given property.
 
void usingTopicFromProperty (const std::string &propertyName, bool orderedPublishing=false)
 Use a topic whose name is specified by the given property.
 
- Public Member Functions inherited from ManagedIceObject
void enableProfiler (bool enable)
 setProfiler allows setting ManagedIceObject::profiler to a new instance (if the new instance is actually not a null pointer)
 
std::string generateSubObjectName (const std::string &subObjectName)
 Generates a unique name for a sub object from a general name.
 
ArmarXManagerPtr getArmarXManager () const
 Returns the ArmarX manager used to add and remove components.
 
ManagedIceObjectConnectivity getConnectivity () const
 Retrieve connectivity of the object (topcis as well as proxies)
 
IceManagerPtr getIceManager () const
 Returns the IceManager.
 
VariantBasePtr getMetaInfo (const std::string &id)
 
StringVariantBaseMap getMetaInfoMap () const
 
std::string getName () const
 Retrieve name of object.
 
Ice::ObjectAdapterPtr getObjectAdapter () const
 Returns object's Ice adapter.
 
ArmarXObjectSchedulerPtr getObjectScheduler () const
 
PeriodicTaskPtr getPeriodicTask (const std::string &name)
 
Profiler::ProfilerPtr getProfiler () const
 getProfiler returns an instance of armarx::Profiler
 
template<class ProxyTarg, class... Args>
void getProxy (const char *name, IceInternal::ProxyHandle< ProxyTarg > &proxy, Args &&... args)
 
template<class ProxyType>
ProxyType getProxy (const std::string &name, bool addToDependencies=false, const std::string &endpoints="", bool throwOnProxyError=true)
 Retrieves a proxy object.
 
template<class ProxyTarg, class... Args>
void getProxy (const std::string &name, IceInternal::ProxyHandle< ProxyTarg > &proxy, Args &&... args)
 
template<class ProxyTarg, class... Args>
void getProxy (IceInternal::ProxyHandle< ProxyTarg > &proxy, const char *name, Args &&... args)
 
template<class ProxyTarg, class... Args>
void getProxy (IceInternal::ProxyHandle< ProxyTarg > &proxy, const std::string &name, Args &&... args)
 Assigns a proxy to proxy.
 
Ice::ObjectPrx getProxy (long timeoutMs=0, bool waitForScheduler=true) const
 Returns the proxy of this object (optionally it waits for the proxy)
 
template<class Prx>
Prx getProxy (long timeoutMs=0, bool waitForScheduler=true) const
 
template<class ProxyType>
void getProxy (ProxyType &proxy, const char *name, bool addToDependencies=false, const std::string &endpoints="", bool throwOnProxyError=true)
 Overload to allow using string literals as name (solve ambiguous overload).
 
template<class Prx>
void getProxy (Prx &prx, long timeoutMs=0, bool waitForScheduler=true) const
 
int getState () const
 Retrieve current state of the ManagedIceObject.
 
template<class TopicProxyType>
TopicProxyType getTopic (const std::string &name)
 Returns a proxy of the specified topic.
 
template<class TopicProxyType>
void getTopic (TopicProxyType &topicProxy, const std::string &name)
 Assigns a proxy of the specified topic to topicProxy.
 
std::vector< std::string > getUnresolvedDependencies () const
 returns the names of all unresolved dependencies
 
 ManagedIceObject (ManagedIceObject const &other)
 
void offeringTopic (const std::string &name)
 Registers a topic for retrival after initialization.
 
void preambleGetTopic (std::string const &name)
 
void setMetaInfo (const std::string &id, const VariantBasePtr &value)
 Allows to set meta information that can be queried live via Ice interface on the ArmarXManager.
 
void startPeriodicTask (const std::string &uniqueName, std::function< void(void)> f, int periodMs, bool assureMeanInterval=false, bool forceSystemTime=true)
 
bool stopPeriodicTask (const std::string &name)
 
bool unsubscribeFromTopic (const std::string &name)
 Unsubscribe from a topic.
 
bool usingProxy (const std::string &name, const std::string &endpoints="")
 Registers a proxy for retrieval after initialization and adds it to the dependency list.
 
void usingTopic (const std::string &name, bool orderedPublishing=false)
 Registers a proxy for subscription after initialization.
 
void waitForObjectScheduler ()
 Waits until the ObjectScheduler could resolve all dependencies.
 
void waitForProxy (std::string const &name, bool addToDependencies)
 
- Public Member Functions inherited from Logging
SpamFilterDataPtr deactivateSpam (float deactivationDurationSec=10.0f, const std::string &identifier="", bool deactivate=true) const
 disables the logging for the current line for the given amount of seconds.
 
MessageTypeT getEffectiveLoggingLevel () const
 
 Logging ()
 
void setLocalMinimumLoggingLevel (MessageTypeT level)
 With setLocalMinimumLoggingLevel the minimum verbosity-level of log-messages can be set.
 
void setTag (const LogTag &tag)
 
void setTag (const std::string &tagName)
 
virtual ~Logging ()
 
- Public Member Functions inherited from PropertyUser
std::vector< std::string > getComponentProxyNames ()
 
Ice::PropertiesPtr getIceProperties () const
 Returns the set of Ice properties.
 
template<typename PropertyType>
Property< PropertyType > getProperty (const std::string &name)
 Property creation and retrieval.
 
template<typename PropertyType>
Property< PropertyType > getProperty (const std::string &name) const
 Hack to allow using getProperty in const-modified methods.
 
template<class T>
void getProperty (std::atomic< T > &val, const std::string &name) const
 
template<class T>
void getProperty (T &val, const std::string &name) const
 
template<class T>
std::vector< T > getPropertyAsCSV (const std::string &name, const std::string &splitBy=",;", bool trimElements=true, bool removeEmptyElements=true)
 
template<class ContainerT>
void getPropertyAsCSV (ContainerT &val, const std::string &name, const std::string &splitBy=",;", bool trimElements=true, bool removeEmptyElements=true)
 
PropertyDefinitionsPtr getPropertyDefinitions ()
 Returns the component's property definition container.
 
std::vector< std::string > getSubscribedTopicNames ()
 
std::vector< std::string > getTopicProxyNames ()
 
bool hasProperty (const std::string &name)
 
 PropertyUser ()
 
virtual void setIceProperties (Ice::PropertiesPtr properties)
 Sets the Ice properties.
 
bool tryAddProperty (const std::string &propertyName, const std::string &value)
 
virtual void updateIceProperties (const std::map< std::string, std::string > &changes)
 
void updateProperties ()
 
void updateProxies (IceManagerPtr)
 
 ~PropertyUser () override
 

Static Public Member Functions

static std::string GetDefaultName ()
 
- Static Public Member Functions inherited from Component
template<class T, class TPtr = IceInternal::Handle<T>>
static TPtr create (Ice::PropertiesPtr properties=Ice::createProperties(), const std::string &configName="", const std::string &configDomain="ArmarX")
 Factory method for a component.
 
- Static Public Member Functions inherited from ManagedIceObject
static std::string generateSubObjectName (const std::string &superObjectName, const std::string &subObjectName)
 Generates a unique name for a sub object from a general name and unique name.
 
static std::string GetObjectStateAsString (int state)
 

Protected Member Functions

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)
 Returns the name. On failure an empty string is returned.
 
void initializeData ()
 
void reportDataLoop ()
 
void reportVisuLoop ()
 
memoryx::GridFileManagerPtr requestFileManager ()
 
void resetData (bool clearWorkingMemory=false)
 resetData Clears all data
 
void shutdownSimulationLoop ()
 stop the simulation and join the simulation thread
 
void simulationLoop ()
 
SimulatedRobotState stateFromRobotInfo (RobotInfo const &robot, IceUtil::Time timestamp)
 
bool updateRobotTopics ()
 
- Protected Member Functions inherited from Component
void addPropertyUser (const PropertyUserPtr &subPropertyUser)
 Add additional property users here that should show up in the application help text.
 
 Component ()
 Protected default constructor. Used for virtual inheritance. Use createManagedIceObject() instead.
 
std::string getConfigDomain ()
 Retrieve config domain for this component as set in constructor.
 
std::string getConfigIdentifier ()
 Retrieve config identifier for this component as set in constructor.
 
std::string getConfigName ()
 Retrieve config name for this component as set in constructor.
 
virtual void icePropertiesInitialized ()
 
- Protected Member Functions inherited from ManagedIceObject
template<class PluginT, class... ParamsT>
PluginT * addPlugin (const std::string prefix="", ParamsT &&... params)
 
template<class PluginT, class... ParamsT>
void addPlugin (PluginT *&targ, const std::string prefix="", ParamsT &&... params)
 
template<class PluginT, class... ParamsT>
void addPlugin (std::experimental::observer_ptr< PluginT > &targ, const std::string prefix="", ParamsT &&... params)
 
Ice::CommunicatorPtr getCommunicator () const
 
std::unique_ptr< ManagedIceObjectPlugin > & getPluginPointer (std::type_info const &type, std::string const &prefix)
 
 ManagedIceObject ()
 Protected default constructor.
 
virtual void postOnConnectComponent ()
 
virtual void postOnDisconnectComponent ()
 
virtual void postOnExitComponent ()
 
virtual void postOnInitComponent ()
 
virtual void preOnDisconnectComponent ()
 
virtual void preOnExitComponent ()
 
bool removeProxyDependency (const std::string &name)
 This function removes the dependency of this object on the in parameter name specified object.
 
void setName (std::string name)
 Override name of well-known object.
 
void terminate ()
 Initiates termination of this IceManagedObject.
 
 ~ManagedIceObject () override
 
- Protected Member Functions inherited from Logging
bool checkLogLevel (MessageTypeT level) const
 
const LogSenderPtr & getLogSender () const
 Retrieve log sender.
 
LogSenderPtr loghelper (const char *file, int line, const char *function) const
 

Protected Attributes

std::map< std::string, std::vector< std::string > > classInstanceMap
 Stores all instances that belong to a class.
 
std::string commonStorageName
 
std::condition_variable condSimulatorThreadRunning
 
std::string contactLayerName
 
float currentComTimeMS = 0
 Stores the time that was needed for communictaion.
 
float currentSimTimeMS = 0
 Stores the time that was needed to perform the last simulation loop.
 
float currentSyncTimeMS = 0
 stores the time that was needed to sync the data
 
memoryx::EntityDrawerInterfacePrx entityDrawerPrx
 Drawing contacts.
 
memoryx::GridFileManagerPtr fileManager
 
GlobalRobotPoseLocalizationListenerPrx globalRobotLocalization
 
int lastPublishedContacts = 0
 
memoryx::LongtermMemoryInterfacePrx longtermMemoryPrx
 
memoryx::WorkingMemoryInterfacePrx memoryPrx
 
ObjectFinder objectFinder
 Constructed once based on the ObjectPackage property.
 
SimulatedWorldPtr physicsWorld
 
std::string priorKnowledgeName
 
memoryx::PriorKnowledgeInterfacePrx priorKnowledgePrx
 
bool publishContacts = false
 
PeriodicTask< Simulator >::pointer_type reportDataTask
 The report data task.
 
bool reportRobotPose = false
 
PeriodicTask< Simulator >::pointer_type reportVisuTask
 The report visu task.
 
std::atomic< float > reportVisuTimeMS = 0
 
PeriodicTask< Simulator >::pointer_type simulationTask
 The sim task.
 
SimulatorResetEventPrx simulatorResetEventTopic
 
std::mutex simulatorRunningMutex
 
bool simulatorThreadRunning = false
 
bool simulatorThreadShutdown = false
 
SimulatorListenerInterfacePrx simulatorVisuUpdateListenerPrx
 
SimulatorTimeServerProxyPtr timeserverProxy
 Proxy object to offer the Timeserver proxy.
 
float timeServerSpeed = 0
 Scaling factor for the passing of time.
 
TimeServerListenerPrx timeTopicPrx
 
- Protected Attributes inherited from Logging
MessageTypeT minimumLoggingLevel
 
SpamFilterDataPtr spamFilter
 
LogTag tag
 

Additional Inherited Members

- Public Types inherited from ManagedIceObject
using PeriodicTaskPtr = IceUtil::Handle<SimplePeriodicTask<std::function<void(void)>>>
 
- Static Public Attributes inherited from ManagedIceObject
static const ManagedIceObjectPtr NullPtr
 A nullptr to be used when a const ref to a nullptr is required.
 

Detailed Description

The Simulator class holds an instance of the AmrarXPhysicsWorld and communicates to ArmarX.

The following optional parameters can be used.

  • RobotFileName
    Simox/VirtualRobot robot file name, e.g. robot_model.xml.
  • InitialRobotPose.x/y/z/roll/pitch/yaw
    The initial pose of the robot
  • LogRobot
    Default: false, If true, the complete robot state is logged to a file.
  • RobotControllerPID.p/i/d
    Setup robot controllers: PID paramters
  • LongtermMemory.SnapshotName
    Name of snapshot to load the scene
  • SceneFileName
    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.
  • FloorPlane
    Indicates if the should be created or not. Default: true.
  • FloorTexture
    The texture file for the floor. By default, a standard texture is used
  • FixedTimeStepLoopNrSteps
    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.
  • FixedTimeStepStepTimeMS
    The simulation's internal timestep (fixed time step mode)
  • ReportVisuFrequency
    How often should the visualization data be published. Value is given in Hz. (0 to disable, default: 30)
  • ReportVisuTopicName
    The topic on which the visualization updates are published. Default: ReportVisuTopicName
  • ReportDataFrequency
    How often should the robot data be published. Value is given in Hz. (0 to disable, default: 30)

Constructor & Destructor Documentation

◆ Simulator()

Simulator ( )

◆ ~Simulator()

~Simulator ( )
override

Member Function Documentation

◆ activateObject()

void activateObject ( const std::string & objectName,
const Ice::Current & c = Ice::emptyCurrent )
override

◆ actuateRobotJoints()

void actuateRobotJoints ( const std::string & robotName,
const NameValueMap & angles,
const NameValueMap & velocities,
const Ice::Current & c = Ice::emptyCurrent )
override

◆ actuateRobotJointsPos()

void actuateRobotJointsPos ( const std::string & robotName,
const NameValueMap & angles,
const Ice::Current & c = Ice::emptyCurrent )
override

◆ actuateRobotJointsTorque()

void actuateRobotJointsTorque ( const std::string & robotName,
const NameValueMap & torques,
const Ice::Current & c = Ice::emptyCurrent )
override

◆ actuateRobotJointsVel()

void actuateRobotJointsVel ( const std::string & robotName,
const NameValueMap & velocities,
const Ice::Current & c = Ice::emptyCurrent )
override

◆ 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

◆ addObject()

void addObject ( const memoryx::ObjectClassBasePtr & objectClassBase,
const std::string & instanceName,
const PoseBasePtr & globalPose,
bool isStatic = false,
const Ice::Current & c = Ice::emptyCurrent )
override

◆ 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

◆ addRobot() [1/2]

std::string addRobot ( const std::string & filename,
const Ice::Current & c = Ice::emptyCurrent )
override

◆ addRobot() [2/2]

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 )
protected

Returns the name. On failure an empty string is returned.

◆ addRobotFromFile()

std::string addRobotFromFile ( const armarx::data::PackagePath & packagePath,
const Ice::Current & c = Ice::emptyCurrent )
override

◆ addScaledRobot()

std::string addScaledRobot ( const std::string & filename,
float scale,
const Ice::Current & c = Ice::emptyCurrent )
override

◆ addScaledRobotName()

std::string addScaledRobotName ( const std::string & instanceName,
const std::string & filename,
float scale,
const Ice::Current & c = Ice::emptyCurrent )
override

◆ addSnapshot()

bool addSnapshot ( memoryx::WorkingMemorySnapshotInterfacePrx snapshotInterfacePrx)

◆ applyForceObject()

void applyForceObject ( const std::string & objectName,
const Vector3BasePtr & force,
const Ice::Current & c = Ice::emptyCurrent )
override

◆ applyForceRobotNode()

void applyForceRobotNode ( const std::string & robotName,
const std::string & robotNodeName,
const Vector3BasePtr & force,
const Ice::Current & c = Ice::emptyCurrent )
override

◆ applyTorqueObject()

void applyTorqueObject ( const std::string & objectName,
const Vector3BasePtr & torque,
const Ice::Current & c = Ice::emptyCurrent )
override

◆ applyTorqueRobotNode()

void applyTorqueRobotNode ( const std::string & robotName,
const std::string & robotNodeName,
const Vector3BasePtr & torque,
const Ice::Current & c = Ice::emptyCurrent )
override

◆ createPropertyDefinitions()

PropertyDefinitionsPtr createPropertyDefinitions ( )
inlineoverridevirtual

◆ 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 handling.

◆ GetDefaultName()

std::string GetDefaultName ( )
static

◆ getDefaultName()

std::string getDefaultName ( ) const
overridevirtual

Retrieve default name of component.

Implement this method in each IceManagedObject. The default name of a is used if no name is specified in the factory method.

Returns
default name of the component (e.g. "KinematicUnit")

Implements ManagedIceObject.

◆ getDistance()

DistanceInfo getDistance ( const std::string & robotName,
const std::string & robotNodeName,
const std::string & worldObjectName,
const Ice::Current & c = Ice::emptyCurrent )
override

◆ getFixedTimeStepMS()

int getFixedTimeStepMS ( const Ice::Current & c = Ice::emptyCurrent)
override
Returns
The number of steps * the timestep in MS

◆ getObjectClassPoses()

ObjectClassInformationSequence getObjectClassPoses ( const std::string & robotName,
const std::string & frameName,
const std::string & className,
const Ice::Current & c = Ice::emptyCurrent )
override

◆ getObjectPose()

PoseBasePtr getObjectPose ( const std::string & objectName,
const Ice::Current & c = Ice::emptyCurrent )
override

◆ getRobotAngularVelocity()

Vector3BasePtr getRobotAngularVelocity ( const std::string & robotName,
const std::string & nodeName,
const Ice::Current & c = Ice::emptyCurrent )
override

◆ getRobotForceTorqueSensors()

ForceTorqueDataSeq getRobotForceTorqueSensors ( const std::string & robotName,
const Ice::Current & c = Ice::emptyCurrent )
override

◆ getRobotJointAngle()

float getRobotJointAngle ( const std::string & robotName,
const std::string & nodeName,
const Ice::Current & c = Ice::emptyCurrent )
override

◆ getRobotJointAngles()

NameValueMap getRobotJointAngles ( const std::string & robotName,
const Ice::Current & c = Ice::emptyCurrent )
override

◆ getRobotJointLimitHi()

float getRobotJointLimitHi ( const std::string & robotName,
const std::string & nodeName,
const Ice::Current & c = Ice::emptyCurrent )
override

◆ getRobotJointLimitLo()

float getRobotJointLimitLo ( const std::string & robotName,
const std::string & nodeName,
const Ice::Current & c = Ice::emptyCurrent )
override

◆ getRobotJointTorques()

NameValueMap getRobotJointTorques ( const std::string & robotName,
const Ice::Current & c = Ice::emptyCurrent )
override

◆ getRobotJointVelocities()

NameValueMap getRobotJointVelocities ( const std::string & robotName,
const Ice::Current & c = Ice::emptyCurrent )
override

◆ getRobotJointVelocity()

float getRobotJointVelocity ( const std::string & robotName,
const std::string & nodeName,
const Ice::Current & c = Ice::emptyCurrent )
override

◆ getRobotLinearVelocity()

Vector3BasePtr getRobotLinearVelocity ( const std::string & robotName,
const std::string & nodeName,
const Ice::Current & c = Ice::emptyCurrent )
override

◆ getRobotMass()

float getRobotMass ( const std::string & robotName,
const Ice::Current & c = Ice::emptyCurrent )
override

◆ getRobotMaxTorque()

float getRobotMaxTorque ( const std::string & robotName,
const std::string & nodeName,
const Ice::Current & c = Ice::emptyCurrent )
override

◆ getRobotNames()

Ice::StringSeq getRobotNames ( const Ice::Current & )
override

◆ getRobotNodeDistance()

DistanceInfo getRobotNodeDistance ( const std::string & robotName,
const std::string & robotNodeName1,
const std::string & robotNodeName2,
const Ice::Current & c = Ice::emptyCurrent )
override

◆ getRobotNodePose()

PoseBasePtr getRobotNodePose ( const std::string & robotName,
const std::string & robotNodeName,
const Ice::Current & c = Ice::emptyCurrent )
override

◆ getRobotPose()

PoseBasePtr getRobotPose ( const std::string & robotName,
const Ice::Current & c = Ice::emptyCurrent )
override

◆ getRobotState()

SimulatedRobotState getRobotState ( const std::string & robotName,
const Ice::Current &  )
override

◆ getScene()

SceneVisuData getScene ( const Ice::Current & c = Ice::emptyCurrent)
override

◆ getSimTime()

float getSimTime ( const Ice::Current & c = Ice::emptyCurrent)
override

◆ getSimulatorInformation()

SimulatorInformation getSimulatorInformation ( const ::Ice::Current & = Ice::emptyCurrent)
override

◆ getSpeed()

Ice::Float getSpeed ( const Ice::Current & c = Ice::emptyCurrent)
override

◆ getStepTimeMS()

Ice::Int getStepTimeMS ( const ::Ice::Current & = Ice::emptyCurrent)
override

◆ getTime()

Ice::Long getTime ( const Ice::Current & c = Ice::emptyCurrent)
override

◆ hasObject()

bool hasObject ( const std::string & instanceName,
const Ice::Current & c = Ice::emptyCurrent )
override

◆ hasRobot()

bool hasRobot ( const std::string & robotName,
const Ice::Current & c = Ice::emptyCurrent )
override

◆ hasRobotNode()

bool hasRobotNode ( const std::string & robotName,
const std::string & robotNodeName,
const Ice::Current & c = Ice::emptyCurrent )
override

◆ initializeData()

void initializeData ( )
protected

◆ isRunning()

bool isRunning ( const Ice::Current & c = Ice::emptyCurrent)
override

◆ loadAgentsFromSnapshot()

bool loadAgentsFromSnapshot ( memoryx::WorkingMemorySnapshotInterfacePrx snapshotInterfacePrx)

◆ 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

◆ 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

◆ onConnectComponent()

void onConnectComponent ( )
overridevirtual

Pure virtual hook for the subclass.

Is called once all dependencies of the object have been resolved and Ice connection is established. This hook is called whenever the dependencies are found. That means if the a depedency crashes or shuts down, the ManagedIceObject goes into disconnected state. When the dependencies are found again, this hook is called again.

See also
onDisconnectComponent()

Implements ManagedIceObject.

◆ onDisconnectComponent()

void onDisconnectComponent ( )
overridevirtual

Hook for subclass.

Is called if a dependency of the object got lost (crash, network error, stopped, ...). This hook should be the inverse to onConnectComponent(). So that onDisconnectComponent() and onConnectComponent() can be called alternatingly and the ManagedIceObject remains in valid states. *

See also
onConnectComponent

Reimplemented from ManagedIceObject.

◆ onExitComponent()

void onExitComponent ( )
overridevirtual

Hook for subclass.

Is called once the component terminates. Use for cleanup. Only called once.

Reimplemented from ManagedIceObject.

◆ onInitComponent()

void onInitComponent ( )
overridevirtual

Pure virtual hook for the subclass.

Is called once initialization of the ManagedIceObject is done. This hook is called in the implenting class once and never again during the lifecyle of the object. This function is called as soon as the ManagedIceObject was added to the ArmarXManager. Called in an own thread and not the thread it was created in.

Implements ManagedIceObject.

◆ pause()

void pause ( const Ice::Current & c = Ice::emptyCurrent)
override

◆ 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 loaded via a MemoryX snapshot, the working memory is cleared) Then, the setup is re-loaded similar to the startup procedure.

◆ removeObject()

void removeObject ( const std::string & instanceName,
const Ice::Current &  )
override

◆ removeRobot()

bool removeRobot ( const std::string & robotName,
const Ice::Current & c = Ice::emptyCurrent )

◆ reportDataLoop()

void reportDataLoop ( )
protected

◆ reportVisuLoop()

void reportVisuLoop ( )
protected

◆ requestFileManager()

memoryx::GridFileManagerPtr requestFileManager ( )
protected

◆ resetData()

void resetData ( bool clearWorkingMemory = false)
protected

resetData Clears all data

Parameters
clearWorkingMemoryIf set, the working memory is also cleared.

◆ run()

void run ( )
override

◆ setObjectPose()

void setObjectPose ( const std::string & objectName,
const PoseBasePtr & globalPose,
const Ice::Current & c = Ice::emptyCurrent )
override

◆ setObjectSimulationType()

void setObjectSimulationType ( const std::string & objectName,
armarx::SimulationType type,
const Ice::Current & c = Ice::emptyCurrent )
override

◆ setRobotAngularVelocity()

void setRobotAngularVelocity ( const std::string & robotName,
const std::string & robotNodeName,
const Vector3BasePtr & vel,
const Ice::Current & c = Ice::emptyCurrent )
override

◆ setRobotAngularVelocityRobotRootFrame()

void setRobotAngularVelocityRobotRootFrame ( const std::string & robotName,
const std::string & robotNodeName,
const Vector3BasePtr & vel,
const Ice::Current & c = Ice::emptyCurrent )
override

◆ setRobotLinearVelocity()

void setRobotLinearVelocity ( const std::string & robotName,
const std::string & robotNodeName,
const Vector3BasePtr & vel,
const Ice::Current & c = Ice::emptyCurrent )
override

◆ setRobotLinearVelocityRobotRootFrame()

void setRobotLinearVelocityRobotRootFrame ( const std::string & robotName,
const std::string & robotNodeName,
const Vector3BasePtr & vel,
const Ice::Current & c = Ice::emptyCurrent )
override

◆ setRobotMaxTorque()

void setRobotMaxTorque ( const std::string & robotName,
const std::string & nodeName,
float maxTorque,
const Ice::Current & c = Ice::emptyCurrent )
override

◆ setRobotPose()

void setRobotPose ( const std::string & robotName,
const PoseBasePtr & globalPose,
const Ice::Current & c = Ice::emptyCurrent )
override

◆ 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.

setSpeed(2) leads to 2 virtual seconds passing every 1 real second (provided the simulation is able to keep up)

Parameters
newSpeednew scaling factor for speed

◆ showContacts()

void showContacts ( bool enable,
const std::string & layerName,
const Ice::Current & c = Ice::emptyCurrent )
override

◆ shutdownSimulationLoop()

void shutdownSimulationLoop ( )
protected

stop the simulation and join the simulation thread

◆ simulationLoop()

void simulationLoop ( )
protected

◆ start()

void start ( const Ice::Current & c = Ice::emptyCurrent)
override

◆ stateFromRobotInfo()

SimulatedRobotState stateFromRobotInfo ( RobotInfo const & robot,
IceUtil::Time timestamp )
protected

◆ step()

void step ( const Ice::Current & c = Ice::emptyCurrent)
override

◆ stop()

void stop ( const Ice::Current & c = Ice::emptyCurrent)
override

◆ 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 = true first.

◆ updateRobotTopics()

bool updateRobotTopics ( )
protected

Member Data Documentation

◆ classInstanceMap

std::map<std::string, std::vector<std::string> > classInstanceMap
protected

Stores all instances that belong to a class.

◆ commonStorageName

std::string commonStorageName
protected

◆ condSimulatorThreadRunning

std::condition_variable condSimulatorThreadRunning
protected

◆ contactLayerName

std::string contactLayerName
protected

◆ currentComTimeMS

float currentComTimeMS = 0
protected

Stores the time that was needed for communictaion.

◆ currentSimTimeMS

float currentSimTimeMS = 0
protected

Stores the time that was needed to perform the last simulation loop.

◆ currentSyncTimeMS

float currentSyncTimeMS = 0
protected

stores the time that was needed to sync the data

◆ entityDrawerPrx

memoryx::EntityDrawerInterfacePrx entityDrawerPrx
protected

Drawing contacts.

◆ fileManager

memoryx::GridFileManagerPtr fileManager
protected

◆ globalRobotLocalization

GlobalRobotPoseLocalizationListenerPrx globalRobotLocalization
protected

◆ lastPublishedContacts

int lastPublishedContacts = 0
protected

◆ longtermMemoryPrx

memoryx::LongtermMemoryInterfacePrx longtermMemoryPrx
protected

◆ memoryPrx

memoryx::WorkingMemoryInterfacePrx memoryPrx
protected

◆ objectFinder

ObjectFinder objectFinder
protected

Constructed once based on the ObjectPackage property.

◆ physicsWorld

SimulatedWorldPtr physicsWorld
protected

◆ priorKnowledgeName

std::string priorKnowledgeName
protected

◆ priorKnowledgePrx

memoryx::PriorKnowledgeInterfacePrx priorKnowledgePrx
protected

◆ publishContacts

bool publishContacts = false
protected

◆ reportDataTask

PeriodicTask<Simulator>::pointer_type reportDataTask
protected

The report data task.

◆ reportRobotPose

bool reportRobotPose = false
protected

◆ reportVisuTask

PeriodicTask<Simulator>::pointer_type reportVisuTask
protected

The report visu task.

◆ reportVisuTimeMS

std::atomic<float> reportVisuTimeMS = 0
protected

◆ simulationTask

PeriodicTask<Simulator>::pointer_type simulationTask
protected

The sim task.

◆ simulatorResetEventTopic

SimulatorResetEventPrx simulatorResetEventTopic
protected

◆ simulatorRunningMutex

std::mutex simulatorRunningMutex
protected

◆ simulatorThreadRunning

bool simulatorThreadRunning = false
protected

◆ simulatorThreadShutdown

bool simulatorThreadShutdown = false
protected

◆ simulatorVisuUpdateListenerPrx

SimulatorListenerInterfacePrx simulatorVisuUpdateListenerPrx
protected

◆ timeserverProxy

SimulatorTimeServerProxyPtr timeserverProxy
protected

Proxy object to offer the Timeserver proxy.

This is a hack to allow offering the proxies "Simulator" and "MasterTimeServer" at once

◆ timeServerSpeed

float timeServerSpeed = 0
protected

Scaling factor for the passing of time.

◆ timeTopicPrx

TimeServerListenerPrx timeTopicPrx
protected

The documentation for this class was generated from the following files: