BipedalLocomotion::Contacts::ContactList class

Class containing a list of contacts.

The contact are added such that the activation time is strictly growing. In addition, contacts cannot be overlapping. It represents a series of contact activations and deactivations of a single entity.

Public types

using const_iterator = std::set<BipedalLocomotion::Contacts::PlannedContact, ContactCompare>::const_iterator
using const_reverse_iterator = std::set<BipedalLocomotion::Contacts::PlannedContact, ContactCompare>::const_reverse_iterator

Public functions

void setDefaultName(const std::string& defaultName)
Set the default name.
auto defaultName() const -> const std::string&
Get the default name.
void setDefaultContactType(const BipedalLocomotion::Contacts::ContactType& type)
Set the default contact type.
void setDefaultIndex(int defaultIndex)
Set the default frame index of the contact.
auto defaultIndex() const -> int
Get the default frame index of the contact.
auto defaultContactType() const -> const BipedalLocomotion::Contacts::ContactType&
Get the default contact type.
auto addContact(const BipedalLocomotion::Contacts::PlannedContact& newContact) -> bool
Add a new contact to the list.
auto addContact(const manif::SE3d& newTransform, const std::chrono::nanoseconds& activationTime, const std::chrono::nanoseconds& deactivationTime) -> bool
Add a new contact to the list.
auto erase(const_iterator iterator) -> const_iterator
Erase a contact.
auto begin() const -> const_iterator
Return a const iterator to the begin of the contacts.
auto cbegin() const -> const_iterator
Return a const iterator to the begin of the contacts.
auto rbegin() const -> const_reverse_iterator
Return a const reverse iterator to the contacts (basically starting from the last contact going backward).
auto crbegin() const -> const_reverse_iterator
Return a const reverse iterator to the contacts (basically starting from the last contact going backward).
auto end() const -> const_iterator
Return a const iterator to the end of the list.
auto cend() const -> const_iterator
Return a const iterator to the end of the list.
auto rend() const -> const_reverse_iterator
Return a const reverse iterator to the end of the list.
auto crend() const -> const_reverse_iterator
Return a const reverse iterator to the end of the list.
auto operator[](size_t index) const -> const BipedalLocomotion::Contacts::PlannedContact&
Access contacts by index.
auto size() const -> size_t
Get the size of the list.
auto firstContact() const -> const_iterator
Iterator pointing to the first contact.
auto lastContact() const -> const_iterator
Iterator pointing to the last contact.
auto editContact(const_iterator element, const BipedalLocomotion::Contacts::PlannedContact& newContact) -> bool
Edit an existing contact.
auto getActiveContact(const std::chrono::nanoseconds& time) const -> const_iterator
Get the active contact given the time.
auto getNextContact(const std::chrono::nanoseconds& time) const -> const_iterator
Get the next contact given the time.
auto getPresentContact(const std::chrono::nanoseconds& time) const -> const_iterator
Get the contact given the time.
auto keepOnlyPresentContact(const std::chrono::nanoseconds& time) -> bool
Clear all the steps, except the one returned by getPresentContact.
void clear()
Clear the contacts.
void removeLastContact()
Remove only the last contact.
auto toString() const -> std::string
Convert the contact list to a string.
auto forceSampleTime(const std::chrono::nanoseconds& dt) -> bool
Force the sample time of the contact list.
auto areContactsSampled(const std::chrono::nanoseconds& dt) const -> bool
Check if the contacts are sampled with the given sample time.

Function documentation

void BipedalLocomotion::Contacts::ContactList::setDefaultName(const std::string& defaultName)

Set the default name.

Parameters
defaultName the default name.

const std::string& BipedalLocomotion::Contacts::ContactList::defaultName() const

Get the default name.

Returns the default name.

void BipedalLocomotion::Contacts::ContactList::setDefaultIndex(int defaultIndex)

Set the default frame index of the contact.

Parameters
defaultIndex the default index.

int BipedalLocomotion::Contacts::ContactList::defaultIndex() const

Get the default frame index of the contact.

Returns the default index.

const BipedalLocomotion::Contacts::ContactType& BipedalLocomotion::Contacts::ContactList::defaultContactType() const

Get the default contact type.

Returns the default contact type.

bool BipedalLocomotion::Contacts::ContactList::addContact(const BipedalLocomotion::Contacts::PlannedContact& newContact)

Add a new contact to the list.

