Moby
ScrewJoint.h
1 /****************************************************************************
2  * Copyright 2013 Evan Drumwright
3  * This library is distributed under the terms of the Apache V2.0
4  * License (obtainable from http://www.apache.org/licenses/LICENSE-2.0).
5  ****************************************************************************/
6 
7 #ifndef _SCREW_JOINT_H
8 #define _SCREW_JOINT_H
9 
10 #include <Moby/Joint.h>
11 
12 namespace Moby {
13 
15 class ScrewJoint : public Joint
16 {
17  public:
18  ScrewJoint();
19  virtual ~ScrewJoint() {}
20  ScrewJoint(boost::weak_ptr<RigidBody> inboard, boost::weak_ptr<RigidBody> outboard);
21  const Ravelin::Vector3d& get_axis() const { return _u; }
22  void set_axis(const Ravelin::Vector3d& axis);
23  virtual void update_spatial_axes();
24  virtual void determine_q(VectorN& q);
25  virtual boost::shared_ptr<const Ravelin::Pose3d>& get_induced_pose();
26  virtual const std::vector<Ravelin::SVelocityd>& get_spatial_axes_dot();
27  virtual void load_from_xml(boost::shared_ptr<const XMLTree> node, std::map<std::string, BasePtr>& id_map);
28  virtual void save_to_xml(XMLTreePtr node, std::list<boost::shared_ptr<const Base> >& shared_objects) const;
29  virtual unsigned num_dof() const { return 1; }
30  virtual void evaluate_constraints(double C[]);
31 
33  double get_pitch() const { return _pitch; }
34 
36  virtual bool is_sngular_config() const { return false; }
37 
39  void set_pitch(double pitch) { _pitch = pitch; update_spatial_axes(); }
40 
41  private:
42  virtual void calc_constraint_jacobian(RigidBodyPtr body, unsigned index, double Cq[7]);
43  virtual void calc_constraint_jacobian_dot(RigidBodyPtr body, unsigned index, double Cq[7]);
44 
46  double _pitch;
47 
49  Ravelin::Vector3d _u;
50 
52  Ravelin::Vector3d _ui, _uj;
53 
55  std::vector<Ravelin::SVelocityd> _s_dot;
56 
58  Ravelin::Vector3d _v2;
59 }; // end class
60 } // end namespace
61 
62 #endif
63 
double get_pitch() const
Gets the pitch of the joint.
Definition: ScrewJoint.h:33
void set_pitch(double pitch)
Sets the pitch of the joint.
Definition: ScrewJoint.h:39
virtual const std::vector< Ravelin::SVelocityd > & get_spatial_axes_dot()
Gets the derivative for the spatial axes for this joint.
Definition: ScrewJoint.cpp:176
virtual void save_to_xml(XMLTreePtr node, std::list< boost::shared_ptr< const Base > > &shared_objects) const
Implements Base::save_to_xml()
Definition: ScrewJoint.cpp:210
virtual void load_from_xml(boost::shared_ptr< const XMLTree > node, std::map< std::string, BasePtr > &id_map)
Implements Base::load_from_xml()
Definition: ScrewJoint.cpp:182
virtual boost::shared_ptr< const Ravelin::Pose3d > & get_induced_pose()
Gets the (local) transform for this joint.
Definition: ScrewJoint.cpp:162
void set_axis(const Ravelin::Vector3d &axis)
Sets the global axis for this joint.
Definition: ScrewJoint.cpp:65
boost::shared_ptr< RigidBody > RigidBodyPtr
Rigid body smart pointer.
Definition: Types.h:62
boost::shared_ptr< XMLTree > XMLTreePtr
XML tree smart pointer.
Definition: Types.h:104
virtual void evaluate_constraints(double C[])
Evaluates the constraint equations.
Definition: ScrewJoint.cpp:463
Defines a joint used in articulated rigid body dynamics simulation.
Definition: Joint.h:30
virtual bool is_sngular_config() const
Screw joint can never be in a singular configuration.
Definition: ScrewJoint.h:36
Defines an actuated screw (helical) joint.
Definition: ScrewJoint.h:15
virtual void update_spatial_axes()
Updates the spatial axis for this joint.
Definition: ScrewJoint.cpp:90
virtual void determine_q(VectorN &q)
Determines (and sets) the value of Q from the axis and the inboard link and outboard link transforms...
Definition: ScrewJoint.cpp:127
ScrewJoint()
Initializes the joint.
Definition: ScrewJoint.cpp:21