moveit_opw_kinematics_plugin.h
Go to the documentation of this file.
1 #ifndef MOVEIT_OPW_KINEMATICS_PLUGIN_
2 #define MOVEIT_OPW_KINEMATICS_PLUGIN_
3 
4 // ROS
5 #include <ros/ros.h>
6 
7 // System
8 #include <memory>
9 
10 // ROS msgs
11 #include <geometry_msgs/PoseStamped.h>
12 #include <moveit_msgs/GetPositionFK.h>
13 #include <moveit_msgs/GetPositionIK.h>
14 #include <moveit_msgs/KinematicSolverInfo.h>
15 #include <moveit_msgs/MoveItErrorCodes.h>
16 
17 // MoveIt!
21 
22 // OPW kinematics
24 
26 {
33 {
34 public:
35  // struct for storing and sorting solutions
37  {
38  std::vector<double> value;
40 
41  bool operator<(const LimitObeyingSol& a) const
42  {
43  return dist_from_seed < a.dist_from_seed;
44  }
45  };
46 
51 
52  virtual bool
53  getPositionIK(const geometry_msgs::Pose& ik_pose, const std::vector<double>& ik_seed_state,
54  std::vector<double>& solution, moveit_msgs::MoveItErrorCodes& error_code,
56 
57  virtual bool
58  searchPositionIK(const geometry_msgs::Pose& ik_pose, const std::vector<double>& ik_seed_state, double timeout,
59  std::vector<double>& solution, moveit_msgs::MoveItErrorCodes& error_code,
61 
62  virtual bool
63  searchPositionIK(const geometry_msgs::Pose& ik_pose, const std::vector<double>& ik_seed_state, double timeout,
64  const std::vector<double>& consistency_limits, std::vector<double>& solution,
65  moveit_msgs::MoveItErrorCodes& error_code,
67 
68  virtual bool searchPositionIK(
69  const geometry_msgs::Pose& ik_pose, const std::vector<double>& ik_seed_state, double timeout,
70  std::vector<double>& solution, const IKCallbackFn& solution_callback, moveit_msgs::MoveItErrorCodes& error_code,
72 
73  virtual bool
74  searchPositionIK(const geometry_msgs::Pose& ik_pose, const std::vector<double>& ik_seed_state, double timeout,
75  const std::vector<double>& consistency_limits, std::vector<double>& solution,
76  const IKCallbackFn& solution_callback, moveit_msgs::MoveItErrorCodes& error_code,
78 
79  virtual bool getPositionFK(const std::vector<std::string>& link_names, const std::vector<double>& joint_angles,
80  std::vector<geometry_msgs::Pose>& poses) const override;
81 
82  virtual bool initialize(const std::string& robot_description, const std::string& group_name,
83  const std::string& base_name, const std::string& tip_frame, double search_discretization) override
84  {
85  std::vector<std::string> tip_frames;
86  tip_frames.push_back(tip_frame);
87  return initialize(robot_description, group_name, base_name, tip_frames, search_discretization);
88  }
89 
90  virtual bool initialize(const std::string& robot_description, const std::string& group_name,
91  const std::string& base_name, const std::vector<std::string>& tip_frames,
92  double search_discretization) override;
93 
97  const std::vector<std::string>& getJointNames() const override;
98 
102  const std::vector<std::string>& getLinkNames() const override;
103 
107  const std::vector<std::string>& getVariableNames() const;
108 
109  virtual bool
110  getPositionIK(const std::vector<geometry_msgs::Pose>& ik_poses, const std::vector<double>& ik_seed_state,
111  std::vector<std::vector<double>>& solutions, KinematicsResult& result,
113 
114 protected:
115  virtual bool
116  searchPositionIK(const geometry_msgs::Pose& ik_pose, const std::vector<double>& ik_seed_state, double timeout,
117  std::vector<double>& solution, const IKCallbackFn& solution_callback,
118  moveit_msgs::MoveItErrorCodes& error_code, const std::vector<double>& consistency_limits,
120 
121  virtual bool
122  searchPositionIK(const std::vector<geometry_msgs::Pose>& ik_poses, const std::vector<double>& ik_seed_state,
123  double timeout, const std::vector<double>& consistency_limits, std::vector<double>& solution,
124  const IKCallbackFn& solution_callback, moveit_msgs::MoveItErrorCodes& error_code,
126 
127  virtual bool setRedundantJoints(const std::vector<unsigned int>& redundant_joint_indices) override;
128 
129 private:
130  bool timedOut(const ros::WallTime& start_time, double duration) const;
131 
132  int getJointIndex(const std::string& name) const;
133 
134  bool isRedundantJoint(unsigned int index) const;
135 
136  bool setOPWParameters();
137 
138  static double distance(const std::vector<double>& a, const std::vector<double>& b);
139  static std::size_t closestJointPose(const std::vector<double>& target,
140  const std::vector<std::vector<double>>& candidates);
141  bool getAllIK(const Eigen::Affine3d& pose, std::vector<std::vector<double>>& joint_poses) const;
142  bool getIK(const Eigen::Affine3d& pose, const std::vector<double>& seed_state, std::vector<double>& joint_pose) const;
143 
149  bool selfTest();
150 
154  bool comparePoses(Eigen::Isometry3d& Ta, Eigen::Affine3d& Tb);
155 
156  bool active_;
158  moveit_msgs::KinematicSolverInfo ik_group_info_;
160  unsigned int dimension_;
162  robot_model::RobotModelPtr robot_model_;
163  robot_model::JointModelGroup* joint_model_group_;
164 
165  robot_state::RobotStatePtr robot_state_;
166 
168 
170 };
171 } // namespace moveit_opw_kinematics_plugin
172 
173 #endif
static std::size_t closestJointPose(const std::vector< double > &target, const std::vector< std::vector< double >> &candidates)
const std::vector< std::string > & getJointNames() const override
Return all the joint names in the order they are used internally.
bool selfTest()
check forward and inverse kinematics consistency
bool comparePoses(Eigen::Isometry3d &Ta, Eigen::Affine3d &Tb)
check if two poses are the same within an absolute tolerance of 1e-6
bool getIK(const Eigen::Affine3d &pose, const std::vector< double > &seed_state, std::vector< double > &joint_pose) const
virtual bool getPositionFK(const std::vector< std::string > &link_names, const std::vector< double > &joint_angles, std::vector< geometry_msgs::Pose > &poses) const override
const std::vector< std::string > & getLinkNames() const override
Return all the link names in the order they are represented internally.
virtual bool searchPositionIK(const geometry_msgs::Pose &ik_pose, const std::vector< double > &ik_seed_state, double timeout, std::vector< double > &solution, moveit_msgs::MoveItErrorCodes &error_code, const kinematics::KinematicsQueryOptions &options=kinematics::KinematicsQueryOptions()) const override
virtual bool getPositionIK(const geometry_msgs::Pose &ik_pose, const std::vector< double > &ik_seed_state, std::vector< double > &solution, moveit_msgs::MoveItErrorCodes &error_code, const kinematics::KinematicsQueryOptions &options=kinematics::KinematicsQueryOptions()) const override
virtual bool initialize(const std::string &robot_description, const std::string &group_name, const std::string &base_name, const std::string &tip_frame, double search_discretization) override
bool getAllIK(const Eigen::Affine3d &pose, std::vector< std::vector< double >> &joint_poses) const
unsigned int index
Specific implementation of kinematics using ROS service calls to communicate with external IK solvers...
options
static double distance(const std::vector< double > &a, const std::vector< double > &b)
boost::function< void(const geometry_msgs::Pose &ik_pose, const std::vector< double > &ik_solution, moveit_msgs::MoveItErrorCodes &error_code)> IKCallbackFn
virtual bool setRedundantJoints(const std::vector< unsigned int > &redundant_joint_indices) override
bool timedOut(const ros::WallTime &start_time, double duration) const
const std::vector< std::string > & getVariableNames() const
Return all the variable names in the order they are represented internally.


moveit_opw_kinematics_plugin
Author(s): Jeroen De Maeyer, Simon Schmeisser (isys vision)
autogenerated on Wed Jun 3 2020 03:17:14