Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Implement inequality operator for the PlannedContact class #750

Merged
merged 2 commits into from
Nov 6, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ All notable changes to this project are documented in this file.
- Implement `GlobalCoPEvaluator` in `Contacts` component (https://github.com/ami-iit/bipedal-locomotion-framework/pull/745)
- Implement `Wrench::getLocalCoP()` method (https://github.com/ami-iit/bipedal-locomotion-framework/pull/745)
- Add tests for classes of `RobotDynamicsEstimator` library (https://github.com/ami-iit/bipedal-locomotion-framework/pull/743)
- Implement inequality operator for the `PlannedContact` class (https://github.com/ami-iit/bipedal-locomotion-framework/pull/750)

### Changed
- Remove the possibility to disable the telemetry in `System::AdvanceableRunner` (https://github.com/ami-iit/bipedal-locomotion-framework/pull/726)
Expand Down
1 change: 1 addition & 0 deletions bindings/python/Contacts/src/Contacts.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,7 @@ void CreateContact(pybind11::module& module)
.def_readwrite("deactivation_time", &PlannedContact::deactivationTime)
.def("__repr__", &toString)
.def("__eq__", &PlannedContact::operator==, py::is_operator())
.def("__neq__", &PlannedContact::operator!=, py::is_operator())
.def("is_contact_active", &PlannedContact::isContactActive);

py::class_<EstimatedContact, ContactBase>(module, "EstimatedContact")
Expand Down
8 changes: 8 additions & 0 deletions src/Contacts/include/BipedalLocomotion/Contacts/Contact.h
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,14 @@ struct PlannedContact : ContactBase
*/
bool operator==(const PlannedContact& other) const;

/**
* @brief The inequality operator.
*
* @param other The other object used for the comparison.
* @return True if the contacts are the different, false otherwise.
*/
bool operator!=(const PlannedContact& other) const;

/**
* @brief Check if the contact is active at a give time instant
*
Expand Down
8 changes: 6 additions & 2 deletions src/Contacts/src/Contact.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,7 @@ using namespace BipedalLocomotion::Contacts;

bool PlannedContact::operator==(const PlannedContact& other) const
{
bool eq = true;
eq = eq && this->activationTime == other.activationTime;
bool eq = this->activationTime == other.activationTime;
eq = eq && this->name == other.name;
eq = eq && this->type == other.type;
eq = eq && this->pose.coeffs() == other.pose.coeffs();
Expand All @@ -23,6 +22,11 @@ bool PlannedContact::operator==(const PlannedContact& other) const
return eq;
}

bool PlannedContact::operator!=(const PlannedContact& other) const
{
return !this->operator==(other);
}

bool PlannedContact::isContactActive(const std::chrono::nanoseconds& t) const
{
return (this->activationTime <= t) && (t < this->deactivationTime);
Expand Down
Loading