-
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
Implement FeasibleContactWrenchTask for TSID component #369
Merged
Merged
Changes from 4 commits
Commits
Show all changes
7 commits
Select commit
Hold shift + click to select a range
cf7c50d
Require a const ParametersHandler in LinearizedFrictionCone and Conta…
GiulioRomualdi e2cb91d
Implement FeasibleContactWrenchTask for TSID component
GiulioRomualdi fc63fc7
Implement FeasibleContactWrench task test
GiulioRomualdi 5bff02e
Update the CHANGELOG
GiulioRomualdi cdd7472
Fix typos in FeasibleContactWrenchTask
GiulioRomualdi a2f89df
Implement FeasibleContactWrenchTask::setContactActive()
GiulioRomualdi 7ffb525
Update the FeasibleContactWrenchTask
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
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
132 changes: 132 additions & 0 deletions
132
src/TSID/include/BipedalLocomotion/TSID/FeasibleContactWrenchTask.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,132 @@ | ||
/** | ||
* @file FeasibleContactWrenchTask.h | ||
* @authors Giulio Romualdi | ||
* @copyright 2021 Istituto Italiano di Tecnologia (IIT). This software may be modified and | ||
* distributed under the terms of the GNU Lesser General Public License v2.1 or any later version. | ||
*/ | ||
|
||
#ifndef BIPEDAL_LOCOMOTION_TSID_FEASIBLE_CONTACT_WRENCH_TASK_H | ||
#define BIPEDAL_LOCOMOTION_TSID_FEASIBLE_CONTACT_WRENCH_TASK_H | ||
|
||
#include <memory> | ||
|
||
#include <manif/manif.h> | ||
|
||
#include <BipedalLocomotion/TSID/TSIDLinearTask.h> | ||
#include <BipedalLocomotion/Math/ContactWrenchCone.h> | ||
|
||
|
||
#include <iDynTree/KinDynComputations.h> | ||
|
||
|
||
namespace BipedalLocomotion | ||
{ | ||
namespace TSID | ||
{ | ||
|
||
/** | ||
* FeasibleContactWrenchTask is a concrete implementation of the TSIDLinearTask. Please use this | ||
* element if you want to ensure that the contact wrench satisfies the constraints implemented in | ||
* BipedalLocomotion::Math::ContactWrenchCone. Differently from the | ||
* BipedalLocomotion::Math::ContactWrenchCone class, FeasibleContactWrenchTask requires also the | ||
* positivstellensatz of the normal force written in local coordinate. | ||
* @note FeasibleContactWrenchTask::disable will force the wrench associated to the task to be equal | ||
* to a null wrench. FeasibleContactWrenchTask::enable will allow the wrench to be different from | ||
* zero. | ||
*/ | ||
class FeasibleContactWrenchTask : public TSIDLinearTask | ||
{ | ||
struct ContactWrench | ||
{ | ||
iDynTree::FrameIndex frameIndex; /**< Frame used to express the contact wrench */ | ||
System::VariablesHandler::VariableDescription variable; /**< Variable describing the contact | ||
wrench */ | ||
Eigen::Matrix3d frame_R_inertial; | ||
}; | ||
|
||
ContactWrench m_contactWrench; | ||
|
||
BipedalLocomotion::Math::ContactWrenchCone m_cone; | ||
|
||
bool m_isInitialized{false}; /**< True if the task has been initialized. */ | ||
bool m_isValid{false}; /**< True if the task is valid. */ | ||
|
||
Eigen::MatrixXd m_AinBodyCoordinate; /**< Matrix A written in body frame */ | ||
|
||
std::shared_ptr<iDynTree::KinDynComputations> m_kinDyn; /**< Pointer to a KinDynComputations | ||
object */ | ||
public: | ||
|
||
/** | ||
* Initialize the task. | ||
* @param handler pointer to the parameter handler. | ||
* @note The following parameters are required: | ||
* | Parameter Name | Type | Description | Mandatory | | ||
* |:-----------------------------:|:----------------:|:-----------------------------------------------------------------------------:|:---------:| | ||
* | `frame_name` | `string` | Name of the frame associated to the contact | Yes | | ||
* | `variable_name` | `string` | Name of the variable contained in `VariablesHandler` describing the contact | Yes | | ||
* | `number_of_slices` | `int` | Number of slices used to split 90 deg. | Yes | | ||
* | `static_friction_coefficient` | `double` | Static friction coefficient. | Yes | | ||
* | `foot_limits_x` | `vector<double>` | x coordinate of the foot limits w.r.t the frame attached to the surface | Yes | | ||
* | `foot_limits_y` | `vector<double>` | y coordinate of the foot limits w.r.t the frame attached to the surface | Yes | | ||
* @return true in case of success/false otherwise. | ||
*/ | ||
bool initialize(std::weak_ptr<const ParametersHandler::IParametersHandler> paramHandler); | ||
|
||
/** | ||
* Set the kinDynComputations object. | ||
* @param kinDyn pointer to a kinDynComputations object. | ||
* @return True in case of success, false otherwise. | ||
*/ | ||
bool setKinDyn(std::shared_ptr<iDynTree::KinDynComputations> kinDyn); | ||
|
||
/** | ||
* Set the set of variables required by the task. The variables are stored in the | ||
* System::VariablesHandler. | ||
* @param variablesHandler reference to a variables handler. | ||
* @note The handler must contain a variable named as the parameter | ||
* `variable_name` stored in the parameter handler. The variable represents the contact wrench | ||
* acting of the robot. | ||
* @return True in case of success, false otherwise. | ||
*/ | ||
bool setVariablesHandler(const System::VariablesHandler& variablesHandler) override; | ||
|
||
/** | ||
* Update the content of the element. | ||
* @return True in case of success, false otherwise. | ||
*/ | ||
bool update() override; | ||
|
||
/** | ||
* Enable the task. I.e. a contact wrench different from zero is allowed. | ||
*/ | ||
void enable(); | ||
|
||
/** | ||
* Disable the task. I.e. the contact wrench is forced to be equal to zero. | ||
*/ | ||
void disable(); | ||
|
||
/** | ||
* 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 CoMTask is an equality task. | ||
* @return the size 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_FEASIBLE_CONTACT_WRENCH_TASK_H |
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.
There is some potential confusion on whether it is the task to be disabled (hence the wrench is not constrained), or if the wrench cannot be used to control the robot. A possibility could be to allow setting directly the maximum normal component. Another possibility could be to have a method like
setContactState
with an enum. Otherwise also a different naming could do the trick, although I did not find any good alternatives myself.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 like
setContactState
! the enum could beActive
Inactive
, what do you think?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.
In theory the enum could be defined in https://github.com/dic-iit/bipedal-locomotion-framework/blob/d81b390683127a451669b0e09ff06da199f9490a/src/Contacts/include/BipedalLocomotion/Contacts/Contact.h#L19
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.
That would be nice. On the other hand, we should try to be coherent and use that enum also inside the class. Right now it is a boolean https://github.com/dic-iit/bipedal-locomotion-framework/blob/d81b390683127a451669b0e09ff06da199f9490a/src/Contacts/include/BipedalLocomotion/Contacts/Contact.h#L102
and only in the
EstimatedContact
.For the time being, we could simply add the boolean and start using it in separate PRs.
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.
In 9b8662b I implemented the function we discussed.