mia_hand_gazebo  rel 1.0.0
mia::MiaHWSim Class Reference

Class hardware sim interface of the simulated Mia hand. More...

#include <Mia_hw_sim.h>

Inheritance diagram for mia::MiaHWSim:
Collaboration diagram for mia::MiaHWSim:

Public Member Functions

virtual bool initSim (const std::string &robot_namespace, ros::NodeHandle model_nh, gazebo::physics::ModelPtr parent_model, const urdf::Model *const urdf_model, std::vector< transmission_interface::TransmissionInfo > transmissions)
 Initialize the simulated robot hardware. More...
 
virtual void readSim (ros::Time time, ros::Duration period)
 Read state data from the simulated robot hardware. More...
 
virtual void writeSim (ros::Time time, ros::Duration period)
 Send commands to the simulated robot hardware. More...
 
virtual void eStopActive (const bool active)
 Unused. More...
 

Protected Types

enum  ControlMethod {
  EFFORT, POSITION, POSITION_PID, VELOCITY,
  VELOCITY_PID
}
 Joints control methods. More...
 

Protected Member Functions

void registerJointLimits (const std::string &joint_name, const std::vector< hardware_interface::JointHandle > &joint_handle, const std::vector< ControlMethod > ctrl_method, const ros::NodeHandle &joint_limit_nh, const urdf::Model *const urdf_model, int *const joint_type, double *const lower_limit, double *const upper_limit, double *const effort_limit)
 Register the joint limits of the simulated hardware. More...
 
double GetThumbOppPosition (ros::Duration period)
 Evaluate the position of the Mia thumb opposition joint. More...
 
bool GetMiddlePosition (double joint_position_m, double joint_position_r, double joint_position_l, double flex_direction)
 Evaluate if any of the Mia simulated middle ring or little flexion joint is stuck. More...
 
enum ControlMethod SelectCtrMethod (enum MiaHWSim::ControlMethod Default_joint_control_methods_, enum ControlMethod last_joint_control_methods_, const double last_joint_velocity_command_, const double joint_velocity_command_, const double last_joint_position_command_, const double joint_position_command_)
 Select the control method to move the simulated hardware. More...
 

Protected Attributes

Joint_index_mapping joints_ii
 Joint_index_mapping struct. More...
 
unsigned int n_dof_
 Number of degree of freedom of the simulated hardware. More...
 
unsigned int write_counter
 Counter of the write method. More...
 
hardware_interface::JointStateInterface js_interface_
 Interface for simulated joint state. More...
 
hardware_interface::EffortJointInterface ej_interface_
 Interface for simulated joint effort commands. More...
 
hardware_interface::PositionJointInterface pj_interface_
 Interface for simulated joint position commands. More...
 
hardware_interface::VelocityJointInterface vj_interface_
 Interface for simulated joint velocity commands. More...
 
joint_limits_interface::EffortJointSaturationInterface ej_sat_interface_
 Interface for simulated joint effort saturation limit. More...
 
joint_limits_interface::EffortJointSoftLimitsInterface ej_limits_interface_
 Interface for simulated joint effort soft limit. More...
 
joint_limits_interface::PositionJointSaturationInterface pj_sat_interface_
 Interface for simulated joint position saturation limit. More...
 
joint_limits_interface::PositionJointSoftLimitsInterface pj_limits_interface_
 Interface for simulated joint position sodt limit. More...
 
joint_limits_interface::VelocityJointSaturationInterface vj_sat_interface_
 Interface for simulated joint velocity saturation limit. More...
 
joint_limits_interface::VelocityJointSoftLimitsInterface vj_limits_interface_
 Interface for simulated joint velocity soft limit. More...
 
std::vector< std::string > joint_names_
 Name of the joints of the simulated hardware. More...
 
std::vector< int > joint_types_
 Type of the joints of the simulated hardware. More...
 
std::vector< double > joint_lower_limits_
 Lower position limits of the joints of the simulated hardware. More...
 
std::vector< double > joint_upper_limits_
 Upper position limits of the joints of the simulated hardware. More...
 
std::vector< double > joint_effort_limits_
 Effort upper limits of the joints of the simulated hardware. More...
 
std::vector< double > joint_position_
 Actual position state of the joints of the simulated hardware. More...
 
std::vector< double > joint_velocity_
 Actual velocity state of the joints of the simulated hardware. More...
 
