Resurgence (PY2022)
Codebase for the Husky Robotics 2021-2022 rover Resurgence
Toggle main menu visibility
Loading...
Searching...
No Matches
src
kinematics
InverseArmKinematics.h
1
#pragma once
2
3
#include "../navtypes.h"
4
#include "ForwardArmKinematics.h"
5
6
#include <
memory
>
7
8
#include <Eigen/Core>
9
10
namespace
kinematics {
11
18
template
<
unsigned
int
D,
unsigned
int
N>
19
class
InverseArmKinematics
{
20
public
:
26
InverseArmKinematics
(
std::shared_ptr
<
const
ForwardArmKinematics<D, N>
> fk) : fk(fk) {}
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
72
protected
:
73
const
std::shared_ptr<const ForwardArmKinematics<D, N>
> fk;
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
memory
std::shared_ptr
kinematics::ForwardArmKinematics
A class that calculates the forward kinematics of an arm.
Definition
ForwardArmKinematics.h:16
kinematics::InverseArmKinematics
A class that calculates the inverse kinematics of an arm.
Definition
InverseArmKinematics.h:19
kinematics::InverseArmKinematics::solve
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.
kinematics::InverseArmKinematics::eePosToJointPos
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
kinematics::InverseArmKinematics::eePosToJointPos
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
kinematics::InverseArmKinematics::InverseArmKinematics
InverseArmKinematics(std::shared_ptr< const ForwardArmKinematics< D, N > > fk)
Construct an IK object.
Definition
InverseArmKinematics.h:26
Generated by
1.17.0