RobWorkProject
24.12.4-
|
A general physics engine interface for simulating dynamics of objects and robot devices. More...
#include <DynamicSimulator.hpp>
Inherits Simulator.
Public Types | |
typedef rw::core::Ptr< DynamicSimulator > | Ptr |
smart pointer type of this class | |
Public Types inherited from Simulator | |
typedef rw::core::Ptr< Simulator > | Ptr |
smart pointer type of simulator | |
Public Member Functions | |
DynamicSimulator (rwsim::dynamics::DynamicWorkCell::Ptr dworkcell, rw::core::Ptr< PhysicsEngine > pengine) | |
Constructor. More... | |
DynamicSimulator (rwsim::dynamics::DynamicWorkCell::Ptr dworkcell) | |
Constructor for a DynamicSimulator using a default PhysicsEngine. More... | |
virtual | ~DynamicSimulator () |
destructor | |
void | exitPhysics () |
cleans up the allocated storage | |
double | getTime () |
gets the the current simulated time More... | |
void | setEnabled (dynamics::Body::Ptr body, bool enabled) |
Enables or disables a body. More... | |
drawable::SimulatorDebugRender::Ptr | createDebugRender () |
create a debug render for the specific implementation More... | |
rw::core::PropertyMap & | getPropertyMap () |
Get the properties used by the simulator. More... | |
void | addController (rw::core::Ptr< rwlibs::simulation::SimulatedController > controller) |
add a simulated controller to this simulator More... | |
void | removeController (rw::core::Ptr< rwlibs::simulation::SimulatedController > controller) |
removes a simulated controller from this simulator More... | |
void | addBody (rwsim::dynamics::Body::Ptr body, rw::kinematics::State &state) |
Add a body to the simulator. More... | |
void | addBody (rwsim::dynamics::Body::Ptr body) |
Add a body to the simulator. More... | |
void | addDevice (rwsim::dynamics::DynamicDevice::Ptr dev, rw::kinematics::State &state) |
Add a device to the simulator. More... | |
void | addDevice (rwsim::dynamics::DynamicDevice::Ptr dev) |
Add a device to the simulator. More... | |
void | addSensor (rwlibs::simulation::SimulatedSensor::Ptr sensor, rw::kinematics::State &state) |
Add a simulated sensor to the simulator. More... | |
void | addSensor (rwlibs::simulation::SimulatedSensor::Ptr sensor) |
Add a simulated sensor to the simulator. More... | |
void | removeSensor (rwlibs::simulation::SimulatedSensor::Ptr sensor) |
Remove a simulated sensor from the simulator. More... | |
std::vector< rwlibs::simulation::SimulatedSensor::Ptr > | getSensors () |
get the list of simulated sensors More... | |
void | step (double dt) |
take a step forward in time with timestep dt. More... | |
rw::kinematics::State & | getState () |
get current state of simulator More... | |
void | reset (const rw::kinematics::State &state) |
reset velocity and acceleration of all bodies to 0. And sets the position of all bodies to that described in state More... | |
void | init (rw::kinematics::State &state) |
initialize simulator with state variables More... | |
void | setEnabled (rw::core::Ptr< rw::kinematics::Frame > f, bool) |
void | setDynamicsEnabled (rwsim::dynamics::Body::Ptr body, bool enabled) |
Enable or disable a body in the simulation. More... | |
void | setTarget (rwsim::dynamics::Body::Ptr body, const rw::math::Transform3D<> &target, rw::kinematics::State &state, double maxLinVel=0.5, double maxLinAcc=1.0, double maxAngVel=0.4, double maxAngAcc=1.0) |
Set a target position of a body. This will add forces/velocities to a body such that it moves toward the target pose. More... | |
void | setTarget (rwsim::dynamics::Body::Ptr body, const rw::math::Transform3D<> &target, double maxLinVel=0.5, double maxLinAcc=1.0, double maxAngVel=0.4, double maxAngAcc=1.0) |
Set a target position of a body. This will add forces/velocities to a body such that it moves toward the target pose. More... | |
void | setTarget (dynamics::Body::Ptr body, rw::trajectory::Trajectory< rw::math::Transform3D<>>::Ptr traj) |
Set a target trajectory for a body. More... | |
void | setTarget (dynamics::Body::Ptr body, const rw::math::VelocityScrew6D<> &velocity) |
Set a velocity target. More... | |
void | disableBodyControl (dynamics::Body::Ptr body) |
disables the target control of body body. More... | |
void | disableBodyControl () |
Disable all control for all bodies. | |
rwsim::control::BodyController::Ptr | getBodyController () |
Get the body controller. More... | |
void | attach (rwsim::dynamics::Body::Ptr b1, rwsim::dynamics::Body::Ptr b2) |
Attach bodies. More... | |
void | detach (rwsim::dynamics::Body::Ptr b1, rwsim::dynamics::Body::Ptr b2) |
Detach bodies. More... | |
rwsim::dynamics::DynamicWorkCell::Ptr | getDynamicWorkCell () |
Get the dynamic workcell used by the simulator. More... | |
void | forceUpdate (rwsim::dynamics::Body::Ptr body, rw::kinematics::State &state) |
this will force the physics engine to update the state of the body. This can be i.e. be used to teleport a rigid body to a new position. More... | |
Public Member Functions inherited from Simulator | |
virtual rw::sensor::Sensor::Ptr | getSensor (const std::string &name) |
get sensor with specific name | |
virtual rwlibs::control::Controller::Ptr | getController (const std::string &name) |
get controller with specific name | |
template<class SIMSENSORTYPE > | |
rw::sensor::Sensor::Ptr | getSensorHandle (SIMSENSORTYPE *ssensor) |
get sensorhandle to a statefull instance of the simulated sensor, controlling the sensor in this simulator. More... | |
template<class SIMSENSORTYPE > | |
bool | hasHandle (SIMSENSORTYPE *ssensor) |
Test if handle for simulatedsensor exists. More... | |
template<class SIMSENSORTYPE > | |
void | addHandle (SIMSENSORTYPE *ssensor, rw::sensor::Sensor::Ptr sensor) |
add handle to a specific simulated sensor More... | |
A general physics engine interface for simulating dynamics of objects and robot devices.
The general step looks like this:;
Foreach controller=_controllers controller->update(dt,state);
physicsEngine->step(dt, state);
Foreach sensor=_sensors sensor->update(dt,state)
DynamicSimulator | ( | rwsim::dynamics::DynamicWorkCell::Ptr | dworkcell, |
rw::core::Ptr< PhysicsEngine > | pengine | ||
) |
Constructor.
dworkcell | [in] the dynamic workcell. |
pengine | [in] the physics engine to use. |
DynamicSimulator | ( | rwsim::dynamics::DynamicWorkCell::Ptr | dworkcell | ) |
Constructor for a DynamicSimulator using a default PhysicsEngine.
dworkcell | [in] the dynamic workcell. |
|
inline |
Add a body to the simulator.
body | [in] the body to add. |
void addBody | ( | rwsim::dynamics::Body::Ptr | body, |
rw::kinematics::State & | state | ||
) |
Add a body to the simulator.
body | [in] the body to add. |
state | [in] the state giving the initial pose of the body. |
void addController | ( | rw::core::Ptr< rwlibs::simulation::SimulatedController > | controller | ) |
add a simulated controller to this simulator
controller | [in] the controller to add. |
|
inline |
Add a device to the simulator.
dev | [in] the device to add. |
void addDevice | ( | rwsim::dynamics::DynamicDevice::Ptr | dev, |
rw::kinematics::State & | state | ||
) |
Add a device to the simulator.
dev | [in] the device to add. |
state | [in/out] the state giving the initial configuration of the device, which might be changed. |
|
inline |
Add a simulated sensor to the simulator.
sensor | [in] the sensor to add. |
void addSensor | ( | rwlibs::simulation::SimulatedSensor::Ptr | sensor, |
rw::kinematics::State & | state | ||
) |
Add a simulated sensor to the simulator.
sensor | [in] the sensor to add. |
state | [in/out] if the sensor is not registered in the state, it will be registered. |
void attach | ( | rwsim::dynamics::Body::Ptr | b1, |
rwsim::dynamics::Body::Ptr | b2 | ||
) |
Attach bodies.
b1 | [in] first body. |
b2 | [in] second body. |
drawable::SimulatorDebugRender::Ptr createDebugRender | ( | ) |
create a debug render for the specific implementation
void detach | ( | rwsim::dynamics::Body::Ptr | b1, |
rwsim::dynamics::Body::Ptr | b2 | ||
) |
Detach bodies.
b1 | [in] first body. |
b2 | [in] second body. |
void disableBodyControl | ( | dynamics::Body::Ptr | body | ) |
disables the target control of body body.
body | [in] the body. |
void forceUpdate | ( | rwsim::dynamics::Body::Ptr | body, |
rw::kinematics::State & | state | ||
) |
this will force the physics engine to update the state of the body. This can be i.e. be used to teleport a rigid body to a new position.
body | [in] the body to update. |
state | [in] the state to update the body from. |
|
inline |
Get the body controller.
|
inline |
Get the dynamic workcell used by the simulator.
|
virtual |
Get the properties used by the simulator.
Implements Simulator.
std::vector<rwlibs::simulation::SimulatedSensor::Ptr> getSensors | ( | ) |
get the list of simulated sensors
|
virtual |
|
virtual |
|
virtual |
initialize simulator with state variables
Implements Simulator.
void removeController | ( | rw::core::Ptr< rwlibs::simulation::SimulatedController > | controller | ) |
removes a simulated controller from this simulator
controller | [in] the controller to remove. |
void removeSensor | ( | rwlibs::simulation::SimulatedSensor::Ptr | sensor | ) |
Remove a simulated sensor from the simulator.
sensor | [in] the sensor to remove. |
|
virtual |
reset velocity and acceleration of all bodies to 0. And sets the position of all bodies to that described in state
Implements Simulator.
void setDynamicsEnabled | ( | rwsim::dynamics::Body::Ptr | body, |
bool | enabled | ||
) |
Enable or disable a body in the simulation.
body | [in] the body. |
enabled | [in] boolean indicating if body should be enabled or not. |
void setEnabled | ( | dynamics::Body::Ptr | body, |
bool | enabled | ||
) |
Enables or disables a body.
body | [in] the body. |
enabled | [in] boolean indicating whether body should be enabled or disabled. |
|
virtual |
Enables or disables simulation of a frame
Implements Simulator.
void setTarget | ( | dynamics::Body::Ptr | body, |
const rw::math::VelocityScrew6D<> & | velocity | ||
) |
Set a velocity target.
body | [in] the body that should move. |
velocity | [in] the velocity target. |
void setTarget | ( | dynamics::Body::Ptr | body, |
rw::trajectory::Trajectory< rw::math::Transform3D<>>::Ptr | traj | ||
) |
Set a target trajectory for a body.
body | [in] the body. |
traj | [in] the trajectory. |
|
inline |
Set a target position of a body. This will add forces/velocities to a body such that it moves toward the target pose.
body | [in] the body to control |
target | [in] the target pose |
maxLinVel | [in] (optional) maximum linear velocity of the body in \(\frac{m}{s}\). |
maxLinAcc | [in] (optional) maximum linear acceleration of the body in \(\frac{m}{s^2}\). |
maxAngVel | [in] (optional) maximum angular velocity of the body in \(\frac{rad}{s}\). |
maxAngAcc | [in] (optional) maximum angular acceleration of the body in \(\frac{rad}{s^2}\). |
void setTarget | ( | rwsim::dynamics::Body::Ptr | body, |
const rw::math::Transform3D<> & | target, | ||
rw::kinematics::State & | state, | ||
double | maxLinVel = 0.5 , |
||
double | maxLinAcc = 1.0 , |
||
double | maxAngVel = 0.4 , |
||
double | maxAngAcc = 1.0 |
||
) |
Set a target position of a body. This will add forces/velocities to a body such that it moves toward the target pose.
body | [in] the body to control |
target | [in] the target pose |
state | [in] the current state. |
maxLinVel | [in] (optional) maximum linear velocity of the body in \(\frac{m}{s}\). |
maxLinAcc | [in] (optional) maximum linear acceleration of the body in \(\frac{m}{s^2}\). |
maxAngVel | [in] (optional) maximum angular velocity of the body in \(\frac{rad}{s}\). |
maxAngAcc | [in] (optional) maximum angular acceleration of the body in \(\frac{rad}{s^2}\). |
|
virtual |