-
Notifications
You must be signed in to change notification settings - Fork 38
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
Variable feasible region task #922
Merged
GiulioRomualdi
merged 21 commits into
ami-iit:master
from
rob-mau:variable_feasible_region_task
Jan 23, 2025
Merged
Changes from all commits
Commits
Show all changes
21 commits
Select commit
Hold shift + click to select a range
0a98afd
added 'VariableLinearTask.h and VariableLinearTask.cpp'
rob-mau 512d78e
changed the task name from VariableLinearTask to SPUTorqueLimitTask
rob-mau 08d4a58
renamed the task from 'SPUTorqueLimitTask' to 'TorqueFeasibleRegionTask'
rob-mau c9e3407
minor changes
rob-mau 1947d55
renamed the task from 'TorqueFeasibleRegionTask' to 'VariableFeasible…
rob-mau 5c2b3f6
made 'VariableFeasibleRegionTask' independent from the size of the co…
rob-mau de18e9d
added bipedal test to the file 'tests/CMakeLists.txt'
rob-mau 5491de8
created the file 'VariableFeasibleRegionTaskTest.cpp'
rob-mau cf73434
added tests for 'VariableFeasibleRegionTask' (all passed).
rob-mau 5094acc
added m_isValid = 'true' in 'setFeasibleRegion()' + minor changes
rob-mau 41f704e
created binding files (.h and .cpp)
rob-mau 69ac8a8
modified 'Module.cpp' and 'CHANGELOG.md'. Formatted with clang.
rob-mau 2e59d9c
formatted the file 'VariableFeasibleRegionTaskTest.cpp'
rob-mau 122092b
added #include in 'Module.cpp'
rob-mau d7f3575
minor changes
rob-mau 3da406a
modified the 'CMakeLists.txt' in 'bindigs/python/TSID'
rob-mau b8820ac
fixed the computation of 'm_S' when 'm_controlledElements.size() == 0'
rob-mau 51c5cd1
added tests in 'test_TSID.py'
rob-mau cc80f58
fixed and extended tests in 'test_TSID.py'
rob-mau 37c3227
added test in 'test_TSID.py'
rob-mau 88b0d8a
Merge branch 'master' into variable_feasible_region_task
GiulioRomualdi File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
26 changes: 26 additions & 0 deletions
26
bindings/python/TSID/include/BipedalLocomotion/bindings/TSID/VariableFeasibleRegionTask.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 VariableFeasibleRegionTask.h | ||
* @authors Roberto Mauceri | ||
* @copyright 2025 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_TSID_VARIABLE_FEASIBLE_REGION_TASK_H | ||
#define BIPEDAL_LOCOMOTION_BINDINGS_TSID_VARIABLE_FEASIBLE_REGION_TASK_H | ||
|
||
#include <pybind11/pybind11.h> | ||
|
||
namespace BipedalLocomotion | ||
{ | ||
namespace bindings | ||
{ | ||
namespace TSID | ||
{ | ||
|
||
void CreateVariableFeasibleRegionTask(pybind11::module& module); | ||
|
||
} // namespace TSID | ||
} // namespace bindings | ||
} // namespace BipedalLocomotion | ||
|
||
#endif // BIPEDAL_LOCOMOTION_BINDINGS_TSID_VARIABLE_FEASIBLE_REGION_TASK_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,37 @@ | ||
/** | ||
* @file VariableFeasibleRegionTask.cpp | ||
* @authors Roberto Mauceri | ||
* @copyright 2025 Istituto Italiano di Tecnologia (IIT). This software may be modified and | ||
* distributed under the terms of the BSD-3-Clause license. | ||
*/ | ||
|
||
#include <pybind11/eigen.h> | ||
#include <pybind11/pybind11.h> | ||
#include <pybind11/stl.h> | ||
|
||
#include <BipedalLocomotion/TSID/TSIDLinearTask.h> | ||
#include <BipedalLocomotion/TSID/VariableFeasibleRegionTask.h> | ||
#include <BipedalLocomotion/bindings/TSID/VariableFeasibleRegionTask.h> | ||
|
||
namespace BipedalLocomotion | ||
{ | ||
namespace bindings | ||
{ | ||
namespace TSID | ||
{ | ||
|
||
void CreateVariableFeasibleRegionTask(pybind11::module& module) | ||
{ | ||
namespace py = ::pybind11; | ||
using namespace ::BipedalLocomotion::TSID; | ||
|
||
py::class_<VariableFeasibleRegionTask, | ||
std::shared_ptr<VariableFeasibleRegionTask>, | ||
TSIDLinearTask>(module, "VariableFeasibleRegionTask") | ||
.def(py::init()) | ||
.def("set_feasible_region", &VariableFeasibleRegionTask::setFeasibleRegion, py::arg("C"), py::arg("l"), py::arg("u")); | ||
} | ||
|
||
} // namespace TSID | ||
} // namespace bindings | ||
} // namespace BipedalLocomotion |
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
102 changes: 102 additions & 0 deletions
102
src/TSID/include/BipedalLocomotion/TSID/VariableFeasibleRegionTask.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,102 @@ | ||
/** | ||
* @file VariableFeasibleRegionTask.h | ||
* @authors Roberto Mauceri | ||
* @copyright 2025 Istituto Italiano di Tecnologia (IIT). This software may be modified and | ||
* distributed under the terms of the BSD-3-Clause license. | ||
*/ | ||
|
||
#ifndef BIPEDAL_LOCOMOTION_TSID_VARIABLE_FEASIBLE_REGION_TASK_H | ||
#define BIPEDAL_LOCOMOTION_TSID_VARIABLE_FEASIBLE_REGION_TASK_H | ||
|
||
#include <BipedalLocomotion/TSID/TSIDLinearTask.h> | ||
|
||
namespace BipedalLocomotion | ||
{ | ||
namespace TSID | ||
{ | ||
/** | ||
* VariableFeasibleRegionTask is a concrete implementation of the Task. Please use this element if | ||
* you want to create a inequality linear constraint on a subset of the optimization variable. The | ||
* task represents the following equation: | ||
* \f[ | ||
* l \ne Cx \ne u | ||
* \f] | ||
* where \f$C\f$ is a generic transformation matrix (m x n), \f$l\f$ is a vector of lower bounds (m | ||
* x 1), \f$u\f$ is a vector of upper bounds (m x 1), and \f$x\f$ are the elements of the variable | ||
* you want to consider (n x 1). \f$m\f$ is the number of constraints and \f$n\f$ is the number of | ||
* variables. | ||
*/ | ||
class VariableFeasibleRegionTask : public TSIDLinearTask | ||
{ | ||
std::string m_variableName; /**< Name of the variable considered in the task. */ | ||
std::vector<std::string> m_controlledElements; /**< Name of the variable elements considered in | ||
the task. */ | ||
bool m_isInitialized{false}; /**< True if the task has been initialized. */ | ||
bool m_isValid{false}; /**< True if the task is valid. */ | ||
std::size_t m_NumberOfVariables{0}; /**< Number of variables. */ | ||
std::size_t m_variableSize{0}; /**< Size of the variable considered in the task. */ | ||
|
||
Eigen::MatrixXd m_S; /**< Selection Matrix. */ | ||
Eigen::MatrixXd m_T; /**< Transformation Matrix. */ | ||
|
||
public: | ||
// clang-format off | ||
/** | ||
* Initialize the planner. | ||
* @param paramHandler pointer to the parameters handler. | ||
* @param variablesHandler reference to a variables handler. | ||
* @note the following parameters are required by the class | ||
* | Parameter Name | Type | Description | Mandatory | | ||
* |:----------------:|:--------:|:--------------------------------------------------------------------------------------:|:---------:| | ||
* | `variable_name` | `string` | Name of the variable that you want to regularize. | Yes | | ||
* | `variable_size` | `int` | Number of the elements that will be regularized. | Yes | | ||
* | `elements_name` | `vector` | Name of the elements to consider. If not specified all the elements are constrained | No | | ||
* @return True in case of success, false otherwise. | ||
*/ | ||
bool initialize(std::weak_ptr<const ParametersHandler::IParametersHandler> paramHandler) override; | ||
// clang-format on | ||
|
||
/** | ||
* Set the set of variables required by the TSIDLinearTask. The variables are stored in the | ||
* System::VariablesHandler. | ||
* @param variablesHandler reference to a variables handler. | ||
* @note The variablesHandler must contain a variable named as the parameter `variable_name`. | ||
* @return True in case of success, false otherwise. | ||
*/ | ||
bool setVariablesHandler(const System::VariablesHandler& variablesHandler) override; | ||
|
||
/** | ||
* Set the region of feasibility for the desired elements of the variable. | ||
* @param C generic linear transformation matrix (m x n) where m is the number of constraints | ||
* and n is the number of variables. | ||
* @param l lower_bounds (m x 1) | ||
* @param u upper_bounds (m x 1) | ||
* @return True in case of success, false otherwise. | ||
*/ | ||
bool setFeasibleRegion(Eigen::Ref<const Eigen::MatrixXd> C, | ||
Eigen::Ref<const Eigen::VectorXd> l, | ||
Eigen::Ref<const Eigen::VectorXd> u); | ||
|
||
/** | ||
* Get the size of the task. (I.e the number of rows of the vector b) | ||
* @return the size of the task. | ||
*/ | ||
std::size_t size() const override; | ||
|
||
/** | ||
* The VariableFeasibleRegionTask is an inequality task. | ||
* @return the type of the task. | ||
*/ | ||
Type type() const override; | ||
|
||
/** | ||
* Determines the validity of the objects retrieved with getA() and getB() | ||
* @return True if the objects are valid, false otherwise. | ||
*/ | ||
bool isValid() const override; | ||
}; | ||
|
||
} // namespace TSID | ||
} // namespace BipedalLocomotion | ||
|
||
#endif // BIPEDAL_LOCOMOTION_TSID_VARIABLE_FEASIBLE_REGION_TASK_H |
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Instead of having m_variableName and m_variableSize you can directly store the variable
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I tried to be consistent with the tasks already implemented, e.g.
VariableRegularizationTask