3#include "../navtypes.h"
4#include "ForwardArmKinematics.h"
19template <
unsigned int N>
29 PlanarArmFK(
const navtypes::Vectord<N>& segLens,
const navtypes::Vectord<N>& jointMin,
30 const navtypes::Vectord<N>& jointMax)
31 : segLens(segLens), jointMin(jointMin), jointMax(jointMax) {}
38 for (
unsigned int i = 0; i < N; i++) {
39 if (jointPos[i] < jointMin[i] || jointPos[i] > jointMax[i]) {
46 navtypes::Matrixd<2, N>
getJacobian(
const navtypes::Vectord<N>& jointPos)
const override {
49 thetaCumSum[0] = jointPos[0];
50 for (
unsigned int i = 1; i < N; i++) {
51 thetaCumSum[i] = jointPos[i] + thetaCumSum[i - 1];
53 for (
unsigned int i = 0; i < N; i++) {
54 for (
unsigned int j = i; j < N; j++) {
55 jacobian(0, i) += -segLens[j] *
std::sin(thetaCumSum[j]);
56 jacobian(1, i) += segLens[j] *
std::cos(thetaCumSum[j]);
62 Eigen::Vector2d
jointPosToEEPos(
const navtypes::Vectord<N>& jointPos)
const override {
63 Eigen::Vector2d eePos = Eigen::Vector2d::Zero();
64 double accumAngle = 0;
65 for (
unsigned int i = 0; i < N; i++) {
66 accumAngle += jointPos[i];
68 eePos += segLens[i] * segVec;
74 navtypes::Vectord<N> segLens;
75 navtypes::Vectord<N> jointMin;
76 navtypes::Vectord<N> jointMax;
complex< _Tp > sin(const complex< _Tp > &)
complex< _Tp > cos(const complex< _Tp > &)
static const ConstantReturnType Zero()
A class that calculates the forward kinematics of an arm.
Definition ForwardArmKinematics.h:16
Eigen::Vector2d jointPosToEEPos(const navtypes::Vectord< N > &jointPos) const override
Given a joint position, calculate the current EE position.
Definition PlanarArmFK.h:62
navtypes::Vectord< N > getSegLens() const override
Get the segment lengths for this arm.
Definition PlanarArmFK.h:33
PlanarArmFK(const navtypes::Vectord< N > &segLens, const navtypes::Vectord< N > &jointMin, const navtypes::Vectord< N > &jointMax)
Construct a new kinematics object.
Definition PlanarArmFK.h:29
navtypes::Matrixd< 2, N > getJacobian(const navtypes::Vectord< N > &jointPos) const override
Get the jacobian matrix for the arm at the given joint angles.
Definition PlanarArmFK.h:46
bool satisfiesConstraints(const navtypes::Vectord< N > &jointPos) const override
Check if the given joint configuration is valid.
Definition PlanarArmFK.h:37