-
Notifications
You must be signed in to change notification settings - Fork 38
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #624 from ami-iit/contact_detector
Restructure ContactDetector machinery
- Loading branch information
Showing
25 changed files
with
940 additions
and
664 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
26 changes: 26 additions & 0 deletions
26
bindings/python/Math/include/BipedalLocomotion/bindings/Math/SchmittTrigger.h
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
/** | ||
* @file SchmittTrigger.h | ||
* @authors Giulio Romualdi | ||
* @copyright 2023 Istituto Italiano di Tecnologia (IIT). This software may be modified and | ||
* distributed under the terms of the BSD-3-Clause license. | ||
*/ | ||
|
||
#ifndef BIPEDAL_LOCOMOTION_BINDINGS_MATH_SCHMITT_TRIGGER_H | ||
#define BIPEDAL_LOCOMOTION_BINDINGS_MATH_SCHMITT_TRIGGER_H | ||
|
||
#include <pybind11/pybind11.h> | ||
|
||
namespace BipedalLocomotion | ||
{ | ||
namespace bindings | ||
{ | ||
namespace Math | ||
{ | ||
|
||
void CreateSchmittTrigger(pybind11::module& module); | ||
|
||
} // namespace Math | ||
} // namespace bindings | ||
} // namespace BipedalLocomotion | ||
|
||
#endif // BIPEDAL_LOCOMOTION_BINDINGS_MATH_SCHMITT_TRIGGER_H |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,92 @@ | ||
/** | ||
* @file SchmittTrigger.cpp | ||
* @authors Giulio Romualdi | ||
* @copyright 2023 Istituto Italiano di Tecnologia (IIT). This software may be modified and | ||
* distributed under the terms of the BSD-3-Clause license. | ||
*/ | ||
|
||
#include <pybind11/pybind11.h> | ||
|
||
#include <BipedalLocomotion/Math/SchmittTrigger.h> | ||
#include <BipedalLocomotion/System/Advanceable.h> | ||
#include <BipedalLocomotion/bindings/Math/SchmittTrigger.h> | ||
#include <BipedalLocomotion/bindings/System/Advanceable.h> | ||
|
||
namespace BipedalLocomotion | ||
{ | ||
namespace bindings | ||
{ | ||
namespace Math | ||
{ | ||
|
||
void CreateSchmittTrigger(pybind11::module& module) | ||
{ | ||
using namespace BipedalLocomotion::Math; | ||
namespace py = ::pybind11; | ||
|
||
py::class_<SchmittTriggerState>(module, "SchmittTriggerState") | ||
.def(py::init([](bool state, double switchTime, double edgeTime) -> SchmittTriggerState { | ||
return SchmittTriggerState{std::move(state), | ||
std::move(switchTime), | ||
std::move(edgeTime)}; | ||
}), | ||
py::arg("state") = false, | ||
py::arg("switch_time") = 0.0, | ||
py::arg("edge_time") = 0.0) | ||
.def_readwrite("state", &SchmittTriggerState::state) | ||
.def_readwrite("switch_time", &SchmittTriggerState::switchTime) | ||
.def_readwrite("edge_time", &SchmittTriggerState::edgeTime); | ||
|
||
py::class_<SchmittTriggerInput>(module, "SchmittTriggerInput") | ||
.def(py::init([](double time, double rawValue) -> SchmittTriggerInput { | ||
return SchmittTriggerInput{std::move(time), std::move(rawValue)}; | ||
}), | ||
py::arg("time") = 0.0, | ||
py::arg("raw_value") = 0.0) | ||
.def_readwrite("time", &SchmittTriggerInput::time) | ||
.def_readwrite("raw_value", &SchmittTriggerInput::rawValue); | ||
|
||
BipedalLocomotion::bindings::System::CreateAdvanceable< | ||
BipedalLocomotion::Math::SchmittTriggerInput, | ||
BipedalLocomotion::Math::SchmittTriggerState>(module, "SchmittTrigger"); | ||
|
||
py::class_<SchmittTrigger, | ||
::BipedalLocomotion::System::Advanceable<SchmittTriggerInput, // | ||
SchmittTriggerState>> | ||
schmittTrigger(module, "SchmittTrigger"); | ||
|
||
py::class_<SchmittTrigger::Params>(schmittTrigger, "Params") | ||
.def(py::init([](double onThreshold, | ||
double offThreshold, | ||
double switchOnAfter, | ||
double switchOffAfter, | ||
double timeComparisonThreshold) -> SchmittTrigger::Params { | ||
SchmittTrigger::Params params; | ||
params.onThreshold = std::move(onThreshold); | ||
params.offThreshold = std::move(offThreshold); | ||
params.switchOnAfter = std::move(switchOnAfter); | ||
params.switchOffAfter = std::move(switchOffAfter); | ||
params.timeComparisonThreshold = std::move(timeComparisonThreshold); | ||
return params; | ||
}), | ||
py::arg("on_threshold") = 0.0, | ||
py::arg("off_threshold") = 0.0, | ||
py::arg("switch_on_after") = 0.0, | ||
py::arg("switch_off_after") = 0.0, | ||
py::arg("time_comparison_threshold") = std::numeric_limits<double>::epsilon()) | ||
.def_readwrite("on_threshold", &SchmittTrigger::Params::onThreshold) | ||
.def_readwrite("off_threshold", &SchmittTrigger::Params::offThreshold) | ||
.def_readwrite("switch_on_after", &SchmittTrigger::Params::switchOnAfter) | ||
.def_readwrite("switch_off_after", &SchmittTrigger::Params::switchOffAfter) | ||
.def_readwrite("time_comparison_threshold", | ||
&SchmittTrigger::Params::timeComparisonThreshold); | ||
|
||
schmittTrigger.def(py::init()) | ||
.def("set_state", &SchmittTrigger::setState, py::arg("state")) | ||
.def("initialize", | ||
py::overload_cast<const SchmittTrigger::Params&>(&SchmittTrigger::initialize), | ||
py::arg("parameters")); | ||
} | ||
} // namespace Math | ||
} // namespace bindings | ||
} // namespace BipedalLocomotion |
Oops, something went wrong.