std::vector< double > joint_effort_
 Actual effort state of the joints of the simulated hardware. More...
 
std::vector< double > joint_effort_command_
 Actual effort command of the joints of the simulated hardware. More...
 
std::vector< double > last_joint_effort_command_
 Last effort command of the joints of the simulated hardware. More...
 
std::vector< double > joint_position_command_
 Actual position command of the joints of the simulated hardware. More...
 
std::vector< double > last_joint_position_command_
 Last position command of the joints of the simulated hardware. More...
 
std::vector< double > joint_velocity_command_
 Actual velocity command of the joints of the simulated hardware. More...
 
std::vector< double > last_joint_velocity_command_
 Last velocity command of the joints of the simulated hardware. More...
 
std::vector< ControlMethodlast_joint_control_methods_
 Last control method used for the joints of the simulated hardware. More...
 
std::vector< ControlMethodjoint_control_methods_
 Actual control method for the joints of the simulated hardware. More...
 
std::vector< std::vector< ControlMethod > > List_joint_control_methods_
 List of control method available for the joints of the simulated hardware. More...
 
std::vector< control_toolbox::Pid > pid_controllers_
 
double * j_index_flex_pos
 Pointer to the position status of Mia simulated index flexion joint. More...
 
double j_index_flex_pos_Th
 Threshold used for the simulated index flexion position control to switch its sign. More...
 
int j_index_flex_sign
 Current sign of the Mia simulated index flexion joint. More...
 
double jThOpp_Target_position
 Target position of the Mia simulated thumb opposition joint evaluated by this class. More...
 
double jMiddle_StackTarget_position
 Target position of the Mia simulated middle flexion joint when ring and/or little get stuck. More...
 
bool mrl_united
 If True then middle ring little fingers are physical connected in the URDF, False if they ate independent joints. More...
 
mia_hand::thumb_opp_passive_joint MyTh_opp_passiveJoint
 Class used to evaluate the target position of the Mia simulated thumb opposition joint. More...
 
std::vector< gazebo::physics::JointPtr > sim_joints_
 Gazebo joint pointer. More...
 
bool e_stop_active_
 
bool last_e_stop_active_
 Unused. More...
 

Detailed Description

Class hardware sim interface of the simulated Mia hand.

This class inherits from public gazebo_ros_control::RobotHWSim and it can be used also when the Mia hand is mounted on another robots that work with the gazebo_ros_control::DefaultRobotHWSim class. In this case this class is able to control both the simulated mia hand and the other robot components.

Definition at line 71 of file Mia_hw_sim.h.

Member Enumeration Documentation

◆ ControlMethod

Joints control methods.

All possible joints controlled methods allowed by ROS control

Enumerator
EFFORT 
POSITION 
POSITION_PID 
VELOCITY 
VELOCITY_PID 

Definition at line 117 of file Mia_hw_sim.h.

Member Function Documentation

◆ eStopActive()

void mia::MiaHWSim::eStopActive ( const bool  active)
virtual

Unused.

Definition at line 1258 of file Mia_hw_sim.cpp.

◆ GetMiddlePosition()

bool mia::MiaHWSim::GetMiddlePosition ( double  joint_position_m,
double  joint_position_r,
double  joint_position_l,
double  flex_direction 
)
protected

Evaluate if any of the Mia simulated middle ring or little flexion joint is stuck.

Since in the actual Mia hand the middle, little and ring flexion JointState are coupled, while in the Mia simulated model are not (since they have different rotation axis) this fucntion has the aim to avoid that the difference among the position of these joints exceeds a certain threshold, simulating the behaviour of coupled joints.

Parameters
joint_position_mPosition of the Mia simulated middle flexion joint.
joint_position_rPosition of the Mia simulated ring flexion joint.
joint_position_lPosition of the Mia simulated little flexion joint.
flex_directiondirection of the ongoing flexion movement.
Returns
True if the difference among the position of these joints exceeds a certain threshold (e.g when any joint is stuck).

Definition at line 1211 of file Mia_hw_sim.cpp.

◆ GetThumbOppPosition()

double mia::MiaHWSim::GetThumbOppPosition ( ros::Duration  period)
protected

Evaluate the position of the Mia thumb opposition joint.

Since in the actual Mia hand the opposition of the thumb (passive joint) is coupled to the movement of the index flexion this function uses the sate of the index flexion joint of the simulated mia hand to evaluate the position that the simulated thumb opposition joint has to reach at every simulation step.

