Bioscara
DALSA's DIY SCARA Robot Arm.
Loading...
Searching...
No Matches
Public Member Functions | Protected Member Functions | Protected Attributes | Private Attributes | List of all members
bioscara_hardware_drivers::BaseGripper Class Reference

Generic base class for gripper control implementations. More...

#include <mBaseGripper.h>

Inheritance diagram for bioscara_hardware_drivers::BaseGripper:
bioscara_hardware_drivers::Gripper bioscara_hardware_drivers::MockGripper

Public Member Functions

 BaseGripper (float reduction, float offset, float min, float max, float backup_init_pos)
 Construct a new BaseGripper object.
 
 ~BaseGripper (void)
 Destroy the BaseGripper object.
 
virtual err_type_t init (void)
 Initializes the gripper.
 
virtual err_type_t deinit (void)
 Deinitializes the gripper.
 
virtual err_type_t enable (void)
 Enables the gripper.
 
virtual err_type_t disable (void)
 Disables the gripper.
 
virtual err_type_t setPosition (float width)
 Sets the gripper width in m.
 
virtual err_type_t getPosition (float &width)
 Gets the gripper width.
 
virtual void setReduction (float reduction)
 Manually set reduction.
 
virtual void setOffset (float offset)
 Manually set offset.
 

Protected Member Functions

err_type_t save_last_position (float pos)
 Stores the latest position to the buffer file.
 
err_type_t retrieve_last_position (float &pos)
 Retrieves the stored position from the buffer file.
 

Protected Attributes

float _reduction = 1
 gripper width to actuator reduction ratio
 
float _offset = 0
 gripper width position offset
 
float _min = 0
 gripper width lower limit
 
float _max = 0
 gripper width upper limit
 
float _backup_init_pos = 0.0
 Initial position assumed if none can be retrieved from the buffer file.
 
float _pos = _backup_init_pos
 stored position
 
float _pos_get = _pos
 reported position
 

Private Attributes

std::chrono::_V2::system_clock::time_point _new_cmd_time = std::chrono::_V2::system_clock::time_point()
 

Detailed Description

Generic base class for gripper control implementations.

This class is a wrapper function to interact with the robot gripper either through a MockGripper or hardware Gripper object.

Constructor & Destructor Documentation

◆ BaseGripper()

bioscara_hardware_drivers::BaseGripper::BaseGripper ( float  reduction,
float  offset,
float  min,
float  max,
float  backup_init_pos 
)

Construct a new BaseGripper object.

The gripper has the reduction $r$ and offset $o$ parameters which are used to translate from a desired gripper width to the servo angle. The relationship between gripper width $w$ and acutator angle $\alpha$ is as follows:

\[
  \alpha = r (w-o)
  \]

To determine these parameters execute the following steps:

  1. Manually set the gripper to an open position by setting a actuator angle. Be carefull to not exceed the physical limits of the gripper since the actuator is strong enough to break PLA before stalling.
  2. Measure the gripper width $w_1$ and note the set actuator angle $\alpha_1$.
  3. Move the gripper to a more closed position that still allows you to accurately measure the width
  4. Measure the second width $w_2$ and note the corresponding angle $\alpha_2$
  5. Calculate the offset $o$:

    \[
  o = \frac{\alpha_1 w_2 -  \alpha_2 w_1}{\alpha_1 - \alpha_2}
  \]

  6. Calculate the reduction $r$:

    \[
  r = \frac{\alpha_1}{w_1 - o}
  \]

Parameters
reductionthe gripper width to actuator reduction ratio
offsetgripper width to actuator zero offset
minlower limit in m
maxupper limit in m
backup_init_posinitial position assumed if none can be retrieved from the buffer file

◆ ~BaseGripper()

bioscara_hardware_drivers::BaseGripper::~BaseGripper ( void  )

Destroy the BaseGripper object.

invokes the disable() and deinit() method to clean up.

Member Function Documentation

◆ deinit()

err_type_t bioscara_hardware_drivers::BaseGripper::deinit ( void  )
virtual

Deinitializes the gripper.

Returns
err_type_t::OK

◆ disable()

err_type_t bioscara_hardware_drivers::BaseGripper::disable ( void  )
virtual

Disables the gripper.

As described in enable()

Returns
err_type_t::OK

Reimplemented in bioscara_hardware_drivers::Gripper.

◆ enable()

err_type_t bioscara_hardware_drivers::BaseGripper::enable ( void  )
virtual

Enables the gripper.

Since the gripper has no position feedback its position is initially unknown. For this reason we try to retrieve the latest commanded position from a buffer file using retrieve_last_position(). If this fails the _backup_init_pos is used.

Returns
err_type_t::OK

Reimplemented in bioscara_hardware_drivers::Gripper.

◆ getPosition()

err_type_t bioscara_hardware_drivers::BaseGripper::getPosition ( float &  width)
virtual

Gets the gripper width.

Note
Since the PWM servo has no position feedback, the latest position command is returned.
Parameters
widthwidth in m.
Returns
err_type_t::OK

◆ init()

err_type_t bioscara_hardware_drivers::BaseGripper::init ( void  )
virtual

Initializes the gripper.

Returns
err_type_t::OK

◆ retrieve_last_position()

err_type_t bioscara_hardware_drivers::BaseGripper::retrieve_last_position ( float &  pos)
protected

Retrieves the stored position from the buffer file.

Parameters
posposition value that is retrieved
Returns
err_type_t::OK on success, err_type_t::ERROR if parsing buffer file fails.

◆ save_last_position()

err_type_t bioscara_hardware_drivers::BaseGripper::save_last_position ( float  pos)
protected

Stores the latest position to the buffer file.

Parameters
posposition value to store
Returns
err_type_t::OK on success, err_type_t::ERROR if writing buffer file fails.

◆ setOffset()

void bioscara_hardware_drivers::BaseGripper::setOffset ( float  offset)
virtual

Manually set offset.

◆ setPosition()

err_type_t bioscara_hardware_drivers::BaseGripper::setPosition ( float  width)
virtual

Sets the gripper width in m.

Arguments outside the allowed range are bounded to _min and _max.

Parameters
widthwidth in m.
Returns
err_type_t::OK

Reimplemented in bioscara_hardware_drivers::Gripper.

◆ setReduction()

void bioscara_hardware_drivers::BaseGripper::setReduction ( float  reduction)
virtual

Manually set reduction.

Parameters
reduction

Member Data Documentation

◆ _backup_init_pos

float bioscara_hardware_drivers::BaseGripper::_backup_init_pos = 0.0
protected

Initial position assumed if none can be retrieved from the buffer file.

◆ _max

float bioscara_hardware_drivers::BaseGripper::_max = 0
protected

gripper width upper limit

◆ _min

float bioscara_hardware_drivers::BaseGripper::_min = 0
protected

gripper width lower limit

◆ _new_cmd_time

std::chrono::_V2::system_clock::time_point bioscara_hardware_drivers::BaseGripper::_new_cmd_time = std::chrono::_V2::system_clock::time_point()
private

◆ _offset

float bioscara_hardware_drivers::BaseGripper::_offset = 0
protected

gripper width position offset

◆ _pos

float bioscara_hardware_drivers::BaseGripper::_pos = _backup_init_pos
protected

stored position

◆ _pos_get

float bioscara_hardware_drivers::BaseGripper::_pos_get = _pos
protected

reported position

◆ _reduction

float bioscara_hardware_drivers::BaseGripper::_reduction = 1
protected

gripper width to actuator reduction ratio


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