moveit2
The MoveIt Motion Planning Framework for ROS 2.
kinematic_terms.h
Go to the documentation of this file.
1 #pragma once
2 
4 
5 #include <Eigen/Geometry>
6 
8 {
12 inline Eigen::Vector3d quaternionRotationVector(const Eigen::Matrix3d& matrix)
13 {
14  Eigen::Quaterniond quaternion;
15  quaternion = matrix;
16  return Eigen::Vector3d(quaternion.x(), quaternion.y(), quaternion.z());
17 }
18 
22 inline Eigen::VectorXd concatVector(const Eigen::VectorXd& vector_a, const Eigen::VectorXd& vector_b)
23 {
24  Eigen::VectorXd out(vector_a.size() + vector_b.size());
25  out.topRows(vector_a.size()) = vector_a;
26  out.middleRows(vector_a.size(), vector_b.size()) = vector_b;
27  return out;
28 }
29 
33 template <typename T>
34 inline std::vector<T> concatVector(const std::vector<T>& vector_a, const std::vector<T>& vector_b)
35 {
36  std::vector<T> out;
37  out.insert(out.end(), vector_a.begin(), vector_a.end());
38  out.insert(out.end(), vector_b.begin(), vector_b.end());
39  return out;
40 }
41 
46 struct CartPoseErrCalculator : public sco::VectorOfVector
47 {
49  Eigen::Isometry3d target_pose_inv_;
50  planning_scene::PlanningSceneConstPtr planning_scene_;
51  std::string link_;
52  Eigen::Isometry3d tcp_;
53 
54  CartPoseErrCalculator(const Eigen::Isometry3d& pose, const planning_scene::PlanningSceneConstPtr planning_scene,
55  const std::string& link, Eigen::Isometry3d tcp = Eigen::Isometry3d::Identity())
56  : target_pose_inv_(pose.inverse()), planning_scene_(planning_scene), link_(link), tcp_(tcp)
57  {
58  }
59 
60  Eigen::VectorXd operator()(const Eigen::VectorXd& dof_vals) const override;
61 };
62 
63 // TODO(omid): The following should be added and adjusted from trajopt
64 // JointPosEqCost
65 // JointPosIneqCost
66 // JointPosEqConstraint
67 // JointPosIneqConstraint
68 
69 struct JointVelErrCalculator : sco::VectorOfVector
70 {
72  double target_;
74  double upper_tol_;
76  double lower_tol_;
78  {
79  }
80  JointVelErrCalculator(double target, double upper_tol, double lower_tol)
81  : target_(target), upper_tol_(upper_tol), lower_tol_(lower_tol)
82  {
83  }
84 
85  Eigen::VectorXd operator()(const Eigen::VectorXd& var_vals) const;
86 };
87 
88 struct JointVelJacobianCalculator : sco::MatrixOfVector
89 {
90  Eigen::MatrixXd operator()(const Eigen::VectorXd& var_vals) const;
91 };
92 
93 } // namespace trajopt_interface
ROS/KDL based interface for the inverse kinematics of the PR2 arm.
Vec3fX< details::Vec3Data< double > > Vector3d
Definition: fcl_compat.h:89
This namespace includes the central class for representing planning contexts.
Eigen::VectorXd concatVector(const Eigen::VectorXd &vector_a, const Eigen::VectorXd &vector_b)
Appends b to a of type VectorXd.
Eigen::Vector3d quaternionRotationVector(const Eigen::Matrix3d &matrix)
Extracts the vector part of quaternion.
Used to calculate the error for StaticCartPoseTermInfo This is converted to a cost or constraint usin...
planning_scene::PlanningSceneConstPtr planning_scene_
Eigen::VectorXd operator()(const Eigen::VectorXd &dof_vals) const override
CartPoseErrCalculator(const Eigen::Isometry3d &pose, const planning_scene::PlanningSceneConstPtr planning_scene, const std::string &link, Eigen::Isometry3d tcp=Eigen::Isometry3d::Identity())
EIGEN_MAKE_ALIGNED_OPERATOR_NEW Eigen::Isometry3d target_pose_inv_
Eigen::VectorXd operator()(const Eigen::VectorXd &var_vals) const
JointVelErrCalculator(double target, double upper_tol, double lower_tol)
Eigen::MatrixXd operator()(const Eigen::VectorXd &var_vals) const