ROSEndEffector
ROS End-Effector package: provides a ROS-based set of standard interfaces to command robotics end-effectors in an agnostic fashion.
UniversalRosEndEffectorExecutor.h
Go to the documentation of this file.
1 /*
2  * Copyright (C) 2019 IIT-HHCM
3  * Author: Luca Muratore
4  * email: luca.muratore@iit.it
5  *
6  * Licensed under the Apache License, Version 2.0 (the "License");
7  * you may not use this file except in compliance with the License.
8  * You may obtain a copy of the License at
9  * http://www.apache.org/licenses/LICENSE-2.0
10  *
11  * Unless required by applicable law or agreed to in writing, software
12  * distributed under the License is distributed on an "AS IS" BASIS,
13  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14  * See the License for the specific language governing permissions and
15  * limitations under the License.
16 */
17 
18 #ifndef __ROSEE_UNIVERSAL_ROS_END_EFFECTOR_EXECUTOR_
19 #define __ROSEE_UNIVERSAL_ROS_END_EFFECTOR_EXECUTOR_
20 
21 #include <memory>
22 #include <string>
23 
24 #include <ros/console.h>
25 #include <actionlib/server/simple_action_server.h>
26 
27 #include <sensor_msgs/JointState.h>
28 
29 #include <end_effector/Parser.h>
31 #include <end_effector/Utils.h>
36 
39 #include <rosee_msg/HandInfo.h>
40 
41 namespace ROSEE
42 {
43 
49 {
50 
51 public:
52 
53  typedef std::shared_ptr<UniversalRosEndEffectorExecutor> Ptr;
54  typedef std::shared_ptr<const UniversalRosEndEffectorExecutor> ConstPtr;
55 
56  UniversalRosEndEffectorExecutor ( std::string ns = "" );
58 
59  void spin();
60 
61  void timer_callback ( const ros::TimerEvent& timer_ev );
62 
63 private:
64 
66  bool init_qref_filter();
67  void init_joint_state_sub();
69 
71 
72  bool updateGoal(); //the "new" pinch/grasp callback (now used for all actions)
73  bool readOptionalCommands(std::vector<std::string> motors_names, std::vector<double> motors_commands);
74  bool updateRefGoal(double percentage = 1.0);
75  double sendFeedbackGoal(std::string currentAction = "");
76  bool update_send_timed();
77 
78  ros::NodeHandle _nh;
79  ros::Timer _loop_timer;
80 
81  double _time, _period, _rate;
82 
84 
85  ros::Publisher _motor_reference_pub;
86  sensor_msgs::JointState _mr_msg;
87  int _motors_num = 0;
88  int _seq_id = 0;
89 
91  ros::Subscriber _joint_state_sub;
92  void joint_state_clbk(const sensor_msgs::JointStateConstPtr& msg);
93 
94  std::vector<std::string> _motors_names;
95 
96  std::string folderForActions;
97 
98  Eigen::VectorXd _qref, _qref_filtered, _qref_optional;
99 
101 
102  // grasping primitives maps
103  // TODO still needed? now we have the handler that store them...
104  std::map<std::set<std::string>, ROSEE::ActionPrimitive::Ptr> _pinchParsedMap;
105  std::map<std::set<std::string>, ROSEE::ActionPrimitive::Ptr> _pinchLooseParsedMap;
106  std::map<std::set<std::string>, ROSEE::ActionPrimitive::Ptr> _trigParsedMap;
107  std::map<std::set<std::string>, ROSEE::ActionPrimitive::Ptr> _tipFlexParsedMap;
108  std::map<std::set<std::string>, ROSEE::ActionPrimitive::Ptr> _fingFlexParsedMap;
109 
110  std::shared_ptr<ROSEE::ActionGeneric> _graspParsed;
111 
113 
114  std::shared_ptr <RosServiceHandler> _ros_service_handler;
115  std::shared_ptr <RosActionServer> _ros_action_server;
116 
120 
122  std::shared_ptr<ROSEE::ActionTimed> timedAction;
123  unsigned int timed_index;
124  ROSEE::Utils::Timer<> timer; //for time margins of timed action
125  double msToWait;
126 
127 };
128 
129 } //namespace
130 
131 #endif //__ROSEE_UNIVERSAL_ROS_END_EFFECTOR_EXECUTOR_
std::map< std::set< std::string >, ROSEE::ActionPrimitive::Ptr > _pinchLooseParsedMap
std::shared_ptr< EEInterface > Ptr
Definition: EEInterface.h:40
void timer_callback(const ros::TimerEvent &timer_ev)
std::map< std::set< std::string >, ROSEE::ActionPrimitive::Ptr > _fingFlexParsedMap
std::map< std::set< std::string >, ROSEE::ActionPrimitive::Ptr > _pinchParsedMap
std::map< std::string, std::vector< double > > JointPos
The map to describe the position of all actuated joints.
Definition: Action.h:40
std::map< std::string, unsigned int > JointsInvolvedCount
The map to describe, how many times a joint is set by the action.
Definition: Action.h:63
std::shared_ptr< RosServiceHandler > _ros_service_handler
std::shared_ptr< RosActionServer > _ros_action_server
std::shared_ptr< ROSEE::ActionGeneric > _graspParsed
std::shared_ptr< ActionPrimitive > Ptr
std::map< std::set< std::string >, ROSEE::ActionPrimitive::Ptr > _tipFlexParsedMap
ROSEE::Utils::SecondOrderFilter< Eigen::VectorXd > _filt_q
Class representing the ROS executor implementing the unviversal ROS EE concept.
double sendFeedbackGoal(std::string currentAction="")
std::shared_ptr< UniversalRosEndEffectorExecutor > Ptr
std::shared_ptr< const UniversalRosEndEffectorExecutor > ConstPtr
void joint_state_clbk(const sensor_msgs::JointStateConstPtr &msg)
std::shared_ptr< MapActionHandler > Ptr
std::shared_ptr< ROSEE::ActionTimed > timedAction
bool readOptionalCommands(std::vector< std::string > motors_names, std::vector< double > motors_commands)
std::map< std::set< std::string >, ROSEE::ActionPrimitive::Ptr > _trigParsedMap