Cheetah Software  1.0
LegController.h File Reference

Common Leg Control Interface and Leg Control Algorithms. More...

#include <eigen3/Eigen/Dense>
#include "leg_control_command_lcmt.hpp"
#include "leg_control_data_lcmt.hpp"
#include "Dynamics/Quadruped.h"
#include "SimUtilities/SpineBoard.h"
#include "SimUtilities/ti_boardcontrol.h"
#include "cppTypes.h"
+ Include dependency graph for LegController.h:
+ This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Classes

struct  LegControllerCommand< T >
 
struct  LegControllerData< T >
 
class  LegController< T >
 

Functions

template<typename T >
void computeLegJacobianAndPosition (Quadruped< T > &quad, Vec3< T > &q, Mat3< T > *J, Vec3< T > *p, int leg)
 

Detailed Description

Common Leg Control Interface and Leg Control Algorithms.

Implements low-level leg control for Mini Cheetah and Cheetah 3 Robots Abstracts away the difference between the SPIne and the TI Boards All quantities are in the "leg frame" which has the same orientation as the body frame, but is shifted so that 0,0,0 is at the ab/ad pivot (the "hip frame").

Definition in file LegController.h.

Function Documentation

template<typename T >
void computeLegJacobianAndPosition ( Quadruped< T > &  quad,
Vec3< T > &  q,
Mat3< T > *  J,
Vec3< T > *  p,
int  leg 
)

Compute the position of the foot and its Jacobian. This is done in the local leg coordinate system. If J/p are NULL, the calculation will be skipped.

Definition at line 240 of file LegController.cpp.

References Quadruped< T >::_abadLinkLength, Quadruped< T >::_hipLinkLength, Quadruped< T >::_kneeLinkLength, computeLegJacobianAndPosition< double >(), computeLegJacobianAndPosition< float >(), and Quadruped< T >::getSideSign().

241  {
242  T l1 = quad._abadLinkLength;
243  T l2 = quad._hipLinkLength;
244  T l3 = quad._kneeLinkLength;
245  T sideSign = quad.getSideSign(leg);
246 
247  T s1 = std::sin(q(0));
248  T s2 = std::sin(q(1));
249  T s3 = std::sin(q(2));
250 
251  T c1 = std::cos(q(0));
252  T c2 = std::cos(q(1));
253  T c3 = std::cos(q(2));
254 
255  T c23 = c2 * c3 - s2 * s3;
256  T s23 = s2 * c3 + c2 * s3;
257 
258  if (J) {
259  J->operator()(0, 0) = 0;
260  J->operator()(0, 1) = l3 * c23 + l2 * c2;
261  J->operator()(0, 2) = l3 * c23;
262  J->operator()(1, 0) = l3 * c1 * c23 + l2 * c1 * c2 - l1 * sideSign * s1;
263  J->operator()(1, 1) = -l3 * s1 * s23 - l2 * s1 * s2;
264  J->operator()(1, 2) = -l3 * s1 * s23;
265  J->operator()(2, 0) = l3 * s1 * c23 + l2 * c2 * s1 + l1 * sideSign * c1;
266  J->operator()(2, 1) = l3 * c1 * s23 + l2 * c1 * s2;
267  J->operator()(2, 2) = l3 * c1 * s23;
268  }
269 
270  if (p) {
271  p->operator()(0) = l3 * s23 + l2 * s2;
272  p->operator()(1) = l1 * sideSign * c1 + l3 * (s1 * c23) + l2 * c2 * s1;
273  p->operator()(2) = l1 * sideSign * s1 - l3 * (c1 * c23) - l2 * c1 * c2;
274  }
275 }
T _hipLinkLength
Definition: Quadruped.h:62
T _kneeLinkLength
Definition: Quadruped.h:62
static T getSideSign(int leg)
Definition: Quadruped.h:74
T _abadLinkLength
Definition: Quadruped.h:62

+ Here is the call graph for this function:

+ Here is the caller graph for this function: