23 if ( !
_nh.getParam (
"/rate",
_rate ) ) {
24 ROS_INFO_STREAM (
"Ros parameter for rate not found, I'm setting the default rate of 100 Hz" );
38 _ee = std::make_shared<ROSEE::EEInterface> ( p );
39 ROS_INFO_STREAM (
"Fingers in EEInterface: " );
40 for (
auto& f :
_ee->getFingers() ) {
41 ROS_INFO_STREAM ( f );
62 std::string actionGraspingCommandName;
63 _nh.param<std::string>(
"/rosee/rosAction_grasping_command", actionGraspingCommandName,
"action_command");
75 std::string motor_reference_topic =
"motor_reference_pos";
76 const int motor_reference_queue = 10;
84 _mr_msg.position.resize ( _motors_num );
85 _mr_msg.velocity.resize ( _motors_num );
86 _mr_msg.effort.resize ( _motors_num );
94 const double DAMPING_FACT = 1.0;
95 const double BW_MEDIUM = 2.0;
96 double omega = 2.0 * M_PI * BW_MEDIUM;
125 if (
mapActionHandlerPtr->getPrimitiveMap(ROSEE::ActionPrimitive::Type::PinchLoose).size()>0) {
136 ROS_INFO_STREAM (
"PINCHES-TIGHT:" );
140 ROS_INFO_STREAM (
"PINCHES-LOOSE:" );
144 ROS_INFO_STREAM (
"TRIGGERS:" );
148 ROS_INFO_STREAM (
"TIP FLEX:" );
152 ROS_INFO_STREAM (
"FINGER FLEX:" );
161 ROS_INFO_STREAM (
"GRASP:" );
172 std::string topic_name_js =
"/ros_end_effector/joint_states";
174 ROS_INFO_STREAM (
"Getting joint pos from '" << topic_name_js <<
"'" );
183 for (
int i=0; i< msg->name.size(); i++) {
184 std::vector <double> one_dof { msg->position.at(i) };
197 if (goal.action_type != ROSEE::Action::Type::Timed){
198 if (goal.percentage < 0 || goal.percentage > 1) {
199 ROS_ERROR_STREAM (
"Received an action-goal with percentage " << goal.percentage <<
200 " Please insert a value between 0 (for 0%) and 1 (for 100%) ");
211 switch (goal.action_type) {
213 case ROSEE::Action::Type::Primitive :
217 if (primitive ==
nullptr) {
228 case ROSEE::Action::Type::Generic :
229 case ROSEE::Action::Type::Composed :
233 if (
generic ==
nullptr) {
244 case ROSEE::Action::Type::Timed : {
266 case ROSEE::Action::Type::None :
268 ROS_ERROR_STREAM (
"Received an action-goal of type None (" << goal.action_type <<
269 ") which is a no-type. Please use valid Action::Type ");
275 ROS_ERROR_STREAM (
"Received an action-goal of type " << goal.action_type <<
276 " which I do not recognize. Please use valid Action::Type ");
284 if (goal.optional_motors_names.size() != 0) {
293 std::vector<std::string> motors_names, std::vector<double> motors_commands) {
297 if (motors_names.size() != motors_commands.size() &&
299 ROS_ERROR_STREAM (
"In receiving the goal command, the optional field is formed badly: " 300 <<
"optional_motors_names and optional_motors_commands and number of motors have different size (" 301 << motors_names.size() <<
" and " << motors_commands.size() <<
" and " <<
_motors_num 302 <<
" respectively). I will ignore the optional command");
307 for (
int i=0; i<motors_names.size(); i++) {
310 _ee->getInternalIdForJoint ( motors_names.at(i), id );
317 ROS_WARN_STREAM (
"Trying to send an optional command to motor: " << motors_names.at(i)
318 <<
" which is not defined" );
333 if ( it.second != 0 ) {
335 _ee->getInternalIdForJoint ( it.first,
id );
345 ROS_WARN_STREAM (
"Trying to move Joint: " << it.first <<
" with ID: " <<
id );
362 }
else if (timed_index < timedAction->getInnerActionsNames().size()) {
376 double actualNorm = 0;
380 if ( it.second != 0 ) {
382 _ee->getInternalIdForJoint ( it.first,
id );
390 ROS_ERROR_STREAM (
"YOU SHOULD NOT BE HERE, previous error should stop execution");
394 actualNorm = sqrt(actualNorm);
396 double actualCompletationPercentage;
398 if (actualNorm < _ros_action_server->getWantedNormError()) {
399 actualCompletationPercentage = 100;
403 actualCompletationPercentage =
408 return actualCompletationPercentage;
414 _mr_msg.header.stamp = ros::Time::now();
423 _ee->getInternalIdForJoint ( motor_name,
id );
487 ROS_INFO_STREAM (
"Waiting time to execute timed action...");
503 ROS_INFO_STREAM (
"Started looping @ " << 1./
_period <<
"Hz" );
std::map< std::set< std::string >, ROSEE::ActionPrimitive::Ptr > _pinchLooseParsedMap
ROSEE::EEInterface::Ptr _ee
void timer_callback(const ros::TimerEvent &timer_ev)
void printEndEffectorFingerJointsMap() const
Utility to print the mapping between the End Effector finger chains and the related actuated joints...
std::map< std::set< std::string >, ROSEE::ActionPrimitive::Ptr > _fingFlexParsedMap
void setOmega(double omega)
std::map< std::set< std::string >, ROSEE::ActionPrimitive::Ptr > _pinchParsedMap
ros::Publisher _motor_reference_pub
const SignalType & process(const SignalType &input)
std::shared_ptr< RosServiceHandler > _ros_service_handler
std::shared_ptr< RosActionServer > _ros_action_server
bool init()
Initialization function using the ROS param ROSEEConfigPath.
std::shared_ptr< ROSEE::ActionGeneric > _graspParsed
void setDamping(double eps)
bool publish_motor_reference()
ros::Subscriber _joint_state_sub
std::shared_ptr< ActionGeneric > Ptr
std::shared_ptr< ActionPrimitive > Ptr
ROSEE::JointPos _motor_position_goal
std::map< std::set< std::string >, ROSEE::ActionPrimitive::Ptr > _tipFlexParsedMap
ROSEE::Utils::SecondOrderFilter< Eigen::VectorXd > _filt_q
sensor_msgs::JointState _mr_msg
std::string getActionPath() const
get the path where emit and parse grasping actions
MapActionHandler::Ptr mapActionHandlerPtr
void setTimeStep(double ts)
double sendFeedbackGoal(std::string currentAction="")
void joint_state_clbk(const sensor_msgs::JointStateConstPtr &msg)
std::vector< std::string > _motors_names
std::shared_ptr< ROSEE::ActionTimed > timedAction
virtual ~UniversalRosEndEffectorExecutor()
void init_joint_state_sub()
ROSEE::JointsInvolvedCount _motor_involved_mask
bool init_motor_reference_pub()
Class responsible for parsing the YAML file providing the URDF, SRDF, the EE-HAL library implementati...
bool updateRefGoal(double percentage=1.0)
Eigen::VectorXd _qref_filtered
bool init_grasping_primitive()
ROSEE::JointPos _joint_actual_pos
bool readOptionalCommands(std::vector< std::string > motors_names, std::vector< double > motors_commands)
UniversalRosEndEffectorExecutor(std::string ns="")
ROSEE::Utils::Timer timer
void reset(const SignalType &initial_state)
Eigen::VectorXd _qref_optional
std::map< std::set< std::string >, ROSEE::ActionPrimitive::Ptr > _trigParsedMap
std::string folderForActions
double normGoalFromInitialPos