mc_control::Gripper Struct Reference

A robot's gripper reprensentation. More...

#include <mc_control/generic_gripper.h>

Collaboration diagram for mc_control::Gripper:

Public Member Functions

 Gripper (const mc_rbdyn::Robot &robot, const std::vector< std::string > &jointNames, const std::string &robot_urdf, bool reverseLimits, const mc_rbdyn::RobotModule::Gripper::Safety &safety)
 Constructor. More...
 
 Gripper (const mc_rbdyn::Robot &robot, const std::vector< std::string > &jointNames, const std::vector< mc_rbdyn::Mimic > &mimics, bool reverseLimits, const mc_rbdyn::RobotModule::Gripper::Safety &safety)
 Constructor. More...
 
void resetDefaults ()
 Resets the gripper parameters to their default value (percentVMax, actualCommandDiffTrigger) More...
 
void saveConfig ()
 Saves the current gripper configuration parameters contained in Config. More...
 
void restoreConfig ()
 Restores the gripper configuration parameters from their saved value. More...
 
void configure (const mc_rtc::Configuration &config)
 Applies a new gripper configuration (safeties and targets) More...
 
void reset (const std::vector< double > &currentQ)
 Reset the gripper state to the current actual state of the gripper. More...
 
void reset (const Gripper &gripper)
 Reset from another gripper. More...
 
void run (double timeStep, mc_rbdyn::Robot &robot, mc_rbdyn::Robot &real)
 Run one iteration of control. More...
 
void setTargetQ (const std::vector< double > &targetQ)
 Set the target configuration of the active joints involved in the gripper. More...
 
void setTargetQ (const std::string &jointName, double targetQ)
 Set the target configuration of the specified active joint. More...
 
double getTargetQ (const std::string &jointName) const
 
std::vector< double > getTargetQ () const
 
void setTargetOpening (double targetOpening)
 Set the target opening of all gripper joints simultaneously. More...
 
void setTargetOpening (const std::string &jointName, double targetOpening)
 Set the target opening of a single gripper joint. More...
 
double getTargetOpening (const std::string &jointName) const
 Get the target opening of a single gripper joint. More...
 
std::vector< double > curPosition () const
 Get current configuration. More...
 
std::vector< double > curOpening () const
 Get current opening percentage. More...
 
double curOpening (const std::string &jointName) const
 Get the current opening of a single gripper joint. More...
 
const std::vector< std::string > & joints () const
 Returns all joints involved in the gripper. More...
 
const std::vector< std::string > & activeJoints () const
 Returns all active joints involved in the gripper. More...
 
bool hasActiveJoint (const std::string &jointName) const
 
const std::vector< double > & q () const
 Return all gripper joints configuration. More...
 
double opening () const
 Get the current opening percentage. More...
 
void percentVMAX (double percent)
 
double percentVMAX () const
 
void actualCommandDiffTrigger (double d)
 
double actualCommandDiffTrigger () const
 
void overCommandLimitIterN (unsigned int N)
 
unsigned int overCommandLimitIterN () const
 
void releaseSafetyOffset (double offset)
 
double releaseSafetyOffset () const
 
bool complete () const
 Check if the gripper motion stopped moving. More...
 
bool is_metric () const noexcept
 Returns true if a gripper is metric, i.e. all active joints are prismatic rather than revolute. More...
 
bool reversed () const noexcept
 When true the gripper is considered "open" when the joints' values are minimal. More...
 

Protected Types

using Config = mc_rbdyn::RobotModule::Gripper::Safety
 

Protected Member Functions

void setTargetOpening (size_t activeJointId, double targetOpening)
 Set the target opening of a single gripper joint by index. More...
 
void setTargetQ (size_t activeJointId, double targetQ)
 Set the target configuration of the specified active joint. More...
 
void setTargetQ_ (size_t activeJoints, double targetQ)
 Fast version of setTargetQ(size_t, double) without clamping. More...
 
void setTargetQ_ (const std::vector< double > &targetQ)
 Fast version of setTargetQ(std::vector<double>) More...
 
double curPosition (size_t jointId) const
 Current position of an active joint. More...
 
double curOpening (size_t jointId) const
 Current opening percentage of an active joint. More...
 
double targetOpening (size_t jointId) const
 Target opening percentage of an active joint. More...
 
double getTargetQ (size_t jointId) const
 Target opening angle of an active joint. More...
 
double clampQ (size_t activeJoint, double q)
 Clamp an active joint value within its joint limits. More...
 

Protected Attributes

std::vector< std::string > names
 
std::vector< std::string > active_joints
 
std::vector< size_t > active_joints_idx
 
std::vector< int > joints_mbc_idx
 
bool is_metric_
 
std::vector< double > closeP
 
std::vector< double > openP
 
std::vector< double > vmax
 
std::vector< std::pair< size_t, double > > mult
 
