Moby
Gears.h
1 /****************************************************************************
2  * Copyright 2015 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 _GEARS_H
8 #define _GEARS_H
9 
10 #include <boost/weak_ptr.hpp>
11 #include <boost/shared_ptr.hpp>
12 #include <Ravelin/Pose3d.h>
13 #include <Ravelin/MatrixNd.h>
14 #include <Ravelin/SAcceld.h>
15 #include <Ravelin/LinAlgd.h>
16 #include <Ravelin/DynamicBodyd.h>
17 #include <Moby/Base.h>
18 #include <Moby/RigidBody.h>
19 #include <Moby/Visualizable.h>
20 #include <Moby/Joint.h>
21 
22 namespace Moby {
23 
24 class VisualizationData;
25 
27 
30 class Gears : public Joint
31 {
32  public:
33 
34  Gears();
35  virtual ~Gears() {}
36  virtual void save_to_xml(XMLTreePtr node, std::list<boost::shared_ptr<const Base> >& shared_objects) const;
37  virtual void load_from_xml(boost::shared_ptr<const XMLTree> node, std::map<std::string, BasePtr>& id_map);
38  virtual void set_inboard_pose(boost::shared_ptr<const Ravelin::Pose3d> link, bool update_joint_pose);
39  virtual void set_outboard_pose(boost::shared_ptr<const Ravelin::Pose3d> link, bool update_joint_pose);
40  virtual void evaluate_constraints(double C[]);
41  virtual void evaluate_constraints_dot(double C[]);
42  virtual void calc_constraint_jacobian(bool inboard, Ravelin::MatrixNd& Cq);
43  virtual void calc_constraint_jacobian_dot(bool inboard, Ravelin::MatrixNd& Cq);
44  virtual unsigned num_dof() const { return 0; }
45  virtual unsigned num_constraint_eqns() const { return 1; }
46  virtual void determine_q(Ravelin::VectorNd& q) {}
47  virtual boost::shared_ptr<const Ravelin::Pose3d> get_induced_pose() { return boost::shared_ptr<const Ravelin::Pose3d>(); }
48  virtual bool is_singular_config() const { return false; }
49  virtual const std::vector<Ravelin::SVelocityd>& get_spatial_axes_dot() { return _sdot; }
50 
51  private:
52  double _ratio; // the input:output ratio for the gears
53 
54  std::vector<Ravelin::SVelocityd> _sdot; // this will be unused
55 }; // end class
56 } // end namespace
57 
58 #endif
59 
virtual void calc_constraint_jacobian(bool inboard, Ravelin::MatrixNd &Cq)
Computes the constraint Jacobian.
Definition: Gears.cpp:64
virtual void load_from_xml(boost::shared_ptr< const XMLTree > node, std::map< std::string, BasePtr > &id_map)
Implements Base::load_from_xml()
Definition: Gears.cpp:107
virtual void set_inboard_pose(boost::shared_ptr< const Ravelin::Pose3d > link, bool update_joint_pose)
Sets the inboard pose.
Definition: Gears.cpp:48
virtual void calc_constraint_jacobian_dot(bool inboard, Ravelin::MatrixNd &Cq)
Computes the time derivative of the constraint Jacobian.
Definition: Gears.cpp:100
virtual void evaluate_constraints(double C[])
Evaluates the joint constraint.
Definition: Gears.cpp:34
virtual void evaluate_constraints_dot(double C[])
Evaluates the time derivative of the constraint.
Definition: Gears.cpp:41
boost::shared_ptr< XMLTree > XMLTreePtr
XML tree smart pointer.
Definition: Types.h:104
virtual void save_to_xml(XMLTreePtr node, std::list< boost::shared_ptr< const Base > > &shared_objects) const
Implements Base::save_to_xml()
Definition: Gears.cpp:122
Defines a gear ("joint") constraint.
Definition: Gears.h:30
Defines a joint used in articulated rigid body dynamics simulation.
Definition: Joint.h:30
Gears()
Initializes the joint.
Definition: Gears.cpp:27
virtual void set_outboard_pose(boost::shared_ptr< const Ravelin::Pose3d > link, bool update_joint_pose)
Sets the outboard pose.
Definition: Gears.cpp:56