1+ #pragma once
2+
3+ #include " ../navtypes.h"
4+ #include " ForwardArmKinematics.h"
5+
6+ #include < Eigen/Core>
7+ #include < cmath>
8+
9+ namespace kinematics {
10+
11+ /* *
12+ * @brief Kinematics object for the 2026 arm in 3D space.
13+ */
14+ class ArmFK2026 : public ForwardArmKinematics <3 , 3 > {
15+ public:
16+ /* *
17+ * @brief Construct a new kinematics object.
18+ *
19+ * @param segLens The length of each arm segment (only shoulder and elbow).
20+ * @param jointMin The minimum angle of each joint.
21+ * @param jointMax The maximum angle of each joint.
22+ */
23+ ArmFK2026 (const navtypes::Vectord<3 >& segLens,
24+ const navtypes::Vectord<3 >& jointMin,
25+ const navtypes::Vectord<3 >& jointMax)
26+ : segLens(segLens), jointMin(jointMin), jointMax(jointMax) {}
27+
28+ navtypes::Vectord<3 > getSegLens () const override {
29+ return segLens;
30+ }
31+
32+ bool satisfiesConstraints (const navtypes::Vectord<3 >& jointPos) const override {
33+ for (unsigned int i = 0 ; i < 3 ; i++) {
34+ if (jointPos[i] < jointMin[i] || jointPos[i] > jointMax[i]) {
35+ return false ;
36+ }
37+ }
38+ return true ;
39+ }
40+
41+ navtypes::Vectord<3 > jointPosToEEPos (const navtypes::Vectord<3 >& jointPos) const override {
42+ double theta_B = jointPos[0 ];
43+ double theta_S = jointPos[1 ];
44+ double theta_E = jointPos[2 ];
45+
46+ double l = segLens[1 ];
47+ double t = segLens[2 ];
48+
49+ double x = std::cos (theta_B) * (l * std::sin (theta_S) + t * std::cos (theta_E));
50+ double y = std::sin (theta_B) * (l * std::sin (theta_S) + t * std::cos (theta_E));
51+ double z = l * std::cos (theta_S) - t * std::sin (theta_E);
52+
53+ return Eigen::Vector3d (x, y, z);
54+ }
55+
56+ navtypes::Matrixd<3 , 3 > getJacobian (const navtypes::Vectord<3 >& jointPos) const override {
57+ double theta_B = jointPos[0 ];
58+ double theta_S = jointPos[1 ];
59+ double theta_E = jointPos[2 ];
60+
61+ double l = segLens[1 ];
62+ double t = segLens[2 ];
63+
64+ Eigen::Matrix<double , 3 , 3 > J;
65+
66+ // Partial derivatives for X
67+ J (0 , 0 ) = -std::sin (theta_B) * (l * std::sin (theta_S) + t * std::cos (theta_E));
68+ J (0 , 1 ) = std::cos (theta_B) * (l * std::cos (theta_S));
69+ J (0 , 2 ) = std::cos (theta_B) * (-t * std::sin (theta_E));
70+
71+ // Partial derivatives for Y
72+ J (1 , 0 ) = std::cos (theta_B) * (l * std::sin (theta_S) + t * std::cos (theta_E));
73+ J (1 , 1 ) = std::sin (theta_B) * (l * std::cos (theta_S));
74+ J (1 , 2 ) = std::sin (theta_B) * (-t * std::sin (theta_E));
75+
76+ // Partial derivatives for Z
77+ J (2 , 0 ) = 0.0 ; // The base rotation does not affect the Z height
78+ J (2 , 1 ) = -l * std::sin (theta_S);
79+ J (2 , 2 ) = -t * std::cos (theta_E);
80+
81+ return J;
82+ }
83+
84+ private:
85+ navtypes::Vectord<3 > segLens;
86+ navtypes::Vectord<3 > jointMin;
87+ navtypes::Vectord<3 > jointMax;
88+ };
89+
90+ } // namespace kinematics
0 commit comments