std::vector< double > offset
 
std::vector< double > _q
 
std::vector< double > targetQIn
 
std::vector< double > * targetQ
 
std::vector< double > reached_threshold_
 
std::vector< double > actualQ
 
Config config_
 
Config savedConfig_
 
Config defaultConfig_
 
std::vector< double > percentOpen
 
std::vector< bool > overCommandLimit
 
std::vector< unsigned int > overCommandLimitIter
 
bool reversed_ = false
 

Detailed Description

A robot's gripper reprensentation.

A gripper is composed of a set of joints that we want to control only through "manual" operations. It may include passive joints.

By default, a gripper is considered "open" when its joints' values are at maximum value and "closed" at minimum value. This behaviour can be reversed when the gripper is created.

In real operations the actuated joints are also monitored to avoid potential servo errors.

Member Typedef Documentation

◆ Config

Constructor & Destructor Documentation

◆ Gripper() [1/2]

mc_control::Gripper::Gripper ( const mc_rbdyn::Robot robot,
const std::vector< std::string > &  jointNames,
const std::string &  robot_urdf,
bool  reverseLimits,
const mc_rbdyn::RobotModule::Gripper::Safety safety 
)

Constructor.

Parameters
robotThe full robot including uncontrolled joints
jointNamesName of the active joints involved in the gripper
robot_urdfURDF of the robot
reverseLimitsIf set to true, then the gripper is considered "open" when the joints' values are minimal
safetyDefault gripper safety parameters

◆ Gripper() [2/2]

mc_control::Gripper::Gripper ( const mc_rbdyn::Robot robot,
const std::vector< std::string > &  jointNames,
const std::vector< mc_rbdyn::Mimic > &  mimics,
bool  reverseLimits,
const mc_rbdyn::RobotModule::Gripper::Safety safety 
)

Constructor.

This constructor does not use information from the URDF file

Parameters
robotRobot, must have the active joints of the gripper to work properly
jointNamesName of the active joints involved in the gripper
mimicsMimic joints for the gripper
reverseLimitsIf true, the gripper is considered "open" when the joints values are minimal
safetyDefault gripper safety parameters

Member Function Documentation

◆ activeJoints()

const std::vector<std::string>& mc_control::Gripper::activeJoints ( ) const
inline

Returns all active joints involved in the gripper.

◆ actualCommandDiffTrigger() [1/2]

double mc_control::Gripper::actualCommandDiffTrigger ( ) const
inline

Difference between the command and the reality that triggers the safety

◆ actualCommandDiffTrigger() [2/2]

void mc_control::Gripper::actualCommandDiffTrigger ( double  d)
inline

Set safety trigger threshold (difference between the command and the reality)

This safety is meant to prevent over-torques on position controlled grippers with no torque readings by checking how far the encoder output is from the desired command. If it is over the limit, it can only stay there for overCommandLimitIterN iterations before being released

◆ clampQ()

double mc_control::Gripper::clampQ ( size_t  activeJoint,
double  q 
)
protected

Clamp an active joint value within its joint limits.

◆ complete()

bool mc_control::Gripper::complete ( ) const

Check if the gripper motion stopped moving.

The gripper will stop if

  • the desired motion is finished
  • the gripper encountered an obstacle and gripper safety was triggered. This is defined by an encoder error threshold (actualCommandDiffTrigger) and a maximum number of iterations where the gripper is allowed to be at this threshold (overCommandLimitIterN)
Returns
True if gripper is not moving, False if it is moving

◆ configure()

void mc_control::Gripper::configure ( const mc_rtc::Configuration config)

Applies a new gripper configuration (safeties and targets)

◆ curOpening() [1/3]

std::vector<double> mc_control::Gripper::curOpening ( ) const

Get current opening percentage.

Returns
Current opening percentage of the active joints involved in the gripper

◆ curOpening() [2/3]

double mc_control::Gripper::curOpening ( const std::string &  jointName) const

Get the current opening of a single gripper joint.

Parameters
jointNameName of the active joint
Exceptions
std::runtime_errorif the joint name does not match any of the gripper's active joints
Returns
The joint's current opening percentage

◆ curOpening() [3/3]

double mc_control::Gripper::curOpening ( size_t  jointId) const
protected

Current opening percentage of an active joint.

◆ curPosition() [1/2]

std::vector<double> mc_control::Gripper::curPosition ( ) const

Get current configuration.

Returns
Current values of the active joints involved in the gripper

◆ curPosition() [2/2]

double mc_control::Gripper::curPosition ( size_t  jointId) const
protected

Current position of an active joint.

◆ getTargetOpening()

double mc_control::Gripper::getTargetOpening ( const std::string &  jointName) const

Get the target opening of a single gripper joint.

Parameters
jointNameName of the active joint
Exceptions
std::runtime_errorif the joint name does not match any of the gripper's active joints
Returns
The joint's target opening percentage

