RobWorkProject  23.9.11-
Classes | Public Types | Public Member Functions | Protected Types | Protected Member Functions | List of all members
EngineTest Class Referenceabstract

Generic test type for physics engines, which provides a factory for standard tests along with an extension point for user defined tests. More...

#include <EngineTest.hpp>

Inherited by IntegratorTest.

Classes

struct  EngineLoopInfo
 The info passed in a callback function. More...
 
class  Factory
 A factory for engine tests. This factory also defines an ExtensionPoint. More...
 
struct  Failure
 Format for a failure to an engine test. More...
 
struct  Result
 A result of an engine test. Each test can return multiple results. More...
 
class  TestHandle
 Handle for a concrete test run, which makes it possible to interact with the test during simulation. More...
 

Public Types

typedef rw::core::Ptr< EngineTestPtr
 Smart pointer to EngineTest.
 
typedef std::function< void(double time, bool failed, bool done)> TimeCallback
 The callback type for the current simulation time.
 

Public Member Functions

 EngineTest ()
 Construct new test.
 
virtual ~EngineTest ()
 Destructor.
 
virtual bool isEngineSupported (const std::string &engineID) const =0
 Check if engine with specific name is supported by the test. More...
 
virtual TestHandle::Ptr runThread (const std::string &engineID, const rw::core::PropertyMap &parameters, rw::core::Ptr< rwsim::log::SimulatorLogScope > verbose, rw::core::Ptr< rw::common::ThreadTask > task)
 Run the test in a separate thread. More...
 
virtual void run (TestHandle::Ptr handle, const std::string &engineID, const rw::core::PropertyMap &parameters, rw::core::Ptr< rwsim::log::SimulatorLogScope > verbose=NULL)=0
 Run the test. More...
 
virtual double getRunTime () const =0
 Get the length of the simulation. More...
 
virtual rw::core::Ptr< rwsim::dynamics::DynamicWorkCellgetDWC (const rw::core::PropertyMap &map)=0
 Get the dynamic workcell used by the test. More...
 
virtual rw::core::Ptr< rw::core::PropertyMapgetDefaultParameters () const
 Get the default parameters used by the test. More...
 
virtual std::vector< rw::core::Ptr< rw::core::PropertyMap > > getPredefinedParameters () const
 Get a vector of predefined parameters. More...
 

Protected Types

typedef std::function< void(rw::core::Ptr< const rwsim::dynamics::DynamicWorkCell >, rw::kinematics::State &)> InitCallback
 Type for a function initializing the state.
 
typedef std::function< void(const EngineLoopInfo &)> TestCallback
 Type for a callback function.
 

Protected Member Functions

void runEngineLoop (double dt, TestHandle::Ptr handle, const std::string &engineID, const rw::core::PropertyMap &parameters, rw::core::Ptr< rwsim::log::SimulatorLogScope > verbose, TestCallback callback=0, InitCallback initialize=0)
 A standard stepping loop provided as a convenience for test implementations. More...
 

Detailed Description

Generic test type for physics engines, which provides a factory for standard tests along with an extension point for user defined tests.

Member Function Documentation

◆ getDefaultParameters()

virtual rw::core::Ptr<rw::core::PropertyMap> getDefaultParameters ( ) const
virtual

Get the default parameters used by the test.

Returns
the default test parameters.

Reimplemented in IntegratorTest.

◆ getDWC()

virtual rw::core::Ptr<rwsim::dynamics::DynamicWorkCell> getDWC ( const rw::core::PropertyMap map)
pure virtual

Get the dynamic workcell used by the test.

Parameters
map[in] properties for test workcell.
Returns
a smart pointer to a dynamic workcell.

Implemented in IntegratorTest.

◆ getPredefinedParameters()

virtual std::vector<rw::core::Ptr<rw::core::PropertyMap> > getPredefinedParameters ( ) const
virtual

Get a vector of predefined parameters.

Returns
the predefines parameters.

◆ getRunTime()

virtual double getRunTime ( ) const
pure virtual

Get the length of the simulation.

Returns
the length of the simulation.

Implemented in IntegratorSpringTest, IntegratorRotationTest, and IntegratorGravityTest.

◆ isEngineSupported()

virtual bool isEngineSupported ( const std::string &  engineID) const
pure virtual

Check if engine with specific name is supported by the test.

Parameters
engineID[in] the id of the engine.
Returns
true if supported, false otherwise.

Implemented in IntegratorTest.

◆ run()

virtual void run ( TestHandle::Ptr  handle,
const std::string &  engineID,
const rw::core::PropertyMap parameters,
rw::core::Ptr< rwsim::log::SimulatorLogScope verbose = NULL 
)
pure virtual

Run the test.

Parameters
handle[in/out] a TestHandle where the results of the test will be added to.
engineID[in] the id of the engine to run test for.
parameters[in] the parameters for the test run.
verbose[in] (optional) record detailed internal debug information in the engine during simulation.

◆ runEngineLoop()

void runEngineLoop ( double  dt,
TestHandle::Ptr  handle,
const std::string &  engineID,
const rw::core::PropertyMap parameters,
rw::core::Ptr< rwsim::log::SimulatorLogScope verbose,
TestCallback  callback = 0,
InitCallback  initialize = 0 
)
protected

A standard stepping loop provided as a convenience for test implementations.

Parameters
dt[in] the time step to use.
handle[in/out] a TestHandle where the results of the test will be added to.
engineID[in] the id of the engine to run test for.
parameters[in] the parameters for the test run.
verbose[in] record detailed internal debug information in the engine during simulation.
callback[in] (optional) call a function after each step of the simulation.
initialize[in] (optional) call a function that sets the initial state.

◆ runThread()

virtual TestHandle::Ptr runThread ( const std::string &  engineID,
const rw::core::PropertyMap parameters,
rw::core::Ptr< rwsim::log::SimulatorLogScope verbose,
rw::core::Ptr< rw::common::ThreadTask task 
)
virtual

Run the test in a separate thread.

Parameters
engineID[in] the id of the engine to run test for.
parameters[in] the parameters for the test run.
verbose[in] record detailed internal debug information in the engine during simulation.
task[in] the task to add simulation work to.
Returns
a TestHandle which makes it possible to interact with the test during the test run.

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