RobWorkProject  23.9.11-
Public Types | Public Member Functions | List of all members
BodyController Class Reference

A Controller that use a PD loop to follow a trajectory generated from different target types. If the body is a Kinematic body then the velocities of the body is directly controlled, else wrenches are used to control the body. More...

#include <BodyController.hpp>

Inherits Controller, and SimulatedController.

Public Types

typedef rw::core::Ptr< BodyControllerPtr
 Smart pointer type to this class.
 
- Public Types inherited from Controller
typedef rw::core::Ptr< ControllerPtr
 smart poiner definition for controller
 
- Public Types inherited from SimulatedController
typedef rw::core::Ptr< SimulatedControllerPtr
 smart pointer type of this class
 
- Public Types inherited from Stateless
typedef rw::core::Ptr< StatelessPtr
 Smart pointer type for Stateless.
 

Public Member Functions

 BodyController (const std::string &name)
 Construct new controller. More...
 
virtual ~BodyController ()
 Destructor.
 
void setTarget (rw::core::Ptr< rwsim::dynamics::Body > body, const rw::math::Transform3D<> &target, const rw::kinematics::State &state, double maxLinVel=0.5, double maxLinAcc=1.0, double maxAngVel=0.4, double maxAngAcc=1.0)
 Sets the target transform of a body. The target is defined in world frame. More...
 
void setTarget (rw::core::Ptr< rwsim::dynamics::Body > body, rw::trajectory::Trajectory< rw::math::Transform3D<>>::Ptr traj)
 Set a target trajectory of a body. The initial configuration of the trajectory must match the current configuration of the body. More...
 
void setTarget (rw::core::Ptr< rwsim::dynamics::Body > body, const rw::math::VelocityScrew6D<> &velocity)
 Set a velocity target. More...
 
void setForceTarget (rw::core::Ptr< rwsim::dynamics::Body > body, rw::math::Vector3D<> force, rw::math::Vector3D<> torque)
 Set the force target of a body, the forces will be added such that the force on the body in each timestep will be timestep/[force;torque]. In other words the wrench [force;torque] is stretched over one second. More...
 
rw::math::Transform3D getTarget (rw::core::Ptr< rwsim::dynamics::Body > body)
 Get the current Cartesian target. More...
 
rw::trajectory::Trajectory< rw::math::Transform3D<> >::Ptr getTargetTrajectory (rw::core::Ptr< rwsim::dynamics::Body > body)
 Get the current target trajectory for body body. More...
 
void disableBodyControl (rw::core::Ptr< rwsim::dynamics::Body > body)
 Disable control of a specific body. More...
 
void disableBodyControl ()
 Disable control of all bodies.
 
void update (const rwlibs::simulation::Simulator::UpdateInfo &info, rw::kinematics::State &state)
 updates/steps the controller with time step dt. It will update the state state accordingly More...
 
void reset (const rw::kinematics::State &state)
 reset the controller to the applied state More...
 
std::string getControllerName ()
 get the name of this controller More...
 
void setEnabled (bool enabled)
 disable or enable this controller More...
 
bool isEnabled () const
 true if this controller is enabled More...
 
rwlibs::control::Controller::Ptr getControllerHandle (rwlibs::simulation::Simulator::Ptr sim)
 get the controller handle eg. statefull handle, associated with this simulated controller More...
 
- Public Member Functions inherited from Controller
virtual ~Controller ()
 destructor
 
const std::string & getName () const
 get the unique name of this controller More...
 
void setName (const std::string &name)
 set the name of the controller More...
 
- Public Member Functions inherited from SimulatedController
virtual rw::core::Ptr< rwlibs::control::ControllergetControllerHandle (rw::core::Ptr< rwlibs::simulation::Simulator > sim)=0
 get the controller handle eg. statefull handle, associated with this simulated controller More...
 
rw::core::Ptr< rw::models::ControllerModelgetControllerModel ()
 get the controllermodel of this simulated controller More...
 
- Public Member Functions inherited from Stateless
virtual ~Stateless ()
 destructor
 
virtual void registerIn (State &state)
 initialize this stateless data to a specific state More...
 
virtual void registerIn (StateStructure::Ptr state)
 register this stateless object in a statestructure.
 
virtual void unregister ()
 unregisters all state data of this stateless object
 
StateStructure::Ptr getStateStructure ()
 Get the state structure. More...
 
