28 const std::array<double, 7>& dq,
29 const std::array<double, 9>& i_total,
31 const std::array<double, 3>& f_x_ctotal,
32 std::array<double, 7>& c_ne)
override;
35 const std::array<double, 7>& dq,
36 const std::array<double, 9>& i_total,
38 const std::array<double, 3>& f_x_ctotal,
39 const std::array<double, 3>& g_earth,
40 std::array<double, 7>& c_ne)
override;
42 void gravity(
const std::array<double, 7>& q,
43 const std::array<double, 3>& g_earth,
45 const std::array<double, 3>& f_x_ctotal,
46 std::array<double, 7>& g_ne)
override;
48 void mass(
const std::array<double, 7>& q,
49 const std::array<double, 9>& i_total,
51 const std::array<double, 3>& f_x_ctotal,
52 std::array<double, 49>& m_ne)
override;
53 std::array<double, 16>
pose(
54 const std::array<double, 7>& q,
55 int joint_index)
override;
57 const std::array<double, 7>& q,
58 const std::array<double, 16>& f_t_ee)
override;
60 const std::array<double, 7>& q)
override;
62 const std::array<double, 7>& q,
63 const std::array<double, 16>& f_t_ee,
64 const std::array<double, 16>& ee_t_k)
override;
66 const std::array<double, 7>& q,
67 int joint_index)
override;
69 const std::array<double, 7>& q)
override;
71 const std::array<double, 7>& q,
72 const std::array<double, 16>& f_t_ee)
override;
74 const std::array<double, 7>& q,
75 const std::array<double, 16>& f_t_ee,
76 const std::array<double, 16>& ee_t_k)
override;
78 const std::array<double, 7>& q,
79 int joint_index)
override;
81 const std::array<double, 7>& q)
override;
83 const std::array<double, 7>& q,
84 const std::array<double, 16>& f_t_ee)
override;
86 const std::array<double, 7>& q,
87 const std::array<double, 16>& f_t_ee,
88 const std::array<double, 16>& ee_t_k)
override;
91 mutable pinocchio::Data data_;
92 mutable pinocchio::Data data_gravity_;
94 mutable Eigen::Matrix<double, 7, 1> q_eigen_;
95 mutable Eigen::Matrix<double, 7, 1> dq_eigen_;
96 mutable Eigen::Matrix<double, 7, 1> tau_eigen_;
97 mutable Eigen::Matrix<double, 7, 1> ddq_temp_eigen_;
98 mutable Eigen::Vector3d com_eigen_;
99 mutable Eigen::Matrix3d inertia_eigen_;
101 mutable std::array<double, 9> cached_i_total_;
102 mutable double cached_m_total_{-1.0};
103 mutable std::array<double, 3> cached_f_x_ctotal_;
104 mutable bool inertia_cache_valid_{
false};
106 mutable pinocchio::Model pinocchio_model_;
112 pinocchio::Data computeForwardKinematics(
113 const std::array<double, 7>& q)
const;
120 static std::array<double, 16> eigenToArray(
const Eigen::Matrix4d& matrix);
127 static std::array<double, 42> eigenToArray(
const Eigen::Matrix<double, 6, 7>& matrix);
134 pinocchio::Data initializeModelAndReturnData(
const std::string& urdf);
143 pinocchio::FrameIndex addFrame(
const std::string& name,
144 pinocchio::FrameIndex parent_frame_id,
145 const pinocchio::SE3& placement);
155 std::array<double, 42> computeJacobian(
156 const std::array<double, 7>& q,
157 int frame_or_joint_index,
159 pinocchio::ReferenceFrame reference_frame);
168 std::array<double, 42> computeEeJacobian(
169 const std::array<double, 7>& q,
170 const std::array<double, 16>& f_t_ee,
171 pinocchio::ReferenceFrame reference_frame);
181 std::array<double, 42> computeStiffnessJacobian(
182 const std::array<double, 7>& q,
183 const std::array<double, 16>& f_t_ee,
184 const std::array<double, 16>& ee_t_k,
185 pinocchio::ReferenceFrame reference_frame);
193 void updateFramePlacements(
const std::array<double, 16>& f_t_ee,
194 const std::array<double, 16>& ee_t_k = {1, 0, 0, 0, 0, 1, 0, 0, 0, 0,
196 bool update_stiffness =
false);
204 void updateInertiaIfNeeded(
const std::array<double, 9>& i_total,
206 const std::array<double, 3>& f_x_ctotal)
const;
211 void restoreOriginalInertia()
const;
219 void computeGravityVector(
220 const std::array<double, 7>& q,
221 const std::array<double, 3>& g_earth,
222 std::array<double, 7>& g_ne)
const;
224 static constexpr const char* kLastLinkName =
"link8";
226 pinocchio::Inertia initial_last_link_inertia_;
227 pinocchio::FrameIndex last_link_frame_index_;
228 pinocchio::JointIndex last_joint_index_;
229 void copyToEigenQ(
const std::array<double, 7>& q)
const;
231 const std::array<double, 7>& dq)
const;
232 static void copyFromEigen(
const Eigen::VectorXd& src, std::array<double, 7>& dst);
233 static void copyFromEigenMatrix(
const Eigen::MatrixXd& src, std::array<double, 49>& dst);
234 pinocchio::FrameIndex ee_frame_index_;
235 pinocchio::FrameIndex stiffness_frame_index_;