20 #define CHAIN_PER_GROUP 1 34 std::string finger_name
40 _finger_joint_map.insert(std::make_pair(finger_name, std::vector<std::string>()));
43 KDL::Chain actual_chain;
44 if (
_robot_tree.getChain ( base_link, tip_link, actual_chain ) ) {
46 int segments_num = actual_chain.getNrOfSegments();
47 for (
int i = 0; i < segments_num; i++ ) {
49 KDL::Segment actual_segment = actual_chain.getSegment ( i );
50 KDL::Joint actual_joint = actual_segment.getJoint();
52 bool is_valid_joint =
false;
55 is_valid_joint = actual_joint.getTypeName() ==
"RotAxis";
59 auto urdf_joint =
_urdf_model->getJoint(actual_joint.getName());
60 bool is_mimic_joint = (urdf_joint->mimic ==
nullptr) ?
false :
true;
64 if ( is_valid_joint && (!is_mimic_joint) ) {
78 ROS_ERROR_STREAM (
"chain from base_link " << base_link <<
" to tip_link " << tip_link <<
" not found in the URDF" );
91 std::vector<srdf::Model::EndEffector> srdf_end_effectors =
_srdfdom.getEndEffectors();
95 if ( srdf_end_effectors.size() != 1 ) {
100 ROS_INFO_STREAM (
"ros_end_effector Parser found end_effector: " << srdf_end_effectors.at ( 0 ).name_ );
103 std::vector<srdf::Model::Group> srdf_groups =
_srdfdom.getGroups();
106 srdf::Model::Group fingers_group;
109 int group_num = srdf_groups.size();
111 std::string end_effector_group_name = srdf_end_effectors.at ( 0 ).component_group_;
112 for (
int i = 0; i < group_num; i++ ) {
113 if ( srdf_groups[i].name_ == end_effector_group_name ) {
114 fingers_group = srdf_groups[i];
115 ROS_INFO_STREAM (
"ros_end_effector Parser found group: " << end_effector_group_name <<
" in the SRDF with the following fingers: " );
129 for (
int j = 0; j < group_num; j++ ) {
144 ROS_ERROR_STREAM (
"for the finger chain groups you can specify only one chain per group in your SRDF check " <<
145 current_finger_group.name_.c_str() <<
" group" );
151 current_finger_group.chains_[0].second,
152 current_finger_group.name_
164 std::stringstream buffer_srdf;
165 buffer_srdf << t_srdf.rdbuf();
176 if (it.second->mimic ==
nullptr) {
178 if (it.second->type == urdf::Joint::CONTINUOUS ||
179 it.second->type == urdf::Joint::REVOLUTE ) {
198 std::vector<srdf::Model::PassiveJoint> passiveJointList =
_srdfdom.getPassiveJoints();
200 for (
auto passiveJoint : passiveJointList) {
211 if (it->compare(passiveJoint.name_) == 0 ) {
227 std::string xml_string;
228 std::fstream xml_file (
_urdf_path.c_str(), std::fstream::in );
229 if ( xml_file.is_open() ) {
231 while ( xml_file.good() ) {
234 std::getline ( xml_file, line );
235 xml_string += ( line +
"\n" );
244 ROS_ERROR_STREAM (
"in " << __func__ <<
" Failed to construct kdl tree" );
250 std::stringstream buffer_urdf;
251 buffer_urdf << t_urdf.rdbuf();
258 ROS_ERROR_STREAM (
"in " << __func__ <<
" : Can NOT open " <<
_urdf_path <<
" !" );
335 ROS_INFO_STREAM (
"ROSEndEffector Parser successfully configured using urdf file: " <<
_urdf_path 341 ROS_ERROR_STREAM (
"ROSEndEffector Parser error while parsing SRDF");
347 ROS_ERROR_STREAM (
"ROSEndEffector Parser error while parsing URDF");
375 ROS_ERROR_STREAM (
"in " << __func__ <<
" : '_urdf_path' and/or '_srdf_path' and/or 'actions_folder_path' not found on ROS parameter server" );
380 bool ROSEE::Parser::init (
const std::string& urdf_path,
const std::string& srdf_path,
const std::string& action_path ) {
394 ROS_INFO_STREAM (
"ROS End Effector: Finger Joints Map" );
395 ROS_INFO_STREAM (
"-------------------------" );
397 ROS_INFO_STREAM ( chain_joints.first );
399 int nJointInFinger = chain_joints.second.size();
401 if ( nJointInFinger == 0 ) {
403 ROS_INFO_STREAM (
"No actuated joint in this finger" );
407 for (
int i = 0; i < nJointInFinger ; i++ ) {
408 ROS_INFO_STREAM ( chain_joints.second.at ( i ) );
412 ROS_INFO_STREAM (
"-------------------------" );
416 ROS_ERROR_STREAM (
"in " << __func__ <<
" : ROSEE::Parser needs to be initialized. Call init() frist." );
std::string getSrdfString() const
get the whole srdf file parsed as a string
void printEndEffectorFingerJointsMap() const
Utility to print the mapping between the End Effector finger chains and the related actuated joints...
int getActuatedJointsNumber() const
getter for the total number of actuated joints in the configuration files
std::string getUrdfString() const
get the whole urdf file parsed as a string
std::vector< int > _fingers_group_id
bool configure()
configure the ROSEE parser based on the configration files requested
std::map< std::string, std::string > _joint_finger_map
bool init()
Initialization function using the ROS param ROSEEConfigPath.
std::string getEndEffectorName() const
getter for the configure End-Effector name
urdf::ModelInterfaceSharedPtr _urdf_model
std::string getActionPath() const
get the path where emit and parse grasping actions
bool removePassiveJoints()
Function to remove the passive joints from the filled maps.
std::map< std::string, std::vector< std::string > > _finger_joint_map
bool parseSRDF()
Function responsible to parse the SRDF data.
void addNotInFingerJoints()
Parser(const ros::NodeHandle &nh)
std::map< std::string, urdf::JointConstSharedPtr > getUrdfJointMap() const
getter for the URDF information of the joints of the End-Effector
bool parseURDF()
Function responsible to get the file needed to fill the internal data structure of the Parser with da...
std::vector< std::string > _fingers_names
std::map< std::string, urdf::JointConstSharedPtr > _urdf_joint_map
bool getJointsInFinger(std::string base_link, std::string tip_link, std::string finger_name)
fill a data structure related with the revolute/prismatic joints included in between base_link and ti...
std::map< std::string, std::string > getJointFingerMap() const
getter for a description of the End-Effector as a map of joint name, finger name
std::map< std::string, std::vector< std::string > > getFingerJointMap() const
getter for a description of the End-Effector as a map of finger name, finger joint names...