const StateStructure::Ptr getStateStructure () const
 Get the state structure. More...
 
bool isRegistered ()
 Check if object has registered its state. More...
 

Additional Inherited Members

- Protected Member Functions inherited from Controller
 Controller (const std::string &name)
 constructor More...
 
- Protected Member Functions inherited from SimulatedController
 SimulatedController (rw::models::ControllerModel::Ptr model)
 Constructor. More...
 
- Protected Member Functions inherited from Stateless
 Stateless ()
 constructor
 
template<class T >
void add (StatelessData< T > &data)
 implementations of sensor should add all their stateless data on initialization
 
void add (StateData *data)
 Add data. More...
 
void add (rw::core::Ptr< StateData > data)
 implementations of sensor should add all their state data on initialization
 
- Protected Attributes inherited from Stateless
bool _registered
 True if object has registered its state.
 
std::vector< rw::core::Ptr< StateData > > _datas
 Data.
 
StateStructure::Ptr _stateStruct
 The state structure.
 

Detailed Description

A Controller that use a PD loop to follow a trajectory generated from different target types. If the body is a Kinematic body then the velocities of the body is directly controlled, else wrenches are used to control the body.

Constructor & Destructor Documentation

◆ BodyController()

BodyController ( const std::string &  name)

Construct new controller.

Parameters
name[in] the name of the controller.

Member Function Documentation

◆ disableBodyControl()

void disableBodyControl ( rw::core::Ptr< rwsim::dynamics::Body body)

Disable control of a specific body.

Parameters
body[in] the body.

◆ getControllerHandle()

get the controller handle eg. statefull handle, associated with this simulated controller

Returns

◆ getControllerName()

std::string getControllerName ( )
inlinevirtual

get the name of this controller

Returns
name of this controller

Implements SimulatedController.

◆ getTarget()

Get the current Cartesian target.

Parameters
body[in] the body for which to get the target
Returns
6D Cartesian target

◆ getTargetTrajectory()

Get the current target trajectory for body body.

Parameters
body[in] body for which to get the target
Returns
target trajectory

◆ isEnabled()

bool isEnabled ( ) const
inlinevirtual

true if this controller is enabled

Returns

Implements SimulatedController.

◆ reset()

void reset ( const rw::kinematics::State state)
virtual

reset the controller to the applied state

Parameters
state[in] the state to reset to

Implements SimulatedController.

◆ setEnabled()

void setEnabled ( bool  enabled)
inlinevirtual

disable or enable this controller

Parameters
enabled

Implements SimulatedController.

◆ setForceTarget()

void setForceTarget ( rw::core::Ptr< rwsim::dynamics::Body body,
rw::math::Vector3D<>  force,
rw::math::Vector3D<>  torque 
)

Set the force target of a body, the forces will be added such that the force on the body in each timestep will be timestep/[force;torque]. In other words the wrench [force;torque] is stretched over one second.

The wrench is defined in world coordinates.

Parameters
body[in] the body.
force[in] the force.
torque[in] the torque.

◆ setTarget() [1/3]

void setTarget ( rw::core::Ptr< rwsim::dynamics::Body body,
const rw::math::Transform3D<> &  target,
const rw::kinematics::State state,
double  maxLinVel = 0.5,
double  maxLinAcc = 1.0,
double  maxAngVel = 0.4,
double  maxAngAcc = 1.0 
)

Sets the target transform of a body. The target is defined in world frame.

Parameters
body[in] the body to set target for.
target[in] the target transformation in world frame.
state[in] the state giving the current position.
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}\).

◆ setTarget() [2/3]

void setTarget ( rw::core::Ptr< rwsim::dynamics::Body body,
const rw::math::VelocityScrew6D<> &  velocity 
)

Set a velocity target.

Parameters
body[in] the body that should move.
velocity[in] the velocity target.

◆ setTarget() [3/3]

Set a target trajectory of a body. The initial configuration of the trajectory must match the current configuration of the body.

A Kinematic body will follow the exact path of the trajectory whereas a RigidBody will use a PD controller to follow the trajectory

Parameters
body[in] the body that should be moved
traj[in] the trajectory.

◆ update()

void update ( const rwlibs::simulation::Simulator::UpdateInfo info,
rw::kinematics::State state 
)
virtual

updates/steps the controller with time step dt. It will update the state state accordingly

Parameters
info[in] update information related to the time step.
state[in/out] the current state

Implements SimulatedController.


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