Ravelin
SphericalJoint.h
1 /****************************************************************************
2  * Copyright 2014 Evan Drumwright
3  * This library is distributed under the terms of the Apache V2.0 License
4  ****************************************************************************/
5 
6 #ifndef SPHERICALJOINT
7 #error This class is not to be included by the user directly. Use SphericalJointd.h or SphericalJointf.h instead.
8 #endif
9 
11 class SPHERICALJOINT : public virtual JOINT
12 {
13  public:
14  enum Axis { eAxis1, eAxis2, eAxis3 };
16  virtual void update_spatial_axes();
17  virtual void determine_q(VECTORN& q);
18  virtual boost::shared_ptr<const POSE3> get_induced_pose();
19  virtual const std::vector<SVELOCITY>& get_spatial_axes();
20  virtual const std::vector<SVELOCITY>& get_spatial_axes_dot();
21  virtual unsigned num_dof() const { return 3; }
22  virtual void evaluate_constraints(REAL C[]);
23  VECTOR3 get_axis(Axis a) const;
24  void set_axis(const VECTOR3& axis, Axis a);
25  virtual void calc_constraint_jacobian(bool inboard, MATRIXN& Cq);
26  virtual void calc_constraint_jacobian_dot(bool inboard, MATRIXN& Cq);
27 
29  virtual bool is_singular_config() const { return std::fabs(std::sin(q[DOF_1])) < SINGULAR_TOL && std::fabs(std::cos(q[DOF_2])) < SINGULAR_TOL; }
30 
32 
38 
39 
40  protected:
41  bool assign_axes();
42  static bool rel_equal(REAL x, REAL y);
43  MATRIX3 get_rotation() const;
44 
46  VECTOR3 _u[3];
47 
49  std::vector<SVELOCITY> _s_dot;
50 
51  void setup_joint();
52 
53 }; // end class
54 
Defines a joint for purely rotational motion.
Definition: SphericalJoint.h:11
MATRIX3 get_rotation() const
Gets the (local) rotation induced by this joint.
Definition: SphericalJoint.cpp:298
VECTOR3 get_axis(Axis a) const
Gets the global axis for this joint.
Definition: SphericalJoint.cpp:48
virtual bool is_singular_config() const
Spherical joint is singular if sin(q1) = 0 and cos(q2) = 0.
Definition: SphericalJoint.h:29
SPHERICALJOINT()
Initializes the joint.
Definition: SphericalJoint.cpp:11
virtual void determine_q(VECTORN &q)
Determines (and sets) the value of Q from the axes and the inboard link and outboard link transforms...
Definition: SphericalJoint.cpp:292
virtual void update_spatial_axes()
Updates the spatial axis for this joint.
Definition: SphericalJoint.cpp:99
A generic, possibly non-square matrix.
Definition: MatrixN.h:18
REAL SINGULAR_TOL
The tolerance to which a joint configuration is considered singular.
Definition: SphericalJoint.h:37
virtual void calc_constraint_jacobian(bool inboard, MATRIXN &Cq)
Computes the constraint jacobian with respect to a body.
Definition: SphericalJoint.cpp:349
std::vector< SVELOCITY > _s_dot
The derivative of the spatial axis.
Definition: SphericalJoint.h:49
VECTORN q
The position of this joint.
Definition: Joint.h:144
virtual boost::shared_ptr< const POSE3 > get_induced_pose()
Gets the (local) transform for this joint.
Definition: SphericalJoint.cpp:319
virtual void calc_constraint_jacobian_dot(bool inboard, MATRIXN &Cq)
Computes the time derivative of the constraint jacobian with respect to a body.
Definition: SphericalJoint.cpp:413
A generic N-dimensional floating point vector.
Definition: VectorN.h:16
A three-dimensional floating point vector used for representing points and vectors in 3D with associa...
Definition: Vector3.h:15
VECTOR3 _u[3]
The local joint axes.
Definition: SphericalJoint.h:46
Defines a bilateral constraint (a joint)
Definition: Joint.h:14
virtual const std::vector< SVELOCITY > & get_spatial_axes()
Gets the spatial axes for this joint.
Definition: SphericalJoint.cpp:204
bool assign_axes()
Attempts to compute unassigned axes.
Definition: SphericalJoint.cpp:131
virtual const std::vector< SVELOCITY > & get_spatial_axes_dot()
Gets the derivative of the spatial-axis.
Definition: SphericalJoint.cpp:243
virtual void evaluate_constraints(REAL C[])
Evaluates the constraint equations.
Definition: SphericalJoint.cpp:327
virtual unsigned num_dof() const
Gets the number of degrees-of-freedom for this joint.
Definition: SphericalJoint.h:21
static bool rel_equal(REAL x, REAL y)
Determines whether two values are relatively equal.
Definition: SphericalJoint.cpp:36
A 3x3 matrix that may be used for orientation, inertia tensors, etc.
Definition: Matrix3.h:20
void set_axis(const VECTOR3 &axis, Axis a)
Sets the local axis of rotation for this joint (MUST BE CALLED AFTER set_location(.))
Definition: SphericalJoint.cpp:90