state-observation 1.8.0
General implementation of observers.
Loading...
Searching...
No Matches
ContactsManager.hpp
1#ifndef CONTACTSMANAGERHPP
2#define CONTACTSMANAGERHPP
3#include <set>
4#include <state-observation/tools/measurements-manager/Contact.hpp>
5#include <string>
6#include <type_traits>
7#include <unordered_map>
8
9namespace stateObservation
10{
11namespace measurements
12{
17template<typename ContactT>
19{
20
21protected:
26 template<typename OnAddedContact = std::nullptr_t>
27 ContactT & addContactToManager(const std::string & name, OnAddedContact onAddedContact = nullptr);
28
29public:
40 template<typename OnNewContact,
41 typename OnMaintainedContact,
42 typename OnRemovedContact,
43 typename OnAddedContact = std::nullptr_t>
44 void updateContacts(const std::set<std::string> & latestContactList,
45 OnNewContact onNewContact,
46 OnMaintainedContact onMaintainedContact,
47 OnRemovedContact onRemovedContact,
48 OnAddedContact onAddedContact = nullptr);
49
53 inline std::unordered_map<std::string, ContactT> & contacts()
54 {
55 return listContacts_;
56 }
57
59 inline bool contactsDetected() const noexcept
60 {
61 return contactsDetected_;
62 }
63
69 ContactT * findContact(const std::string & name)
70 {
71 auto it = listContacts_.find(name);
72 if(it != listContacts_.end())
73 {
74 return &(it->second);
75 }
76 return nullptr;
77 }
78
79protected:
80 // map of contacts used by the manager. unordered map containing all the contacts, currently set or not.
81 std::unordered_map<std::string, ContactT> listContacts_;
82
83 // vector containing the name of all the currently set contacts
84 std::set<std::string> currentContactsList_;
85
86 // Index generator, incremented everytime a new contact is created
87 unsigned idx_ = 0;
89 bool contactsDetected_ = false;
90};
91} // namespace measurements
92} // namespace stateObservation
93
94#include <state-observation/tools/measurements-manager/ContactsManager.hxx>
95
96#endif // CONTACTSMANAGERHPP
Filtering of divergent component of motion (DCM) and estimation of a bias betweeen the DCM and the co...
Structure that implements all the necessary functions to manage the map of contacts....
ContactT & addContactToManager(const std::string &name, OnAddedContact onAddedContact=nullptr)
Insert a contact to the map of contacts.
std::unordered_map< std::string, ContactT > & contacts()
Get the map of all the contacts.
ContactT * findContact(const std::string &name)
Accessor for the a contact associated to a surface contained in the map.
void updateContacts(const std::set< std::string > &latestContactList, OnNewContact onNewContact, OnMaintainedContact onMaintainedContact, OnRemovedContact onRemovedContact, OnAddedContact onAddedContact=nullptr)
Updates the list of contacts to inform whether they are newly set, removed, etc., and execute actions...