RobWorkProject  24.12.4-
Classes | Public Types | Public Member Functions | Protected Member Functions | Protected Attributes | List of all members
GraspTaskSimulator Class Reference

A class for simulating multiple grasping tasks. More...

#include <GraspTaskSimulator.hpp>

Classes

struct  GraspedObject
 
struct  SimState
 

Public Types

enum  StepState { GRASPING , LIFTING , NEW_GRASP , APPROACH }
 
typedef rw::core::Ptr< GraspTaskSimulatorPtr
 smart pointer type
 

Public Member Functions

 GraspTaskSimulator (rwsim::dynamics::DynamicWorkCell::Ptr dwc, int nrThreads=1)
 constructor More...
 
virtual ~GraspTaskSimulator ()
 destructor
 
void load (const std::string &filename)
 load tasks
 
void load (rwlibs::task::GraspTask::Ptr graspTasks)
 
rwlibs::task::GraspTask::Ptr getTasks ()
 
rwlibs::task::GraspTask::Ptr getResult ()
 
size_t getNrTargets ()
 get the number of targets
 
ThreadSimulator::Ptr getSimulator ()
 
std::vector< ThreadSimulator::PtrgetSimulators ()
 
void init (rwsim::dynamics::DynamicWorkCell::Ptr dwc, const rw::kinematics::State &initState, std::string engineID="ODE")
 
void startSimulation (const rw::kinematics::State &initState)
 
void pauseSimulation ()
 
void resumeSimulation ()
 
bool isRunning ()
 
bool isFinished ()
 
int getStat (rwlibs::task::GraspResult::TestStatus status)
 get the statistics of the current simulations More...
 
std::vector< int > getStat ()
 get the current statistics. The array is based on the enumeration rwlibs::task::GraspTask::TestStatus
 
std::string getStatDescription ()
 
int getNrTargetsDone ()
 get the number of targets that have been simulated until now
 
void setAlwaysResting (bool alwaysResting)
 
void setStepDelay (int delay)
 add a delay each time the simulation has stepped. usefull for debuging or visualization. More...
 
void setWallTimeLimit (double limit)
 Sets the limit on wall time required for single grasp simulation. More...
 
void setSimTimeLimit (double limit)
 Sets the limit on internal simulation time for single grasp simulation. More...
 
void setStoreTimedStatePaths (bool enabled)
 Enable storing the simulations as TimedStatePaths. More...
 
void forceSimulateAll (bool enabled)
 force the simulation of all tasks, even those that already have results in specified in the task More...
 
std::map< rwlibs::task::GraspSubTask *, std::map< rwlibs::task::GraspTarget *, rw::trajectory::TimedStatePath > > getTimedStatePaths () const
 Get the current map of stored TimedStatePaths. More...
 

Protected Member Functions

virtual void graspFinished (SimState &sstate)
 Callback called after each finished grasp.
 
virtual void printGraspResult (SimState &sstate)
 Prints result after the grasp is finished.
 
virtual void simulationFinished (SimState &sstate)
 Callback called after simulation is finished.
 

Protected Attributes

rwsim::dynamics::DynamicWorkCell::Ptr _dwc
 
bool _requestSimulationStop
 
int _stepDelayMs
 
int _autoSaveInterval
 
double _maxObjectGripperDistanceThreshold
 
std::vector< int > _stat
 
bool _initialized
 
int _nrOfThreads
 
int _currentTargetIndex
 
bool _alwaysResting
 
int _gripperDim
 
int _failed
 
int _success
 
int _slipped
 
int _collision
 
int _timeout
 
int _simfailed
 
int _skipped
 
int _nrOfExperiments
 
int _lastSaveTaskIndex
 
int _totalNrOfExperiments
 
std::vector< rw::core::Ptr< rwsim::dynamics::RigidBody > > _objects
 
rwsim::dynamics::DynamicDevice::Ptr _dhand
 
rw::core::Ptr< rwsim::dynamics::RigidDevice_rhand
 
rw::models::Device::Ptr _hand
 
rw::core::Ptr< rwsim::dynamics::KinematicBody_hbase
 
rw::kinematics::MovableFrame_mbase
 
rwlibs::simulation::SimulatedController::Ptr _simGraspController
 
rw::kinematics::Frame_tcp
 
rw::kinematics::State _homeState
 
std::map< rwsim::simulator::ThreadSimulator::Ptr, SimState_simStates
 
std::vector< rwsim::simulator::ThreadSimulator::Ptr_simulators
 
rwlibs::task::GraspSubTask_currentTask
 
rwlibs::task::GraspTarget_currentTarget
 
rwlibs::task::GraspTask::Ptr _gtask
 
std::stack< std::pair< rwlibs::task::GraspSubTask *, rwlibs::task::GraspTarget * > > _taskQueue
 
rw::core::Ptr< rw::proximity::CollisionDetector_collisionDetector
 
boost::mutex _nextTargetLock
 
double _wallTimeLimit
 
double _simTimeLimit
 
bool _storeTimedStatePaths
 
bool _forceSimulateAll
 
std::map< rwlibs::task::GraspSubTask *, std::map< rwlibs::task::GraspTarget *, rw::trajectory::TimedStatePath > > _timedStatePaths
 

Detailed Description

A class for simulating multiple grasping tasks.

A grasping task can be considered as a sequence of the following states

The home and target poses are controlled through a task description file. Which is also used to write back all the results of the simulation.

The configuration of the simulation is setup through properties. These can be set from the command prompt, loaded by file, or edited in the gui. These properties include:

Constructor & Destructor Documentation

◆ GraspTaskSimulator()

constructor

Parameters
dwc[in] the dynamic workcell
nrThreads[in] the number of parallel simulations to run

Member Function Documentation

◆ forceSimulateAll()

void forceSimulateAll ( bool  enabled)
inline

force the simulation of all tasks, even those that already have results in specified in the task

Parameters
enabled

◆ getStat()

int getStat ( rwlibs::task::GraspResult::TestStatus  status)
inline

get the statistics of the current simulations

Parameters
status[in]
Returns

◆ getTimedStatePaths()

std::map<rwlibs::task::GraspSubTask*, std::map<rwlibs::task::GraspTarget*, rw::trajectory::TimedStatePath> > getTimedStatePaths ( ) const
inline

Get the current map of stored TimedStatePaths.

Note that setStoreTimedStatePaths must be set to enabled before running the simulation or the map will be empty. Please call this function only after simulation is finished.

Returns
a map of maps to a TimedStatePath (indexed by GraspSubTask pointer and a GraspTarget pointer).

◆ load()

void load ( rwlibs::task::GraspTask::Ptr  graspTasks)
Parameters
graspTasks

◆ setSimTimeLimit()

void setSimTimeLimit ( double  limit)
inline

Sets the limit on internal simulation time for single grasp simulation.

Parameters
limit[in] simulation time limit in seconds (default 30.0)

◆ setStepDelay()

void setStepDelay ( int  delay)
inline

add a delay each time the simulation has stepped. usefull for debuging or visualization.

Parameters
delay

◆ setStoreTimedStatePaths()

void setStoreTimedStatePaths ( bool  enabled)
inline

Enable storing the simulations as TimedStatePaths.

Parameters
enabled[in] whether or not a TimeStatePath should be stored for each grasp simulation.

◆ setWallTimeLimit()

void setWallTimeLimit ( double  limit)
inline

Sets the limit on wall time required for single grasp simulation.

Parameters
limit[in] wall time limit in seconds (default 30.0)

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