◆ getTargetQ() [1/3]

std::vector<double> mc_control::Gripper::getTargetQ ( ) const

Get the current gripper's target

Note
returns the current gripper position if no target has been set

◆ getTargetQ() [2/3]

double mc_control::Gripper::getTargetQ ( const std::string &  jointName) const

Get a joint's target angle

Exceptions
std::runtime_errorif the joint name does not match any of the gripper's active joints

◆ getTargetQ() [3/3]

double mc_control::Gripper::getTargetQ ( size_t  jointId) const
protected

Target opening angle of an active joint.

◆ hasActiveJoint()

bool mc_control::Gripper::hasActiveJoint ( const std::string &  jointName) const
inline

◆ is_metric()

bool mc_control::Gripper::is_metric ( ) const
inlinenoexcept

Returns true if a gripper is metric, i.e. all active joints are prismatic rather than revolute.

This only affects safety settings in the GUI

◆ joints()

const std::vector<std::string>& mc_control::Gripper::joints ( ) const
inline

Returns all joints involved in the gripper.

◆ opening()

double mc_control::Gripper::opening ( ) const

Get the current opening percentage.

Note
Returns an average of the current opening percentage of each joint
Returns
Current opening percentage

◆ overCommandLimitIterN() [1/2]

unsigned int mc_control::Gripper::overCommandLimitIterN ( ) const
inline

Number of iterations where actualCommandDiffTrigger() threshold may be exceeded before the security is triggered

◆ overCommandLimitIterN() [2/2]

void mc_control::Gripper::overCommandLimitIterN ( unsigned int  N)
inline

Number of iterations where actualCommandDiffTrigger() threshold may be exceeded before the security is triggered

◆ percentVMAX() [1/2]

double mc_control::Gripper::percentVMAX ( ) const

Get gripper speed (percentage of max velocity)

◆ percentVMAX() [2/2]

void mc_control::Gripper::percentVMAX ( double  percent)

Set gripper speed as a percentage of maximum velocity

◆ q()

const std::vector<double>& mc_control::Gripper::q ( ) const
inline

Return all gripper joints configuration.

Returns
Current values of all the gripper's joints, including passive joints

◆ releaseSafetyOffset() [1/2]

double mc_control::Gripper::releaseSafetyOffset ( ) const
inline

Offset by which the gripper is release if overCommandDiffTrigger is trigger for more than overCommandLimitIterN

◆ releaseSafetyOffset() [2/2]

void mc_control::Gripper::releaseSafetyOffset ( double  offset)
inline

Offset by which the gripper is released if overCommandDiffTrigger is trigger for more than overCommandLimitIterN

Parameters
offsetoffset angle in [rad] or distance in [meter]

◆ reset() [1/2]

void mc_control::Gripper::reset ( const Gripper gripper)

Reset from another gripper.

Parameters
gripperGripper used to reset this one

◆ reset() [2/2]

void mc_control::Gripper::reset ( const std::vector< double > &  currentQ)

Reset the gripper state to the current actual state of the gripper.

Parameters
currentQCurrent encoder values for the robot

◆ resetDefaults()

void mc_control::Gripper::resetDefaults ( )

Resets the gripper parameters to their default value (percentVMax, actualCommandDiffTrigger)

◆ restoreConfig()

void mc_control::Gripper::restoreConfig ( )

Restores the gripper configuration parameters from their saved value.

See also
saveConfig()

◆ reversed()

bool mc_control::Gripper::reversed ( ) const
inlinenoexcept

When true the gripper is considered "open" when the joints' values are minimal.

◆ run()

void mc_control::Gripper::run ( double  timeStep,
mc_rbdyn::Robot robot,
mc_rbdyn::Robot real 
)

Run one iteration of control.

Parameters
robotRobot for which this gripper control is running
realReal robot for which this gripper control is running

The gripper control updates both the robot's configuration and the output

◆ saveConfig()

void mc_control::Gripper::saveConfig ( )

Saves the current gripper configuration parameters contained in Config.

◆ setTargetOpening() [1/3]

void mc_control::Gripper::setTargetOpening ( const std::string &  jointName,
double  targetOpening 
)

Set the target opening of a single gripper joint.

Parameters
jointNameName of the active joint to move
targetOpeningOpening value ranging from 0 (closed) to 1 (open)
Exceptions
std::runtime_errorif the joint name does not match any of the gripper's active joints

◆ setTargetOpening() [2/3]

void mc_control::Gripper::setTargetOpening ( double  targetOpening)

Set the target opening of all gripper joints simultaneously.

Parameters
targetOpeningOpening value ranging from 0 (closed) to 1 (open)
Note
If the individual joint targets were set manually, they will move to match this new opening target. Depending on the maximum allowed velocity, this may result in fast gripper joint motions. Use with care if the gripper is currently grasping objects or close to collisions with the environment.

