26 T.push_back(Eigen::Matrix4d::Identity());
27 Eigen::Matrix4d* rot =
new Eigen::Matrix4d();
28 *rot = Eigen::Matrix4d::Identity();
29 Eigen::Matrix4d* trans =
new Eigen::Matrix4d();
30 *trans = Eigen::Matrix4d::Identity();
41 prevT = (*trans) * (*rot);
54 double x = -
k / std::tan(alpha);
56 return std::make_pair(x, y);
60 return (std::fabs(value) < 0.000001) ? 0 : value;
67 radius = std::sqrt(ICC.first * ICC.first + ICC.second * ICC.second);
76 Eigen::Matrix4d* rot =
new Eigen::Matrix4d();
77 *rot = Eigen::Matrix4d::Identity();
98 std::pair<double, double> ICC)
100 Eigen::Matrix4d* trans =
new Eigen::Matrix4d();
101 *trans = Eigen::Matrix4d::Identity();
112 double theta =
calcTheta(distance, radius);
117 x = radius * std::cos(theta + alpha) + ICC.first;
118 y = radius * std::sin(theta + alpha) + ICC.second;
123 x = radius * std::cos(
PI - theta + alpha) + ICC.first;
124 y = radius * std::sin(
PI - theta + alpha) + ICC.second;
137 Eigen::Matrix4d* Ti =
new Eigen::Matrix4d();
138 *Ti = Eigen::Matrix4d::Identity();
143 Ti =
calcTrans(0, distance, alpha, std::make_pair(0, 0));
147 std::pair<double, double> ICC =
calcICC(alpha);
149 double theta =
calcTheta(distance, radius);
152 Eigen::Matrix4d* trans =
calcTrans(radius, distance, alpha, ICC);
153 *Ti = (*trans) * (*Ti);
160 Eigen::Matrix4d Tn =
prevT * (*Ti);
167 double e_x1 = Tn(0, 0);
168 double e_x2 = Tn(1, 0);
172 double angle = std::atan2(e_x2, e_x1);
Header file for the ForwardKinematics class.
Eigen::Matrix4d * calcRot(double theta, double alpha)
Calculate the current rotation matrix.
Eigen::Matrix4d * calcTrans(double radius, double distance, double alpha, std::pair< double, double > ICC)
Calculate the current translation matrix.
double flattenZeros(double value)
Rounds values close to zero to exactly zero.
ForwardKinematics()
ForwardKinematics default constructor.
double radToDeg(double angle)
Conversion from radiants to degrees.
double calcTheta(double distance, double radius)
Calculate the current orientation of the robot with respect to the coordinate system of the previous ...
std::pair< double, double > calcICC(double alpha)
Calculates the current instantaneous center of curvature given a steering angle.
std::vector< double > & getUpdate(double alpha, double distance)
Get the current position and orientation.
std::vector< Eigen::Matrix4d > T
double calcRadius(std::pair< double, double > ICC)
Calculate the radius of the current robot tracjectory around the instantaneous center of curvature (I...
void init()
Initialize simulation.
const double getRadius() const
Get the radius of the current robot tracjectory around the instantaneous center of curvature (ICC)...
The ForwardKinematics class simulates kinematic behavoir of a car like mobile platform given its curr...
std::vector< double > currentPosition
double degToRad(double angle)
Conversion from degrees to radiants.