Resurgence (PY2022)
Codebase for the Husky Robotics 2021-2022 rover Resurgence
Loading...
Searching...
No Matches
InverseArmKinematics.h
1#pragma once
2
3#include "../navtypes.h"
4#include "ForwardArmKinematics.h"
5
6#include <memory>
7
8#include <Eigen/Core>
9
10namespace kinematics {
11
18template <unsigned int D, unsigned int N>
20public:
27
28 virtual ~InverseArmKinematics() = default;
29
40 navtypes::Vectord<N> eePosToJointPos(const navtypes::Vectord<D>& eePos,
41 const navtypes::Vectord<N>& currJointPos) const {
42 bool success;
43 return eePosToJointPos(eePos, currJointPos, success);
44 }
45
57 virtual navtypes::Vectord<N> eePosToJointPos(const navtypes::Vectord<D>& eePos,
58 const navtypes::Vectord<N>& jointAngles,
59 bool& success) const {
60 double armLen = fk->getSegLens().sum();
61 if (eePos.norm() >= armLen) {
62 success = false;
63 return jointAngles;
64 }
65 navtypes::Vectord<N> sol = solve(eePos, jointAngles, success);
66 if (success) {
67 success = fk->satisfiesConstraints(sol);
68 }
69 return success ? sol : jointAngles;
70 }
71
72protected:
74
89 virtual navtypes::Vectord<N> solve(const navtypes::Vectord<D>& eePos,
90 const navtypes::Vectord<N>& jointAngles,
91 bool& success) const = 0;
92};
93
94} // namespace kinematics
A class that calculates the forward kinematics of an arm.
Definition ForwardArmKinematics.h:16
A class that calculates the inverse kinematics of an arm.
Definition InverseArmKinematics.h:19
virtual navtypes::Vectord< N > solve(const navtypes::Vectord< D > &eePos, const navtypes::Vectord< N > &jointAngles, bool &success) const =0
Solve for the joint angles that yield the given EE position.
virtual navtypes::Vectord< N > eePosToJointPos(const navtypes::Vectord< D > &eePos, const navtypes::Vectord< N > &jointAngles, bool &success) const
Solve for the joint angles that yield the given EE position.
Definition InverseArmKinematics.h:57
navtypes::Vectord< N > eePosToJointPos(const navtypes::Vectord< D > &eePos, const navtypes::Vectord< N > &currJointPos) const
Calculate the joint angles that yield the desired EE position.
Definition InverseArmKinematics.h:40
InverseArmKinematics(std::shared_ptr< const ForwardArmKinematics< D, N > > fk)
Construct an IK object.
Definition InverseArmKinematics.h:26