◆ setTargetOpening() [3/3]

void mc_control::Gripper::setTargetOpening ( size_t  activeJointId,
double  targetOpening 
)
protected

Set the target opening of a single gripper joint by index.

Parameters
activeJointIdIndex of the active joint
targetOpeningOpening value ranging from 0 (closed) to 1 (open)

◆ setTargetQ() [1/3]

void mc_control::Gripper::setTargetQ ( const std::string &  jointName,
double  targetQ 
)

Set the target configuration of the specified active joint.

Parameters
jointNameName of the gripper's active joint to move
targetQDesired value of the active joint
Exceptions
std::runtime_errorif the joint name does not match any of the gripper's active joints

◆ setTargetQ() [2/3]

void mc_control::Gripper::setTargetQ ( const std::vector< double > &  targetQ)

Set the target configuration of the active joints involved in the gripper.

Parameters
targetQDesired values of the active joints involved in the gripper
Exceptions
std::runtime_errorIf the targetQ size does not match the number of active joints

◆ setTargetQ() [3/3]

void mc_control::Gripper::setTargetQ ( size_t  activeJointId,
double  targetQ 
)
protected

Set the target configuration of the specified active joint.

Parameters
activeJointIdIndex of the gripper's active joint to move
targetQDesired value of the active joint. Clamps the target within the joint limits.

◆ setTargetQ_() [1/2]

void mc_control::Gripper::setTargetQ_ ( const std::vector< double > &  targetQ)
protected

Fast version of setTargetQ(std::vector<double>)

◆ setTargetQ_() [2/2]

void mc_control::Gripper::setTargetQ_ ( size_t  activeJoints,
double  targetQ 
)
protected

Fast version of setTargetQ(size_t, double) without clamping.

◆ targetOpening()

double mc_control::Gripper::targetOpening ( size_t  jointId) const
protected

Target opening percentage of an active joint.

Member Data Documentation

◆ _q

std::vector<double> mc_control::Gripper::_q
protected

Full joints' values

◆ active_joints

std::vector<std::string> mc_control::Gripper::active_joints
protected

Name of active joints involved in the gripper

◆ active_joints_idx

std::vector<size_t> mc_control::Gripper::active_joints_idx
protected

Active joints indexes in the reference joint order

◆ actualQ

std::vector<double> mc_control::Gripper::actualQ
protected

Joints' values from the encoders

◆ closeP

std::vector<double> mc_control::Gripper::closeP
protected

Lower limits of active joints in the gripper (closed-gripper values)

◆ config_

Config mc_control::Gripper::config_
protected

Current configuration of the gripper parameters

◆ defaultConfig_

Config mc_control::Gripper::defaultConfig_
protected

Default configuration provided at construction

◆ is_metric_

bool mc_control::Gripper::is_metric_
protected

True if all joints are primatic

◆ joints_mbc_idx

std::vector<int> mc_control::Gripper::joints_mbc_idx
protected

All joint indexes in mbc, -1 if absent

◆ mult

std::vector<std::pair<size_t, double> > mc_control::Gripper::mult
protected

Mimic multiplier, first element is the joint to mimic, second is the multiplier

◆ names

std::vector<std::string> mc_control::Gripper::names
protected

Name of joints involved in the gripper

◆ offset

std::vector<double> mc_control::Gripper::offset
protected

Mimic offsets

◆ openP

std::vector<double> mc_control::Gripper::openP
protected

Upper limits of active joints in the gripper (open-gripper values)

◆ overCommandLimit

std::vector<bool> mc_control::Gripper::overCommandLimit
protected

True if the gripper has been too far from the command for over overCommandLimitIterN iterations

◆ overCommandLimitIter

std::vector<unsigned int> mc_control::Gripper::overCommandLimitIter
protected

Store the number of iterations where the gripper command was over the limit

◆ percentOpen

std::vector<double> mc_control::Gripper::percentOpen
protected

Current opening percentage

◆ reached_threshold_

std::vector<double> mc_control::Gripper::reached_threshold_
protected

Target reached threshold per-joint (0.001 rad for revolute and 0.0001 for prismatic joints)

◆ reversed_

bool mc_control::Gripper::reversed_ = false
protected

True if the gripper is reversed

◆ savedConfig_

Config mc_control::Gripper::savedConfig_
protected

Saved configuration of the parameters saved by saveConfig()

◆ targetQ

std::vector<double>* mc_control::Gripper::targetQ
protected

Current gripper target: NULL if target has been reached or safety was triggered

◆ targetQIn

std::vector<double> mc_control::Gripper::targetQIn
protected

Current gripper target

◆ vmax

std::vector<double> mc_control::Gripper::vmax
protected

Maximum velocity of active joints in the gripper


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