Parameters
periodTime since the last simulation step.
Returns
The target position of the Mia simulated thumb opposition joint.

Definition at line 1186 of file Mia_hw_sim.cpp.

◆ initSim()

bool mia::MiaHWSim::initSim ( const std::string &  robot_namespace,
ros::NodeHandle  model_nh,
gazebo::physics::ModelPtr  parent_model,
const urdf::Model *const  urdf_model,
std::vector< transmission_interface::TransmissionInfo >  transmissions 
)
virtual

Initialize the simulated robot hardware.

Initialize the simulated robot hardware by register the correct ros control interfaces and the joint limits.

Parameters
robot_namespaceRobot namespace.
model_nhModel node handle.
parent_modelParent model.
urdf_modelURDF model.
transmissionsTransmissions.
Returns
True if the simulated robot hardware is initialized successfully, False if not.

Definition at line 31 of file Mia_hw_sim.cpp.

◆ readSim()

void mia::MiaHWSim::readSim ( ros::Time  time,
ros::Duration  period 
)
virtual

Read state data from the simulated robot hardware.

Read joint positions velocities and efforts from the simulated robot hardware.

Parameters
timeSimulation time.
periodTime since the last simulation step.

Definition at line 501 of file Mia_hw_sim.cpp.

◆ registerJointLimits()

void mia::MiaHWSim::registerJointLimits ( const std::string &  joint_name,
const std::vector< hardware_interface::JointHandle > &  joint_handle,
const std::vector< ControlMethod ctrl_method,
const ros::NodeHandle &  joint_limit_nh,
const urdf::Model *const  urdf_model,
int *const  joint_type,
double *const  lower_limit,
double *const  upper_limit,
double *const  effort_limit 
)
protected

Register the joint limits of the simulated hardware.

Register the limits of the joint specified by joint_name and joint_handle. The limits are retrieved from joint_limit_nh. If urdf_model is not NULL, limits are retrieved from it also.

Parameters
joint_nameName of the joint whose limits has to be registered.
joint_handleHandler of the joint.
ctrl_methodArray of enum describe the control methods available for that joint.
joint_limit_nhJoint node handle.
urdf_modelURDF model.
joint_typeJoint type (e.g. urdf::Joint::REVOLUTE).
lower_limitLower position limit of the joint returned by this method.
upper_limitUpper position limit of the joint returned by this method.
effort_limitEffortlimit of the joint returned by this method.

Definition at line 365 of file Mia_hw_sim.cpp.

◆ SelectCtrMethod()

enum MiaHWSim::ControlMethod mia::MiaHWSim::SelectCtrMethod ( enum MiaHWSim::ControlMethod  Default_joint_control_methods_,
enum ControlMethod  last_joint_control_methods_,
const double  last_joint_velocity_command_,
const double  joint_velocity_command_,
const double  last_joint_position_command_,
const double  joint_position_command_ 
)
protected

Select the control method to move the simulated hardware.

Since velocity and position interfaces are both loaded for each joint, this method recognize wich type of control the received new command requires.

Parameters
Default_joint_control_methods_Default control method for the joint.
last_joint_control_methods_Last type of control method used for the joint.
last_joint_velocity_command_Last velocity command received for the joint.
joint_velocity_command_Actual velocity command received for the joint.
last_joint_position_command_Last position command received for the joint.
joint_position_command_Actual position command received for the joint.
Returns
the control method to use in the current simulation step to move the joint.

Definition at line 1161 of file Mia_hw_sim.cpp.

◆ writeSim()

void mia::MiaHWSim::writeSim ( ros::Time  time,
ros::Duration  period 
)
virtual

Send commands to the simulated robot hardware.

Send command as joint positions or velocities or efforts to the simulated robot hardware.

Parameters
timeSimulation time.
periodTime since the last simulation step.

Definition at line 575 of file Mia_hw_sim.cpp.

Member Data Documentation

◆ e_stop_active_

bool mia::MiaHWSim::e_stop_active_
protected

Definition at line 257 of file Mia_hw_sim.h.

◆ ej_interface_

hardware_interface::EffortJointInterface mia::MiaHWSim::ej_interface_
protected

Interface for simulated joint effort commands.

Definition at line 202 of file Mia_hw_sim.h.

◆ ej_limits_interface_

joint_limits_interface::EffortJointSoftLimitsInterface mia::MiaHWSim::ej_limits_interface_
protected

