Drake
contact_results.h
Go to the documentation of this file.
1 #pragma once
2 
3 #include <vector>
4 
8 
9 namespace drake {
10 namespace systems {
11 
12 // Forward declaration
13 template <typename T>
15 
16 /**
17  A class containing the contact results (contact points and response spatial
18  forces for each colliding pair of collision elements) as well as the sum of
19  all JᵀF for all contact, where J is the contact point Jacobian, and F is
20  the contact force.
21 
22  @tparam T The scalar type. It must be a valid Eigen scalar.
23 
24  Instantiated templates for the following ScalarTypes are provided:
25  - double
26  - AutoDiffXd
27  */
28 template <typename T>
30  public:
32 
34 
35  /** Returns the number of unique collision element pairs in contact. */
36  int get_num_contacts() const;
37 
38  /** Retrieves the ith ContactInfo instance. No bounds checking will be done
39  in a release build (but will be done in debug). It is assumed the caller
40  will only use values in the range [0, get_num_contacts() -1], inclusive.
41  */
42  const ContactInfo<T>& get_contact_info(int i) const;
43 
44  // Clears the set of contact information for when the old data becomes
45  // invalid.
46  void Clear();
47 
48  // Reports a contact between two elements and prepares a ContactInfo. The
49  // caller should populate the ContactInfo with the appropriate details.
52 
53  /**
54  * Stores the contact forces as a force in the generalized coordinate.
55  * @param f = J^T * contact_force, where J is the stacked contact Jacobian,
56  * and contact_force is the stacked contact forces.
57  */
59  generalized_contact_force_ = f;
60  }
61 
62  /**
63  * Returns the stored generalized force that represents the contact forces.
64  */
66  return generalized_contact_force_;
67  }
68 
69  private:
70  std::vector<ContactInfo<T>> contacts_;
71  VectorX<T> generalized_contact_force_;
72 };
73 
74 } // namespace systems
75 } // namespace drake
uintptr_t ElementId
Definition: element.h:27
int get_num_contacts() const
Returns the number of unique collision element pairs in contact.
Definition: contact_results.cc:10
int i
Definition: reset_after_move_test.cc:51
A class containing information regarding contact response between two bodies including: ...
Definition: contact_info.h:48
Definition: automotive_demo.cc:90
A class containing the contact results (contact points and response spatial forces for each colliding...
Definition: contact_results.h:29
const ContactInfo< T > & get_contact_info(int i) const
Retrieves the ith ContactInfo instance.
Definition: contact_results.cc:15
Eigen::Matrix< Scalar, Eigen::Dynamic, 1 > VectorX
A column vector of any size, templated on scalar type.
Definition: eigen_types.h:46
ContactResults()
Definition: contact_results.cc:21
#define DRAKE_DEFAULT_COPY_AND_MOVE_AND_ASSIGN(Classname)
DRAKE_DEFAULT_COPY_AND_MOVE_AND_ASSIGN defaults the special member functions for copy-construction, copy-assignment, move-construction, and move-assignment.
Definition: drake_copyable.h:57
void set_generalized_contact_force(const VectorX< T > &f)
Stores the contact forces as a force in the generalized coordinate.
Definition: contact_results.h:58
This class provides a System interface around a multibody dynamics model of the world represented by ...
Definition: contact_results.h:14
void Clear()
Definition: contact_results.cc:24
const VectorX< T > & get_generalized_contact_force() const
Returns the stored generalized force that represents the contact forces.
Definition: contact_results.h:65
ContactInfo< T > & AddContact(drake::multibody::collision::ElementId element_a, drake::multibody::collision::ElementId element_b)
Definition: contact_results.cc:29
Provides careful macros to selectively enable or disable the special member functions for copy-constr...