Go to the documentation of this file.
30 #include <ArmarXSimulation/interface/simulator/SimulatorInterface.h>
38 #include <SimDynamics/DynamicsEngine/DynamicsEngine.h>
41 #include <Eigen/Geometry>
66 SimulatorForceTorqueListenerInterfacePrx
prx;
73 EIGEN_MAKE_ALIGNED_OPERATOR_NEW
108 EIGEN_MAKE_ALIGNED_OPERATOR_NEW
119 template <
typename R,
typename A>
120 struct argType<R(SimDynamics::DynamicsEngine::*)(A)>
139 const std::map< std::string, float>& angles,
140 const std::map<std::string, float>& velocities) = 0;
142 const std::map< std::string, float>& angles) = 0;
144 const std::map< std::string, float>& velocities) = 0;
146 const std::map< std::string, float>& torques) = 0;
149 virtual void applyForceRobotNode(
const std::string& robotName,
const std::string& robotNodeName,
150 const Eigen::Vector3f& force) = 0;
151 virtual void applyTorqueRobotNode(
const std::string& robotName,
const std::string& robotNodeName,
152 const Eigen::Vector3f& torque) = 0;
154 virtual void applyForceObject(
const std::string& objectName,
const Eigen::Vector3f& force) = 0;
155 virtual void applyTorqueObject(
const std::string& objectName,
const Eigen::Vector3f& torque) = 0;
157 virtual bool hasObject(
const std::string& instanceName) = 0;
159 virtual std::map< std::string, float>
getRobotJointAngles(
const std::string& robotName) = 0;
160 virtual float getRobotJointAngle(
const std::string& robotName,
const std::string& nodeName) = 0;
166 virtual float getRobotJointLimitLo(
const std::string& robotName,
const std::string& nodeName) = 0;
167 virtual float getRobotJointLimitHi(
const std::string& robotName,
const std::string& nodeName) = 0;
170 virtual float getRobotMaxTorque(
const std::string& robotName,
const std::string& nodeName) = 0;
171 virtual void setRobotMaxTorque(
const std::string& robotName,
const std::string& nodeName,
float maxTorque) = 0;
175 virtual Eigen::Vector3f
getRobotLinearVelocity(
const std::string& robotName,
const std::string& nodeName) = 0;
176 virtual Eigen::Vector3f
getRobotAngularVelocity(
const std::string& robotName,
const std::string& nodeName) = 0;
179 const Eigen::Vector3f& vel) = 0;
181 const Eigen::Vector3f& vel) = 0;
183 const std::string& robotName,
const std::string& robotNodeName,
const Eigen::Vector3f& vel) = 0;
185 const std::string& robotName,
const std::string& robotNodeName,
const Eigen::Vector3f& vel) = 0;
194 virtual std::map<std::string, VirtualRobot::RobotPtr>
getRobots() = 0;
195 virtual bool hasRobot(
const std::string& robotName) = 0;
196 virtual bool hasRobotNode(
const std::string& robotName,
const std::string& robotNodeName) = 0;
197 virtual float getRobotMass(
const std::string& robotName) = 0;
200 const std::string& robotName,
const std::string& robotNodeName1,
const std::string& robotNodeName2) = 0;
202 const std::string& robotName,
const std::string& robotNodeName,
const std::string& worldObjectName) = 0;
206 virtual void objectGrasped(
const std::string& robotName,
const std::string& robotNodeName,
207 const std::string& objectName);
210 virtual void objectReleased(
const std::string& robotName,
const std::string& robotNodeName,
211 const std::string& objectName);
214 virtual std::vector<SimDynamics::DynamicsEngine::DynamicsContactInfo>
copyContacts() = 0;
232 virtual bool addRobot(std::string& robotInstanceName,
const std::string&
filename,
234 const std::string& filenameLocal =
"",
235 double pid_p = 10.0,
double pid_i = 0,
double pid_d = 0,
236 bool staticRobot =
false,
float scaling = 1.0f,
bool colModel =
false,
237 const std::map<std::string, float>& initConfig = {},
238 bool selfCollisions =
false);
240 double pid_p,
double pid_i,
double pid_d,
241 const std::string&
filename,
bool staticRobot =
false,
242 float scaling = 1.0f,
243 bool colModel =
false,
bool selfCollisions =
false);
254 const std::string& robotName,
255 const std::string& frameName) = 0;
269 VirtualRobot::SceneObject::Physics::SimulationType simType = VirtualRobot::SceneObject::Physics::eUnknown,
270 const std::string& localFilename =
"");
274 VirtualRobot::SceneObject::Physics::SimulationType simType = VirtualRobot::SceneObject::Physics::eUnknown,
276 const std::string& objectClassName =
"",
277 ObjectVisuPrimitivePtr primitiveData = {},
278 const std::string&
project =
""
287 VirtualRobot::SceneObject::Physics::SimulationType simType = VirtualRobot::SceneObject::Physics::eUnknown);
289 VirtualRobot::SceneObject::Physics::SimulationType simType = VirtualRobot::SceneObject::Physics::eUnknown);
291 virtual void setRobotNodeSimType(
const std::string& robotName,
const std::string& robotNodeName,
292 VirtualRobot::SceneObject::Physics::SimulationType simType) = 0;
293 virtual void setObjectSimType(
const std::string& objectName, VirtualRobot::SceneObject::Physics::SimulationType simType) = 0;
294 virtual std::vector<VirtualRobot::SceneObjectPtr>
getObjects() = 0;
326 virtual void enableLogging(
const std::string& robotName,
const std::string& logFile);
333 virtual bool removeRobot(
const std::string& robotName);
370 virtual void setupFloor(
bool enable,
const std::string& floorTexture);
392 VirtualRobot::SceneObject::Physics::SimulationType simType) = 0;
396 const std::string&
filename,
bool staticRobot,
bool selfCollisions) = 0;
401 virtual bool objectGraspedEngine(
const std::string& robotName,
const std::string& robotNodeName,
402 const std::string& objectName,
Eigen::Matrix4f& storeLocalTransform) = 0;
404 virtual bool objectReleasedEngine(
const std::string& robotName,
const std::string& robotNodeName,
405 const std::string& objectName) = 0;
408 virtual void setupFloorEngine(
bool enable,
const std::string& floorTexture) = 0;
416 std::map<std::string, armarx::PoseBasePtr>& objMap) = 0;
422 Eigen::Vector3f& linearVelocity,
423 Eigen::Vector3f& angularVelocity) = 0;
428 std::map< std::string, armarx::PoseBasePtr >& objMap) = 0;
virtual armarx::DistanceInfo getRobotNodeDistance(const std::string &robotName, const std::string &robotNodeName1, const std::string &robotNodeName2)=0
float simStepExecutionDurationMS
std::map< std::string, int > engineMtxAccCalls
EIGEN_MAKE_ALIGNED_OPERATOR_NEW std::vector< RobotInfo > robots
typename argType< setMutexFunc >::type MutexPtrType
virtual int getFixedTimeStepMS()=0
std::map< std::string, IceUtil::Time > syncMtxLastTime
virtual VirtualRobot::RobotPtr adaptRobotToWorld(VirtualRobot::RobotPtr)
NameValueMap jointTorques
virtual bool synchronizeSceneObjectPoses(VirtualRobot::SceneObjectPtr currentObjEngine, std::map< std::string, armarx::PoseBasePtr > &objMap)=0
SceneVisuData simVisuData
decltype(&SimDynamics::DynamicsEngine::setMutex) setMutexFunc
virtual bool objectGraspedEngine(const std::string &robotName, const std::string &robotNodeName, const std::string &objectName, Eigen::Matrix4f &storeLocalTransform)=0
create a joint
Eigen::Matrix4f node2objectTransformation
virtual ScopedRecursiveLockPtr getScopedSyncLock(const std::string &callStr)
virtual ForceTorqueDataSeq getRobotForceTorqueSensors(const std::string &robotName)=0
virtual void setObjectPose(const std::string &objectName, const Eigen::Matrix4f &globalPose)=0
virtual bool addRobot(std::string &robotInstanceName, const std::string &filename, Eigen::Matrix4f pose=Eigen::Matrix4f::Identity(), const std::string &filenameLocal="", double pid_p=10.0, double pid_i=0, double pid_d=0, bool staticRobot=false, float scaling=1.0f, bool colModel=false, const std::map< std::string, float > &initConfig={}, bool selfCollisions=false)
Load and add a robot.
virtual ~SimulatedWorld() override=default
std::map< std::string, float > engineMtxAccTime
virtual void updateContacts(bool enable)
std::map< std::string, Eigen::Matrix4f > robotNodePoses
MutexPtrType synchronizeMutex
NameValueMap jointVelocities
virtual bool hasObject(const std::string &instanceName)=0
virtual int getRobotJointAngleCount()
virtual void applyForceRobotNode(const std::string &robotName, const std::string &robotNodeName, const Eigen::Vector3f &force)=0
virtual void setRobotPose(const std::string &robotName, const Eigen::Matrix4f &globalPose)=0
std::shared_ptr< RobotInfo > RobotInfoPtr
float maxRealTimeSimSpeed
virtual void applyTorqueObject(const std::string &objectName, const Eigen::Vector3f &torque)=0
Eigen::Vector3f angularVelocity
virtual void setRobotMaxTorque(const std::string &robotName, const std::string &nodeName, float maxTorque)=0
virtual bool synchronizeRobots()
virtual void enableLogging(const std::string &robotName, const std::string &logFile)
virtual bool synchronizeSimulationData()
synchronizeSimulationData Update the sim data according to the internal physics models.
virtual void setRobotAngularVelocityRobotRootFrame(const std::string &robotName, const std::string &robotNodeName, const Eigen::Vector3f &vel)=0
The SimulatedWorld class encapsulates the whole physics simulation and the corresponding data.
virtual double getCurrentSimTime()
std::vector< GraspingInfo > attachedObjects
virtual void setRobotLinearVelocity(const std::string &robotName, const std::string &robotNodeName, const Eigen::Vector3f &vel)=0
virtual bool addObstacle(const std::string &filename, const Eigen::Matrix4f &pose=Eigen::Matrix4f::Identity(), VirtualRobot::SceneObject::Physics::SimulationType simType=VirtualRobot::SceneObject::Physics::eUnknown, const std::string &localFilename="")
Load and add an Obstacle (VirtualRobot xml file).
virtual bool resetData()
resetData Clears all data
virtual float getSimTime()
virtual float getRobotMaxTorque(const std::string &robotName, const std::string &nodeName)=0
std::shared_ptr< Scene > ScenePtr
virtual bool objectReleasedEngine(const std::string &robotName, const std::string &robotNodeName, const std::string &objectName)=0
remove a joint
float synchronizeDurationMS
std::shared_ptr< SimulatedWorldData > SimualtedWorldDataPtr
virtual bool synchronizeRobotNodePoses(const std::string &robotName, std::map< std::string, armarx::PoseBasePtr > &objMap)=0
virtual bool updateForceTorqueSensor(ForceTorqueInfo &ftInfo)=0
virtual bool removeRobotEngine(const std::string &robotName)=0
virtual Eigen::Matrix4f getRobotNodePose(const std::string &robotName, const std::string &robotNodeName)=0
virtual std::vector< std::string > getRobotNames()=0
SimulatedWorldData simReportData
virtual void activateObject(const std::string &objectName)
virtual ScopedRecursiveLockPtr getScopedEngineLock(const std::string &callStr)
std::string robotNodeName
SimulatorForceTorqueListenerInterfacePrx prx
virtual void objectReleased(const std::string &robotName, const std::string &robotNodeName, const std::string &objectName)
remove a joint
virtual VirtualRobot::SceneObjectPtr getFloor()=0
virtual SimulatedWorldData copyReportData()
virtual Eigen::Matrix4f getRobotPose(const std::string &robotName)=0
std::map< std::string, int > syncMtxAccCalls
virtual bool addObstacleEngine(VirtualRobot::SceneObjectPtr o, VirtualRobot::SceneObject::Physics::SimulationType simType)=0
virtual std::vector< std::string > getObstacleNames()=0
virtual float getSyncEngineTime()
void Identity(MatrixXX< N, N, T > *a)
virtual bool removeObstacle(const std::string &name)
virtual void setRobotAngularVelocity(const std::string &robotName, const std::string &robotNodeName, const Eigen::Vector3f &vel)=0
virtual FramedPosePtr toFramedPose(const Eigen::Matrix4f &globalPose, const std::string &robotName, const std::string &frameName)=0
toFramedPose Constructs a framed pose
Eigen::Vector3f currentForce
Eigen::Vector3f currentTorque
virtual Eigen::Vector3f getRobotAngularVelocity(const std::string &robotName, const std::string &nodeName)=0
virtual float getRobotJointLimitLo(const std::string &robotName, const std::string &nodeName)=0
virtual VirtualRobot::RobotPtr getRobot(const std::string &robotName)=0
virtual bool removeObstacleEngine(const std::string &name)=0
virtual void setRobotNodeSimType(const std::string &robotName, const std::string &robotNodeName, VirtualRobot::SceneObject::Physics::SimulationType simType)=0
virtual void setupFloorEngine(bool enable, const std::string &floorTexture)=0
std::shared_ptr< ScopedRecursiveLock > ScopedRecursiveLockPtr
virtual void objectGrasped(const std::string &robotName, const std::string &robotNodeName, const std::string &objectName)
create a joint
virtual bool hasRobot(const std::string &robotName)=0
std::scoped_lock< MutexType > ScopedRecursiveLock
VirtualRobot::ForceTorqueSensorPtr ftSensor
virtual armarx::DistanceInfo getDistance(const std::string &robotName, const std::string &robotNodeName, const std::string &worldObjectName)=0
virtual std::map< std::string, float > getRobotJointAngles(const std::string &robotName)=0
std::vector< ForceTorqueInfo > forceTorqueSensors
virtual void stepPhysicsFixedTimeStep()=0
Perform one simulation step.
const KinematicUnitDatafieldCreator jointVelocities("jointVelocities")
virtual bool removeRobot(const std::string &robotName)
virtual void actuateRobotJointsTorque(const std::string &robotName, const std::map< std::string, float > &torques)=0
virtual float getRobotMass(const std::string &robotName)=0
Eigen::Vector3f linearVelocity
virtual std::map< std::string, float > getRobotJointTorques(const std::string &robotName)=0
virtual void stepPhysicsRealTime()=0
Perform one simulation step.
std::string robotNodeName
virtual std::vector< SimDynamics::DynamicsEngine::DynamicsContactInfo > copyContacts()=0
virtual float getSimulationStepTimeMeasured()
getSimulationStepTimeMeasured
virtual float getSimulationStepDuration()
getSimulationStepDuration
virtual bool synchronizeSimulationDataEngine()=0
virtual void setRobotLinearVelocityRobotRootFrame(const std::string &robotName, const std::string &robotNodeName, const Eigen::Vector3f &vel)=0
armarx::core::time::DateTime Time
virtual SceneVisuData copySceneVisuData()
copySceneVisuData Creates a copy of the visualization data
virtual bool hasRobotNode(const std::string &robotName, const std::string &robotNodeName)=0
virtual Eigen::Vector3f getRobotLinearVelocity(const std::string &robotName, const std::string &nodeName)=0
virtual void applyTorqueRobotNode(const std::string &robotName, const std::string &robotNodeName, const Eigen::Vector3f &torque)=0
SimulatorRobotListenerInterfacePrx simulatorRobotListenerPrx
EIGEN_MAKE_ALIGNED_OPERATOR_NEW RobotInfo()
virtual std::vector< VirtualRobot::SceneObjectPtr > getObjects()=0
virtual void actuateRobotJointsVel(const std::string &robotName, const std::map< std::string, float > &velocities)=0
virtual bool removeRobots()
class A(deque< T, A >)) ARMARX_OVERLOAD_STD_HASH_FOR_ITERABLE((class T
Enables hashing of std::list.
virtual int getObjectCount()
const KinematicUnitDatafieldCreator jointAngles("jointAngles")
virtual float getRobotJointLimitHi(const std::string &robotName, const std::string &nodeName)=0
virtual void actuateRobotJointsPos(const std::string &robotName, const std::map< std::string, float > &angles)=0
virtual void applyForceObject(const std::string &objectName, const Eigen::Vector3f &force)=0
std::shared_ptr< SimulatedWorld > SimulatedWorldPtr
virtual bool addRobotEngine(VirtualRobot::RobotPtr robot, double pid_p, double pid_i, double pid_d, const std::string &filename, bool staticRobot, bool selfCollisions)=0
MatrixXX< 4, 4, float > Matrix4f
Base Class for all Logging classes.
std::string robotTopicName
double currentSyncTimeSec
virtual void setObjectSimType(const std::string &objectName, VirtualRobot::SceneObject::Physics::SimulationType simType)=0
virtual bool addScene(const std::string &filename, VirtualRobot::SceneObject::Physics::SimulationType simType=VirtualRobot::SceneObject::Physics::eUnknown)
Load and add an Scene (VirtualRobot xml file).
virtual void resetSimTime()
boost::intrusive_ptr< SceneObject > SceneObjectPtr
MutexPtrType::element_type MutexType
virtual Eigen::Matrix4f getObjectPose(const std::string &objectName)=0
virtual void setupFloor(bool enable, const std::string &floorTexture)
virtual SimulatedWorldData & getReportData()
virtual void actuateRobotJoints(const std::string &robotName, const std::map< std::string, float > &angles, const std::map< std::string, float > &velocities)=0
virtual bool getRobotStatus(const std::string &robotName, NameValueMap &jointAngles, NameValueMap &jointVelocities, NameValueMap &jointTorques, Eigen::Vector3f &linearVelocity, Eigen::Vector3f &angularVelocity)=0
virtual float getRobotJointVelocity(const std::string &robotName, const std::string &nodeName)=0
const KinematicUnitDatafieldCreator jointTorques("jointTorques")
virtual bool removeObstacles()
std::map< std::string, IceUtil::Time > engineMtxLastTime
virtual std::map< std::string, VirtualRobot::RobotPtr > getRobots()=0
virtual float getRobotJointAngle(const std::string &robotName, const std::string &nodeName)=0
This file offers overloads of toIce() and fromIce() functions for STL container types.
std::map< std::string, float > syncMtxAccTime
virtual std::map< std::string, float > getRobotJointVelocities(const std::string &robotName)=0
virtual int getContactCount()
std::shared_ptr< class Robot > RobotPtr
std::shared_ptr< ForceTorqueInfo > ForceTorqueInfoPtr
virtual bool synchronizeObjects()=0
The SimulatedWorldData class This data is queried by the simulated in order to offer it via topics.