1 #ifndef SimTK_SIMBODY_CONTACT_TRACKER_SUBSYSTEM_H_
2 #define SimTK_SIMBODY_CONTACT_TRACKER_SUBSYSTEM_H_
34 class MultibodySystem;
38 class ContactSnapshot;
156 int getNumSurfaces()
const;
186 bool& reverseOrder)
const;
225 bool realizeActiveContacts(
const State& state,
227 Real& stepAdvice)
const;
232 bool realizePredictedContacts(
const State& state,
234 Real& stepAdvice)
const;
240 class ContactTrackerSubsystemImpl& updImpl();
241 const ContactTrackerSubsystemImpl& getImpl()
const;
261 typedef std::map<ContactId,int> ContactMap;
264 typedef std::map<std::pair<ContactSurfaceIndex,ContactSurfaceIndex>,
274 m_id2contact.clear();
275 m_surfPair2id.clear();
292 assert(
id.isValid() && surf1.isValid() && surf2.isValid());
295 if (surf1 > surf2) std::swap(surf1,surf2);
297 assert(!hasContact(
id));
298 assert(!hasContact(surf1,surf2));
300 const int indx = m_contacts.size();
301 m_contacts.push_back(contact);
302 m_id2contact[id] = indx;
303 m_surfPair2id[std::make_pair(surf1,surf2)] = id;
308 {
return m_id2contact.find(
id) != m_id2contact.end(); }
312 {
if (surf1 > surf2) std::swap(surf1,surf2);
313 return m_surfPair2id.find(std::make_pair(surf1,surf2))
314 != m_surfPair2id.end(); }
328 ContactMap::const_iterator p = m_id2contact.find(
id);
329 return p==m_id2contact.end() ? empty : m_contacts[p->second]; }
335 {
if (surf1 > surf2) std::swap(surf1,surf2);
336 SurfaceMap::const_iterator p =
337 m_surfPair2id.find(std::make_pair(surf1,surf2));
338 return p==m_surfPair2id.end() ?
ContactId() : p->second; }
346 void removeContact(
int n) {
347 assert(0 <= n && n < m_contacts.size());
348 if (n+1 == m_contacts.size()) {
349 m_contacts.pop_back();
353 m_contacts[n] = m_contacts.back();
354 m_contacts.pop_back();
355 m_id2contact[m_contacts[n].getContactId()] = n;
360 Array_<Contact,int> m_contacts;
361 ContactMap m_id2contact;
362 SurfaceMap m_surfPair2id;
375 #endif // SimTK_SIMBODY_CONTACT_TRACKER_SUBSYSTEM_H_
The abstract parent of all Subsystems.
Definition: Subsystem.h:61
Every Simbody header and source file should include this header before any other Simbody header...
This is the handle class for the hidden State implementation.
Definition: State.h:264
const Real NaN
This is the IEEE "not a number" constant for this implementation of the default-precision Real type; ...
The job of the MultibodySystem class is to coordinate the activities of various subsystems which can ...
Definition: MultibodySystem.h:48
std::ostream & operator<<(std::ostream &o, const ContactForce &f)
Definition: CompliantContactSubsystem.h:387
#define SimTK_SIMBODY_EXPORT
Definition: Simbody/include/simbody/internal/common.h:72
A MobilizedBody is Simbody's fundamental body-and-joint object used to parameterize a system's motion...
Definition: MobilizedBody.h:167