37 #ifndef MOVEIT_KINEMATICS_BASE_KINEMATICS_BASE_ 38 #define MOVEIT_KINEMATICS_BASE_KINEMATICS_BASE_ 40 #include <geometry_msgs/PoseStamped.h> 41 #include <moveit_msgs/MoveItErrorCodes.h> 45 #include <boost/function.hpp> 65 namespace DiscretizationMethods
85 namespace KinematicErrors
110 : lock_redundant_joints(false)
111 , return_approximate_solution(false)
151 typedef boost::function<void(const geometry_msgs::Pose& ik_pose, const std::vector<double>& ik_solution,
152 moveit_msgs::MoveItErrorCodes& error_code)>
166 getPositionIK(
const geometry_msgs::Pose& ik_pose,
const std::vector<double>& ik_seed_state,
167 std::vector<double>& solution, moveit_msgs::MoveItErrorCodes& error_code,
185 virtual bool getPositionIK(
const std::vector<geometry_msgs::Pose>& ik_poses,
const std::vector<double>& ik_seed_state,
203 searchPositionIK(
const geometry_msgs::Pose& ik_pose,
const std::vector<double>& ik_seed_state,
double timeout,
204 std::vector<double>& solution, moveit_msgs::MoveItErrorCodes& error_code,
223 searchPositionIK(
const geometry_msgs::Pose& ik_pose,
const std::vector<double>& ik_seed_state,
double timeout,
224 const std::vector<double>& consistency_limits, std::vector<double>& solution,
225 moveit_msgs::MoveItErrorCodes& error_code,
243 searchPositionIK(
const geometry_msgs::Pose& ik_pose,
const std::vector<double>& ik_seed_state,
double timeout,
244 std::vector<double>& solution,
const IKCallbackFn& solution_callback,
245 moveit_msgs::MoveItErrorCodes& error_code,
265 searchPositionIK(
const geometry_msgs::Pose& ik_pose,
const std::vector<double>& ik_seed_state,
double timeout,
266 const std::vector<double>& consistency_limits, std::vector<double>& solution,
267 const IKCallbackFn& solution_callback, moveit_msgs::MoveItErrorCodes& error_code,
296 searchPositionIK(
const std::vector<geometry_msgs::Pose>& ik_poses,
const std::vector<double>& ik_seed_state,
297 double timeout,
const std::vector<double>& consistency_limits, std::vector<double>& solution,
298 const IKCallbackFn& solution_callback, moveit_msgs::MoveItErrorCodes& error_code,
303 if (ik_poses.size() == 1)
306 if (solution_callback)
308 return searchPositionIK(ik_poses[0], ik_seed_state, timeout, consistency_limits, solution, solution_callback,
309 error_code, options);
313 return searchPositionIK(ik_poses[0], ik_seed_state, timeout, consistency_limits, solution, error_code, options);
318 ROS_ERROR_NAMED(
"kinematics_base",
"This kinematic solver does not support searchPositionIK with multiple poses");
329 virtual bool getPositionFK(
const std::vector<std::string>& link_names,
const std::vector<double>& joint_angles,
330 std::vector<geometry_msgs::Pose>& poses)
const = 0;
342 virtual void setValues(
const std::string& robot_description,
const std::string& group_name,
343 const std::string& base_frame,
const std::string& tip_frame,
double search_discretization);
355 virtual void setValues(
const std::string& robot_description,
const std::string& group_name,
356 const std::string& base_frame,
const std::vector<std::string>& tip_frames,
357 double search_discretization);
370 virtual bool initialize(
const std::string& robot_description,
const std::string& group_name,
371 const std::string& base_frame,
const std::string& tip_frame,
372 double search_discretization) = 0;
385 virtual bool initialize(
const std::string& robot_description,
const std::string& group_name,
386 const std::string& base_frame,
const std::vector<std::string>& tip_frames,
387 double search_discretization)
390 if (tip_frames.size() == 1)
392 return initialize(robot_description, group_name, base_frame, tip_frames[0], search_discretization);
395 ROS_ERROR_NAMED(
"kinematics_base",
"This kinematic solver does not support initialization " 396 "with more than one tip frames");
428 if (tip_frames_.size() > 1)
429 ROS_ERROR_NAMED(
"kinematics_base",
"This kinematic solver has more than one tip frame, " 430 "do not call getTipFrame()");
454 virtual bool setRedundantJoints(
const std::vector<unsigned int>& redundant_joint_indices);
463 bool setRedundantJoints(
const std::vector<std::string>& redundant_joint_names);
470 redundant_joint_indices = redundant_joint_indices_;
476 virtual const std::vector<std::string>& getJointNames()
const = 0;
481 virtual const std::vector<std::string>& getLinkNames()
const = 0;
506 redundant_joint_discretization_.clear();
507 for (std::vector<unsigned int>::iterator i = redundant_joint_indices_.begin(); i != redundant_joint_indices_.end();
510 redundant_joint_discretization_[*i] = sd;
523 redundant_joint_discretization_.clear();
524 redundant_joint_indices_.clear();
525 for (std::map<int, double>::const_iterator i = discretization.begin(); i != discretization.end(); i++)
527 redundant_joint_discretization_.insert(*i);
528 redundant_joint_indices_.push_back(i->first);
537 if (redundant_joint_discretization_.count(joint_index) > 0)
539 return redundant_joint_discretization_.at(joint_index);
553 return supported_methods_;
560 default_timeout_ = timeout;
567 return default_timeout_;
578 : tip_frame_(
"DEPRECATED")
581 search_discretization_(DEFAULT_SEARCH_DISCRETIZATION)
582 , default_timeout_(DEFAULT_TIMEOUT)
617 template <
typename T>
618 inline bool lookupParam(
const std::string& param, T& val,
const T& default_val)
const 621 if (pnh.
hasParam(group_name_ +
"/" + param))
623 val = pnh.
param(group_name_ +
"/" + param, default_val);
629 val = pnh.
param(param, default_val);
634 if (nh.
hasParam(
"robot_description_kinematics/" + group_name_ +
"/" + param))
636 val = nh.
param(
"robot_description_kinematics/" + group_name_ +
"/" + param, default_val);
640 if (nh.
hasParam(
"robot_description_kinematics/" + param))
642 val = nh.
param(
"robot_description_kinematics/" + param, default_val);
652 std::string removeSlash(
const std::string& str)
const;
std::vector< unsigned int > redundant_joint_indices_
KinematicError kinematic_error
double getDefaultTimeout() const
For functions that require a timeout specified but one is not specified using arguments, this default timeout is used.
A set of options for the kinematics solver.
virtual const std::string & getGroupName() const
Return the name of the group that the solver is operating on.
virtual const std::string & getBaseFrame() const
Return the name of the frame in which the solver is operating. This is usually a link name...
void setDefaultTimeout(double timeout)
For functions that require a timeout specified but one is not specified using arguments, a default timeout is used, as set by this function (and initialized to KinematicsBase::DEFAULT_TIMEOUT)
ROSCONSOLE_DECL void initialize()
void setSearchDiscretization(double sd)
Set the search discretization value for all the redundant joints.
std::vector< std::string > tip_frames_
double solution_percentage
static const double DEFAULT_TIMEOUT
std::vector< DiscretizationMethod > getSupportedDiscretizationMethods() const
Returns the set of supported kinematics discretization search types. This implementation only support...
bool lock_redundant_joints
virtual const std::vector< std::string > & getTipFrames() const
Return the names of the tip frames of the kinematic tree on which the solver is operating. This is usually a link name. No namespacing (e.g., no "/" prefix) should be used.
DiscretizationMethods::DiscretizationMethod DiscretizationMethod
bool return_approximate_solution
double getSearchDiscretization(int joint_index=0) const
Get the value of the search discretization.
Provides an interface for kinematics solvers.
virtual void getRedundantJoints(std::vector< unsigned int > &redundant_joint_indices) const
Get the set of redundant joints.
MOVEIT_CLASS_FORWARD(RobotModel)
virtual const std::string & getTipFrame() const
Return the name of the tip frame of the chain on which the solver is operating. This is usually a lin...
bool param(const std::string ¶m_name, T ¶m_val, const T &default_val) const
virtual ~KinematicsBase()
Virtual destructor for the interface.
DiscretizationMethod discretization_method
std::vector< DiscretizationMethod > supported_methods_
bool lookupParam(const std::string ¶m, T &val, const T &default_val) const
Enables kinematics plugins access to parameters that are defined for the private namespace and inside...
boost::function< void(const geometry_msgs::Pose &ik_pose, const std::vector< double > &ik_solution, moveit_msgs::MoveItErrorCodes &error_code)> IKCallbackFn
The signature for a callback that can compute IK.
virtual bool searchPositionIK(const std::vector< geometry_msgs::Pose > &ik_poses, const std::vector< double > &ik_seed_state, double timeout, const std::vector< double > &consistency_limits, std::vector< double > &solution, const IKCallbackFn &solution_callback, moveit_msgs::MoveItErrorCodes &error_code, const kinematics::KinematicsQueryOptions &options=kinematics::KinematicsQueryOptions(), const moveit::core::RobotState *context_state=NULL) const
Given a set of desired poses for a planning group with multiple end-effectors, search for the joint a...
std::map< int, double > redundant_joint_discretization_
static const double DEFAULT_SEARCH_DISCRETIZATION
void setSearchDiscretization(const std::map< int, double > &discretization)
Sets individual discretization values for each redundant joint.
API for forward and inverse kinematics.
double search_discretization_
#define ROS_ERROR_NAMED(name,...)
Representation of a robot's state. This includes position, velocity, acceleration and effort...
virtual bool initialize(const std::string &robot_description, const std::string &group_name, const std::string &base_frame, const std::vector< std::string > &tip_frames, double search_discretization)
Initialization function for the kinematics, for use with non-chain IK solvers.
bool hasParam(const std::string &key) const
Main namespace for MoveIt!
std::string robot_description_
KinematicErrors::KinematicError KinematicError