RobotArmLib  0.0.4
Robot Arm Library [WIP]
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Pages
artic.h
Go to the documentation of this file.
1 
7 #ifndef RB_ARTIC_H_
8 #define RB_ARTIC_H_
9 
10 #include "kinematic_chain.h"
11 
12 
13 namespace rb
14 {
15 namespace kin
16 {
17 // Class of kinematics of articulated (6-axis) robot arm
22 class Artic : public KinematicChain
23 {
24 public:
26  Artic();
27 
29  Artic(
30  const rb::math::VectorX& a0,
31  const rb::math::VectorX& alpha0,
32  const rb::math::VectorX& d0,
33  const rb::math::VectorX& ini_theta,
34  const rb::math::VectorX& uplimit0,
35  const rb::math::VectorX& lowlimit0
36  );
37 
39  Artic(
40  std::vector<rb::kin::Link*>& links,
41  rb::math::Matrix4 base=rb::math::Matrix4::Identity(),
42  rb::math::Matrix4 tool=rb::math::Matrix4::Identity(),
43  rb::math::Vector3 gravity={0., 0., rb::math::GRAVITY},
44  std::string manufactor="None",
45  std::string model="None"
46  );
47 
49  ~Artic();
50 
58  ArmPose forwardKin(const rb::math::VectorX& q, const bool update=true) override;
59 
66  const rb::math::Matrix4& world_tcp_tf,
67  rb::math::VectorX& joints,
68  ArmAxisValue& all_sols
69  ) override;
70 
77  const double& x,
78  const double& y,
79  const double& z,
80  const double& roll,
81  const double& pitch,
82  const double& yaw,
83  rb::math::VectorX& joints,
84  ArmAxisValue& all_sols
85  );
86 
96  void solvePitchPitchIK(const double& th1_rad, const rb::math::Vector4& p0,
97  const std::vector<bool>& config,
98  ArmAxisValue& all_sols);
99 
108  void solveRowPitchRowIK(const double& th1_rad, const std::vector<bool>& config,
109  const rb::math::Matrix4& flange_tr,
110  ArmAxisValue& all_sols);
111 
117 
124  void preCheck(const int& njoint, double& rad);
125 
130  ArmPose getArmPose(void) const;
131 
136  rb::math::VectorX getA(void) const;
137 
142  rb::math::VectorX getAlpha(void) const;
143 
148  rb::math::VectorX getD(void) const;
149 
154  rb::math::VectorX getTheta(void) const;
155 
160  void setUpLimit(rb::math::VectorX& up_lim);
161 
166  rb::math::VectorX getUpLimit(void) const;
167 
172  void setLowLimit(rb::math::VectorX& low_lim);
173 
178  rb::math::VectorX getLowLimit(void) const;
179 
180 protected:
183 
185 
187 
191 
192 private:
193  rb::math::VectorX ini_theta_;
194  rb::math::VectorX pre_theta_;
195  rb::math::Matrix4 base_tcp_tf_;
196  ArmPose tcp_pose_;
197  int pre_fit_solution_;
198 
199  // private functions
200  // TODO: could move functions for matrix manipulating, such as rpy2tr & tr2rpy to math.h
201  void tr2rpy(const rb::math::Matrix4& m, double& roll_z, double& pitch_y, double& yaw_x);
202  void rpy2tr(double& roll_z, double& pitch_y, double& yaw_x, rb::math::Matrix4& tool_mat);
203  rb::math::Matrix4 rotateX(const double& deg);
204  rb::math::Matrix4 rotateY(const double& deg);
205  rb::math::Matrix4 rotateZ(const double& deg);
206 };
207 
208 } // namespace kin
209 } // namespace rb
210 
211 #endif // RB_ARTIC_H_
Artic()
Default Constructor.
Definition: artic.cpp:30
IK_RESULT
A set of enumeration to present the result of inverse kinematics (IK)
Definition: kinematic_chain.h:27
ArmPose forwardKin(const rb::math::VectorX &q, const bool update=true) override
Compute forward Kinematics for given angle, update each joint value, and return current current posit...
Definition: artic.cpp:277
rb::math::VectorX up_lim_
Upper limit of all joints.
Definition: artic.h:189
A kinematics class for general serial links.
Definition: kinematic_chain.h:104
A struct variable for Tool Center Point (TCP) ArmPose storages the output of forward kinematic...
Definition: kinematic_chain.h:40
ArmPose getArmPose(void) const
Get the position and orientation of the flange of robot arm.
Definition: artic.cpp:793
void solvePitchPitchIK(const double &th1_rad, const rb::math::Vector4 &p0, const std::vector< bool > &config, ArmAxisValue &all_sols)
Compute inverse kinematics for two links (pitch-pitch) structure by given first joint.
Definition: artic.cpp:555
Eigen::Matrix4d Matrix4
make Matrix4 as alias of Eigen::Matrix4d
Definition: matrix.h:20
Eigen::Vector4d Vector4
make Vector4 as alias of Eigen::Vector4d
Definition: matrix.h:24
IK_RESULT solutionCheck(ArmAxisValue &sols)
Find the solutions in all_sols that is most fit to previous joints value.
Definition: artic.cpp:694
~Artic()
Destructor.
Definition: artic.cpp:274
rb::math::VectorX low_lim_
Lower limit of all joints.
Definition: artic.h:190
rb::math::VectorX getAlpha(void) const
Get the link twist value between each joint of the robot arm.
Definition: artic.cpp:803
rb::math::VectorX getTheta(void) const
Get the joint angle value of each joint of the robot arm.
Definition: artic.cpp:813
IK_RESULT inverseKin(const rb::math::Matrix4 &world_tcp_tf, rb::math::VectorX &joints, ArmAxisValue &all_sols) override
Compute inverse kinematics for given transformation matrix of TCP in Cartesian coordination system...
Definition: artic.cpp:317
Eigen::Vector3d Vector3
make Vector3 as alias of Eigen::Vector3d
Definition: matrix.h:23
rb::math::VectorX getA(void) const
Get the link length a value between each joint of the robot arm.
Definition: artic.cpp:798
rb::math::VectorX getUpLimit(void) const
Get the upper limits of joint angles of the robot arm.
Definition: artic.cpp:824
void setLowLimit(rb::math::VectorX &low_lim)
Set the lower limits of joint angles for the robot arm.
Definition: artic.cpp:829
void setUpLimit(rb::math::VectorX &up_lim)
Set the upper limits of joint angles for the robot arm.
Definition: artic.cpp:818
rb::math::VectorX d
Link offset data member of modified D-H parameter for robot arm.
Definition: artic.h:186
rb::math::VectorX getD(void) const
Get the link offset d value between each joint of the robot arm.
Definition: artic.cpp:808
A kinematics class for articulated (6-axis) robot arm Artic implement the kinematics of articulated (...
Definition: artic.h:22
rb::math::VectorX alpha
Link twist data member of modified D-H parameter for robot arm.
Definition: artic.h:184
void solveRowPitchRowIK(const double &th1_rad, const std::vector< bool > &config, const rb::math::Matrix4 &flange_tr, ArmAxisValue &all_sols)
Compute inverse kinematics for wrist mechanism (row-pitch-row) structure by given first joint...
Definition: artic.cpp:623
A struct variable for joints of robot arm ArmAxisValue storage the output of Inverse kinematic...
Definition: kinematic_chain.h:78
A header file for the class of general kinematic chain.
static const double GRAVITY
Constant to present value of gravity.
Definition: unit.h:28
void preCheck(const int &njoint, double &rad)
Check the value of individual joint depend join limits.
Definition: artic.cpp:771
rb::math::VectorX a
Link length data member of modified D-H parameter for robot arm.
Definition: artic.h:182
Eigen::VectorXd VectorX
make VectorX as alias of Eigen::VectorXd
Definition: matrix.h:22
rb::math::VectorX theta
Joint angle data member of modified D-H parameter for robot arm.
Definition: artic.h:188
rb::math::VectorX getLowLimit(void) const
Get the lower limits of joint angles of the robot arm.
Definition: artic.cpp:835