Interface for simulated joint effort soft limit.

Definition at line 207 of file Mia_hw_sim.h.

◆ ej_sat_interface_

joint_limits_interface::EffortJointSaturationInterface mia::MiaHWSim::ej_sat_interface_
protected

Interface for simulated joint effort saturation limit.

Definition at line 206 of file Mia_hw_sim.h.

◆ j_index_flex_pos

double* mia::MiaHWSim::j_index_flex_pos
protected

Pointer to the position status of Mia simulated index flexion joint.

Definition at line 237 of file Mia_hw_sim.h.

◆ j_index_flex_pos_Th

double mia::MiaHWSim::j_index_flex_pos_Th
protected

Threshold used for the simulated index flexion position control to switch its sign.

Definition at line 238 of file Mia_hw_sim.h.

◆ j_index_flex_sign

int mia::MiaHWSim::j_index_flex_sign
protected

Current sign of the Mia simulated index flexion joint.

Definition at line 239 of file Mia_hw_sim.h.

◆ jMiddle_StackTarget_position

double mia::MiaHWSim::jMiddle_StackTarget_position
protected

Target position of the Mia simulated middle flexion joint when ring and/or little get stuck.

Definition at line 241 of file Mia_hw_sim.h.

◆ joint_control_methods_

std::vector<ControlMethod> mia::MiaHWSim::joint_control_methods_
protected

Actual control method for the joints of the simulated hardware.

Definition at line 231 of file Mia_hw_sim.h.

◆ joint_effort_

std::vector<double> mia::MiaHWSim::joint_effort_
protected

Actual effort state of the joints of the simulated hardware.

Definition at line 222 of file Mia_hw_sim.h.

◆ joint_effort_command_

std::vector<double> mia::MiaHWSim::joint_effort_command_
protected

Actual effort command of the joints of the simulated hardware.

Definition at line 223 of file Mia_hw_sim.h.

◆ joint_effort_limits_

std::vector<double> mia::MiaHWSim::joint_effort_limits_
protected

Effort upper limits of the joints of the simulated hardware.

Definition at line 218 of file Mia_hw_sim.h.

◆ joint_lower_limits_

std::vector<double> mia::MiaHWSim::joint_lower_limits_
protected

Lower position limits of the joints of the simulated hardware.

Definition at line 216 of file Mia_hw_sim.h.

◆ joint_names_

std::vector<std::string> mia::MiaHWSim::joint_names_
protected

Name of the joints of the simulated hardware.

Definition at line 214 of file Mia_hw_sim.h.

◆ joint_position_

std::vector<double> mia::MiaHWSim::joint_position_
protected

Actual position state of the joints of the simulated hardware.

Definition at line 220 of file Mia_hw_sim.h.

◆ joint_position_command_

std::vector<double> mia::MiaHWSim::joint_position_command_
protected

Actual position command of the joints of the simulated hardware.

Definition at line 225 of file Mia_hw_sim.h.

◆ joint_types_

std::vector<int> mia::MiaHWSim::joint_types_
protected

Type of the joints of the simulated hardware.

Definition at line 215 of file Mia_hw_sim.h.

◆ joint_upper_limits_

std::vector<double> mia::MiaHWSim::joint_upper_limits_
protected

Upper position limits of the joints of the simulated hardware.

Definition at line 217 of file Mia_hw_sim.h.

◆ joint_velocity_

std::vector<double> mia::MiaHWSim::joint_velocity_
protected

Actual velocity state of the joints of the simulated hardware.

Definition at line 221 of file Mia_hw_sim.h.

◆ joint_velocity_command_

std::vector<double> mia::MiaHWSim::joint_velocity_command_
protected

Actual velocity command of the joints of the simulated hardware.

Definition at line 227 of file Mia_hw_sim.h.

◆ joints_ii

Joint_index_mapping mia::MiaHWSim::joints_ii
protected

Joint_index_mapping struct.

Struct that stores the index number of the simulated mia hand joint as contained in the interfaces and arrays of this class

See also
Joint_index_mapping()

Definition at line 195 of file Mia_hw_sim.h.

◆ js_interface_

hardware_interface::JointStateInterface mia::MiaHWSim::js_interface_
protected

Interface for simulated joint state.

Definition at line 201 of file Mia_hw_sim.h.

◆ jThOpp_Target_position

