IMP  2.2.1
The Integrative Modeling Platform
CompositeJoint.h
Go to the documentation of this file.
1 /**
2  * \file IMP/kinematics/CompositeJoint.h
3  * \brief a joint composed of several joints, applied on the same
4  * pair of rigid bodies
5  * \authors Dina Schneidman, Barak Raveh
6  *
7 
8  * Copyright 2007-2014 IMP Inventors. All rights reserved.
9  */
10 
11 #ifndef IMPKINEMATICS_COMPOSITE_JOINT_H
12 #define IMPKINEMATICS_COMPOSITE_JOINT_H
13 
14 #include "kinematics_config.h"
16 #include <IMP/kinematics/Joint.h>
17 #include <IMP/base/Object.h>
18 //#include <IMP/compatibility/nullptr.h>
19 #include <IMP/base/exception.h>
20 #include <IMP/core/internal/dihedral_helpers.h>
21 #include <IMP/algebra/Vector3D.h>
22 #include <IMP/base/check_macros.h>
23 
24 IMPKINEMATICS_BEGIN_NAMESPACE
25 
26 class KinematicForest;
27 
28 /********************** CompositeJoint ***************/
29 
30 /**
31  A joint that combines several inner joints, acting on the same
32  pair of rigid bodies
33 */
34 class IMPKINEMATICSEXPORT CompositeJoint : public Joint {
35  public:
36  /**
37  Constructs a composite joint between parent and child,
38  with the specified list of inner joints connecting them.
39 
40  @param parent rigid body upstream of this joint
41  @param child rigid body downstream of this joint
42  @param[in] joints The list of inner joints connecting the two
43  rigid bodies. These will be applied by their
44  specified order in the list, from the parent
45  rigid body to the child rigid body. It is
46  assumed all these joints share the same
47  parent and child as the composite joint.
48  */
50  Joints joints = Joints());
51 
52  /**
53  adds a joint at the end of the list of joints (closest to the child
54  rigid body)
55  @note the joint must have the same parent and child as the composite
56  joint
57  */
59  IMP_ALWAYS_CHECK(j->get_parent_node() == this->get_parent_node() &&
60  j->get_child_node() == this->get_child_node(),
61  "inner joint within a composite joint must have"
62  "the same parent and child rigid body nodes",
63  ValueException);
64  joints_.push_back(j);
65  }
66 
67  /**
68  adds a joint at the front of the list of joints (closest to the parent
69  rigid body)
70  @note the joint must have the same parent and child as the composite
71  joint
72  */
74  IMP_ALWAYS_CHECK(j->get_parent_node() == this->get_parent_node() &&
75  j->get_child_node() == this->get_child_node(),
76  "inner joint within a composite joint must have"
77  << "the same parent and child rigid body nodes",
78  ValueException);
79  joints_.insert(joints_.begin(), j);
80  }
81 
82  /**
83  Sets the list of inner joints instead of the existing one,
84 
85  @param joints the new joints, ordered from the parent rigid body
86  downstream to the child rigid body.
87 
88  @note All joints must have the same parent and child as the composite
89  joint
90  @note This invalidates all existing inner joints if any, detaching
91  them from their current KinematicForest owner if it exists.
92  */
93  void set_joints(Joints joints);
94 
95  /**
96  returns the list of inner joints, ordered from the parent
97  rigid body downstream to the child rigid body
98  */
99  const Joints& get_inner_joints() const { return joints_; }
100 
101 #ifndef SWIG
102  /**
103  returns the list of inner joints, ordered from the parent
104  rigid body downstream to the child rigid body
105  */
106  Joints& get_inner_joints() { return joints_; }
107 #endif
108 
109  protected:
110  /**
111  update the child node reference frame by applying all the
112  inner joints
113  */
114  virtual void update_child_node_reference_frame() const;
115 
116  /**
117  Updates all inner joints value, and the overall transformation
118  resulting from their combinations, based on the external coordinates
119  of the witnesses to each of the inner joints.
120 
121  @note It is assumed that external coordinates are updated before
122  calling this function.
123  */
124 
126 
127  private:
128  Joints joints_; // list of inner joints
129 };
130 
132 
133 IMPKINEMATICS_END_NAMESPACE
134 
135 #endif /* IMPKINEMATICS_COMPOSITE_JOINT_H */
virtual void update_joint_from_cartesian_witnesses()
functionality for defining a kinematic joint between rigid bodies as part of a kinematic tree ...
functionality for defining nodes on a kinematic chain
const Joints & get_inner_joints() const
IMP::base::Vector< IMP::base::Pointer< Joint > > Joints
Definition: Joint.h:130
virtual void update_child_node_reference_frame() const
#define IMP_OBJECTS(Name, PluralName)
Define the types for storing sets of objects.
Exception definitions and assertions.
Simple 3D vector class.
Exception definitions and assertions.
A shared base class to help in debugging and things.
A decorator for a rigid body.
Definition: rigid_bodies.h:75
#define IMP_ALWAYS_CHECK(condition, message, exception_name)
Throw an exception if a check fails.