RobotArmLib 0.0.6
Robot Arm Library [WIP]
Loading...
Searching...
No Matches
kinematic_chain.h
Go to the documentation of this file.
1
7#ifndef RB_KINEMATIC_CHAIN_H_
8#define RB_KINEMATIC_CHAIN_H_
9#include <iostream>
10#include <iomanip>
11#include <string>
12#include <vector>
13#include <array>
14#include <memory>
15
16#include "link.h"
17
18#include <Eigen/StdVector>
19
20namespace rb
21{
22namespace kin
23{
36
41struct ArmPose
42{
44 double x;
45 double y;
46 double z;
48 double a;
49 double b;
50 double c;
51};
52
58std::ostream& operator<< (std::ostream& ost, const ArmPose& pose);
59
60#if __cplusplus == 201103L
65template<typename T>
66 void ostrVec(std::ostream& ost, std::vector<T> vec_inp, int width=12)
67 {
68 ost << '\n';
69 for(auto& inp : vec_inp)
70 ost << std::right << std::setw(width) << inp;
71 return;
72 }
73#endif
74
80{
84 int fit;
85 std::array<bool, 8> solution_check = {{0}};
86 std::array<bool, 8> singular_check = {{0}};
87 std::array<bool, 8> limit_check = {{0}};
88
90 {
91 axis_value = rb::math::MatrixX::Constant(8, 6, 0.0);
92 fit = 0;
93 for (int i = 0; i < 8; i++)
94 {
96 }
97 }
98};
99
100
106{
107public:
108 EIGEN_MAKE_ALIGNED_OPERATOR_NEW
111
114 std::vector<std::unique_ptr<rb::kin::Link>>& links,
115 rb::math::Matrix4 base=rb::math::Matrix4::Identity(),
116 rb::math::Matrix4 tool=rb::math::Matrix4::Identity(),
118 std::string manufactor="None",
119 std::string model="None"
120 );
121
123 virtual ~KinematicChain();
124
132 virtual ArmPose forwardKin(const rb::math::VectorX& q, const bool update=true);
133
140 const rb::math::Matrix4& world_tcp_tf,
141 rb::math::VectorX& joints,
142 ArmAxisValue& all_sols
143 ) = 0;
144
154 rb::math::Matrix4 homoTrans(double& A, double& alpha, double& D, const double& theta);
155
162 bool setTool(const ArmPose& tool_pose);
163
170 bool getTool(ArmPose& tool_pose) const;
171
177 void setBase(const rb::math::Matrix4& base);
178
183 rb::math::Matrix4 getBase(void) const;
184
189 rb::math::Matrix4 getTCP(void) const;
190
195 void setDOF(void);
196
201 int getDOF(void) const;
202
203protected:
205 std::vector<std::unique_ptr<rb::kin::Link>> links_;
206
208 std::vector<rb::math::Matrix4> frames_;
209
210 int dof_;
215
216 std::string manufactor_;
217 std::string model_;
218
219};
220
221} // namespace kin
222} // namespace rb
223
224#endif // RB_KINEMATIC_CHAIN_H_
A kinematics class for general serial links.
Definition kinematic_chain.h:106
bool getTool(ArmPose &tool_pose) const
Get the HT matrix of the offset b/w the arm flange and equipped tool or end-effector.
Definition kinematic_chain.cpp:151
rb::math::Matrix4 getTCP(void) const
Get the HT matrix of TCP w.r.t world coordination.
Definition kinematic_chain.cpp:177
bool setTool(const ArmPose &tool_pose)
Set the HT matrix of the offset b/w the arm flange and equipped tool or end-effector.
Definition kinematic_chain.cpp:136
rb::math::Matrix4 getBase(void) const
Get the HT matrix of the working base of the robot arm.
Definition kinematic_chain.cpp:172
EIGEN_MAKE_ALIGNED_OPERATOR_NEW KinematicChain()
Default Constuctor.
Definition kinematic_chain.cpp:57
void setDOF(void)
Set the degree of freedom according to the property of links.
Definition kinematic_chain.cpp:182
virtual ~KinematicChain()
Destructor.
Definition kinematic_chain.cpp:100
std::vector< std::unique_ptr< rb::kin::Link > > links_
A vector of Link class.
Definition kinematic_chain.h:205
int dof_
A integer indicates the degree of freedom.
Definition kinematic_chain.h:210
rb::math::Vector3 gravity_
Gravity set as a vector.
Definition kinematic_chain.h:214
std::string manufactor_
the name of manufactor of the robot
Definition kinematic_chain.h:216
std::string model_
the model of the robot named by its manufactor
Definition kinematic_chain.h:217
rb::math::Matrix4 world_tcp_tf_
HT matrix of TCP with respected to world coordination.
Definition kinematic_chain.h:213
virtual IK_RESULT inverseKin(const rb::math::Matrix4 &world_tcp_tf, rb::math::VectorX &joints, ArmAxisValue &all_sols)=0
Compute inverse kinematics for given tranformation matrix of TCP in Cartesian coordination system.
rb::math::Matrix4 base_tf_
HT matrix of robot base with respected to world coordination.
Definition kinematic_chain.h:211
int getDOF(void) const
Get the degree of freedom of this kinematic chain.
Definition kinematic_chain.cpp:188
virtual ArmPose forwardKin(const rb::math::VectorX &q, const bool update=true)
Compute forward Kinematics for given angle, update each joint value, and return current current posit...
Definition kinematic_chain.cpp:102
rb::math::Matrix4 homoTrans(double &A, double &alpha, double &D, const double &theta)
Compute homogeneous transformation matrix for given link properties, and return the matrix.
Definition kinematic_chain.cpp:198
rb::math::Matrix4 tool_tf_
HT matrix of TCP with respected to robot flange (last joint)
Definition kinematic_chain.h:212
void setBase(const rb::math::Matrix4 &base)
Set the Homogeneous Transformation matrix of the working base of the robot arm.
Definition kinematic_chain.cpp:166
IK_RESULT
A set of enumeration to present the result of inverse kinematics (IK)
Definition kinematic_chain.h:29
@ IK_COMPLETE
value 0
Definition kinematic_chain.h:30
@ IK_ANGLE_LIMIT
value 2
Definition kinematic_chain.h:32
@ IK_NO_SOLUTION
value 1
Definition kinematic_chain.h:31
@ IK_SINGULAR
value 3
Definition kinematic_chain.h:33
@ IK_INPUT_INVALID
value 4
Definition kinematic_chain.h:34
std::ostream & operator<<(std::ostream &ost, const ArmPose &pose)
Overload << operator to print position & orientation in ArmPose.
Definition kinematic_chain.cpp:24
Eigen::Matrix4d Matrix4
make Matrix4 as alias of Eigen::Matrix4d
Definition matrix.h:21
Eigen::MatrixXd MatrixX
make MatrixX as alias of Eigen::MatrixXd
Definition matrix.h:19
Eigen::VectorXd VectorX
make VectorX as alias of Eigen::VectorXd
Definition matrix.h:23
Eigen::Vector3d Vector3
make Vector3 as alias of Eigen::Vector3d
Definition matrix.h:24
static const double GRAVITY
Constant to present value of gravity.
Definition unit.h:28
Robot Arm Library namespace.
Definition artic.cpp:13
A struct variable for joints of robot arm ArmAxisValue storage the output of Inverse kinematic.
Definition kinematic_chain.h:80
std::array< bool, 8 > limit_check
check if over angle limit.
Definition kinematic_chain.h:87
int fit
Use following method to find the fittest solution.
Definition kinematic_chain.h:84
rb::math::MatrixX axis_value
Joints Angle of 8 solutions.
Definition kinematic_chain.h:82
std::array< bool, 8 > singular_check
check if in singular point.
Definition kinematic_chain.h:86
std::array< bool, 8 > solution_check
check if having solution.
Definition kinematic_chain.h:85
A struct variable for Tool Center Point (TCP) ArmPose storages the output of forward kinematic.
Definition kinematic_chain.h:42
double y
left and right
Definition kinematic_chain.h:45
double c
yaw
Definition kinematic_chain.h:50
double z
up and down
Definition kinematic_chain.h:46
double b
pitch
Definition kinematic_chain.h:49
double x
Position of TCP (mm)
Definition kinematic_chain.h:44
double a
Orientation of TCP (degree)
Definition kinematic_chain.h:48