double mia::MiaHWSim::jThOpp_Target_position
protected

Target position of the Mia simulated thumb opposition joint evaluated by this class.

Definition at line 240 of file Mia_hw_sim.h.

◆ last_e_stop_active_

bool mia::MiaHWSim::last_e_stop_active_
protected

Unused.

Definition at line 257 of file Mia_hw_sim.h.

◆ last_joint_control_methods_

std::vector<ControlMethod> mia::MiaHWSim::last_joint_control_methods_
protected

Last control method used for the joints of the simulated hardware.

Definition at line 229 of file Mia_hw_sim.h.

◆ last_joint_effort_command_

std::vector<double> mia::MiaHWSim::last_joint_effort_command_
protected

Last effort command of the joints of the simulated hardware.

Definition at line 224 of file Mia_hw_sim.h.

◆ last_joint_position_command_

std::vector<double> mia::MiaHWSim::last_joint_position_command_
protected

Last position command of the joints of the simulated hardware.

Definition at line 226 of file Mia_hw_sim.h.

◆ last_joint_velocity_command_

std::vector<double> mia::MiaHWSim::last_joint_velocity_command_
protected

Last velocity command of the joints of the simulated hardware.

Definition at line 228 of file Mia_hw_sim.h.

◆ List_joint_control_methods_

std::vector<std::vector<ControlMethod> > mia::MiaHWSim::List_joint_control_methods_
protected

List of control method available for the joints of the simulated hardware.

Definition at line 232 of file Mia_hw_sim.h.

◆ mrl_united

bool mia::MiaHWSim::mrl_united
protected

If True then middle ring little fingers are physical connected in the URDF, False if they ate independent joints.

Definition at line 242 of file Mia_hw_sim.h.

◆ MyTh_opp_passiveJoint

mia_hand::thumb_opp_passive_joint mia::MiaHWSim::MyTh_opp_passiveJoint
protected

Class used to evaluate the target position of the Mia simulated thumb opposition joint.

Class describing the relation between the position of the Mia index flexion joint and the dependent one of the thumb opposition. This class is implemented in the mia_hand_description pkg.

See also
GetThumbOppPosition()

Definition at line 251 of file Mia_hw_sim.h.

◆ n_dof_

unsigned int mia::MiaHWSim::n_dof_
protected

Number of degree of freedom of the simulated hardware.

Definition at line 197 of file Mia_hw_sim.h.

◆ pid_controllers_

std::vector<control_toolbox::Pid> mia::MiaHWSim::pid_controllers_
protected

Definition at line 234 of file Mia_hw_sim.h.

◆ pj_interface_

hardware_interface::PositionJointInterface mia::MiaHWSim::pj_interface_
protected

Interface for simulated joint position commands.

Definition at line 203 of file Mia_hw_sim.h.

◆ pj_limits_interface_

joint_limits_interface::PositionJointSoftLimitsInterface mia::MiaHWSim::pj_limits_interface_
protected

Interface for simulated joint position sodt limit.

Definition at line 209 of file Mia_hw_sim.h.

◆ pj_sat_interface_

joint_limits_interface::PositionJointSaturationInterface mia::MiaHWSim::pj_sat_interface_
protected

Interface for simulated joint position saturation limit.

Definition at line 208 of file Mia_hw_sim.h.

◆ sim_joints_

std::vector<gazebo::physics::JointPtr> mia::MiaHWSim::sim_joints_
protected

Gazebo joint pointer.

Definition at line 254 of file Mia_hw_sim.h.

◆ vj_interface_

hardware_interface::VelocityJointInterface mia::MiaHWSim::vj_interface_
protected

Interface for simulated joint velocity commands.

Definition at line 204 of file Mia_hw_sim.h.

◆ vj_limits_interface_

joint_limits_interface::VelocityJointSoftLimitsInterface mia::MiaHWSim::vj_limits_interface_
protected

Interface for simulated joint velocity soft limit.

Definition at line 211 of file Mia_hw_sim.h.

◆ vj_sat_interface_

joint_limits_interface::VelocityJointSaturationInterface mia::MiaHWSim::vj_sat_interface_
protected

Interface for simulated joint velocity saturation limit.

Definition at line 210 of file Mia_hw_sim.h.

◆ write_counter

unsigned int mia::MiaHWSim::write_counter
protected

Counter of the write method.

Definition at line 198 of file Mia_hw_sim.h.


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