Parameters
newContact The new contact
Returns false if it was not possible to insert the contact. Possible failures: the activation time is greater than the deactivation time, or the new contact overlaps with an existing contact.

bool BipedalLocomotion::Contacts::ContactList::addContact(const manif::SE3d& newTransform, const std::chrono::nanoseconds& activationTime, const std::chrono::nanoseconds& deactivationTime)

Add a new contact to the list.

Parameters
newTransform The contact pose.
activationTime The activation time.
deactivationTime The deactivation time.
Returns false if it was not possible to insert the contact. Possible failures: the activation time is greater than the deactivation time, or the new contact overlaps with an existing contact.

It uses the defaultName and the defaultContactType for the missing informations.

const_iterator BipedalLocomotion::Contacts::ContactList::erase(const_iterator iterator)

Erase a contact.

Parameters
iterator to the contact to erase.
Returns an iterator to the contact that follows the one removed.

const_iterator BipedalLocomotion::Contacts::ContactList::end() const

Return a const iterator to the end of the list.

This is only a placeholder, it does not reference any contact.

const_iterator BipedalLocomotion::Contacts::ContactList::cend() const

Return a const iterator to the end of the list.

This is only a placeholder, it does not reference any contact.

const_reverse_iterator BipedalLocomotion::Contacts::ContactList::rend() const

Return a const reverse iterator to the end of the list.

This is only a placeholder, it does not reference any contact.

const_reverse_iterator BipedalLocomotion::Contacts::ContactList::crend() const

Return a const reverse iterator to the end of the list.

This is only a placeholder, it does not reference any contact.

const BipedalLocomotion::Contacts::PlannedContact& BipedalLocomotion::Contacts::ContactList::operator[](size_t index) const

Access contacts by index.

Parameters
index of the phase to be accessed.
Returns A const reference to the desired contact.

size_t BipedalLocomotion::Contacts::ContactList::size() const

Get the size of the list.

Returns The number of contacts.

bool BipedalLocomotion::Contacts::ContactList::editContact(const_iterator element, const BipedalLocomotion::Contacts::PlannedContact& newContact)

Edit an existing contact.

Parameters
element Iterator to the element to edit.
newContact The new contact
Returns false if the element is not valid or if the new contact timing would require a reordering of the list.

const_iterator BipedalLocomotion::Contacts::ContactList::getActiveContact(const std::chrono::nanoseconds& time) const

Get the active contact given the time.

Parameters
time The present time.
Returns an iterator to the last contact having an activation time lower than time. If no contact satisfies this condition, it returns a pointer to the end.

It returns the active contact (i.e., the highest activation time lower than time and the deactivation time strictly higher than time). If no contacts are active at the given time, it returns an iterator to the end.

const_iterator BipedalLocomotion::Contacts::ContactList::getNextContact(const std::chrono::nanoseconds& time) const

Get the next contact given the time.

Parameters
time The present time.
Returns an iterator to the first contact having an activation time higher than time. If no contact satisfies this condition, it returns a pointer to the end.

It returns the contact with the lowest activation time higher than time. If no contacts have an activation time higher than time, it returns an iterator to the end.

const_iterator BipedalLocomotion::Contacts::ContactList::getPresentContact(const std::chrono::nanoseconds& time) const

Get the contact given the time.

Parameters
time The present time.
Returns an iterator to the last contact having an activation time lower than time. If no contact satisfies this condition, it returns a pointer to the end.

It returns the contact with the highest activation time lower than time. If no contacts have an activation time lower than time, it returns an iterator to the end. Notice that the contact may not be active, i.e. the deactivationTime may be lower than time.

bool BipedalLocomotion::Contacts::ContactList::keepOnlyPresentContact(const std::chrono::nanoseconds& time)

Clear all the steps, except the one returned by getPresentContact.

Parameters
time The present time.
Returns false if no contact is available at this time.

std::string BipedalLocomotion::Contacts::ContactList::toString() const

Convert the contact list to a string.

Returns A string containing the information of the contact list.

bool BipedalLocomotion::Contacts::ContactList::forceSampleTime(const std::chrono::nanoseconds& dt)

Force the sample time of the contact list.

Parameters
dt The new sample time.
Returns true if the contact list has been correctly resampled.

bool BipedalLocomotion::Contacts::ContactList::areContactsSampled(const std::chrono::nanoseconds& dt) const

Check if the contacts are sampled with the given sample time.

Parameters
dt The sample time.
Returns true if the contacts are sampled with the given sample time.