-
Notifications
You must be signed in to change notification settings - Fork 6
Add interpolation class to simple_mpc #39
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
Merged
Merged
Changes from 8 commits
Commits
Show all changes
9 commits
Select commit
Hold shift + click to select a range
0514b18
First draft of interpolators
edantec 5657e3d
Access to step_nb and step_progress
edantec 82ab105
Expose interpolator
edantec 9b5aa57
Use interpolation in python examples
edantec 3001e81
State and linear interpolators
edantec b8a9607
Working tests
edantec 981473d
interpolate btwn two equal points
edantec 9f413a1
Add include to pinocchio
edantec f05351e
One class for all interpolate methods
edantec 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 hidden or 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 hidden or 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,51 @@ | ||
| /////////////////////////////////////////////////////////////////////////////// | ||
| // BSD 2-Clause License | ||
| // | ||
| // Copyright (C) 2025, INRIA | ||
| // Copyright note valid unless otherwise stated in individual files. | ||
| // All rights reserved. | ||
| /////////////////////////////////////////////////////////////////////////////// | ||
|
|
||
| #include <eigenpy/deprecation-policy.hpp> | ||
| #include <eigenpy/std-vector.hpp> | ||
|
|
||
| #include "simple-mpc/interpolator.hpp" | ||
|
|
||
| namespace simple_mpc | ||
| { | ||
| namespace python | ||
| { | ||
| namespace bp = boost::python; | ||
|
|
||
| Eigen::VectorXd stateInterpolateProxy( | ||
| StateInterpolator & self, const double delay, const double timestep, const std::vector<Eigen::VectorXd> xs) | ||
| { | ||
| Eigen::VectorXd x_interp(xs[0].size()); | ||
| self.interpolate(delay, timestep, xs, x_interp); | ||
|
|
||
| return x_interp; | ||
| } | ||
|
|
||
| Eigen::VectorXd linearInterpolateProxy( | ||
| LinearInterpolator & self, const double delay, const double timestep, const std::vector<Eigen::VectorXd> xs) | ||
| { | ||
| Eigen::VectorXd x_interp(xs[0].size()); | ||
| self.interpolate(delay, timestep, xs, x_interp); | ||
|
|
||
| return x_interp; | ||
| } | ||
|
|
||
| void exposeStateInterpolator() | ||
| { | ||
| bp::class_<StateInterpolator>("StateInterpolator", bp::init<const Model &>(bp::args("self", "model"))) | ||
| .def("interpolate", &stateInterpolateProxy); | ||
| } | ||
|
|
||
| void exposeLinearInterpolator() | ||
| { | ||
| bp::class_<LinearInterpolator>("LinearInterpolator", bp::init<const size_t>(bp::args("self", "vec_size"))) | ||
| .def("interpolate", &linearInterpolateProxy); | ||
| } | ||
|
|
||
| } // namespace python | ||
| } // namespace simple_mpc |
This file contains hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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,58 @@ | ||
| /////////////////////////////////////////////////////////////////////////////// | ||
| // BSD 3-Clause License | ||
| // | ||
| // Copyright (C) 2025, INRIA | ||
| // Copyright note valid unless otherwise stated in individual files. | ||
| // All rights reserved. | ||
| /////////////////////////////////////////////////////////////////////////////// | ||
| /** | ||
| * @file interpolator.hpp | ||
| * @brief Interpolation class for practical control of the robot | ||
| */ | ||
|
|
||
| #ifndef SIMPLE_MPC_INTERPOLATOR_HPP_ | ||
| #define SIMPLE_MPC_INTERPOLATOR_HPP_ | ||
|
|
||
| #include "simple-mpc/fwd.hpp" | ||
| #include "simple-mpc/model-utils.hpp" | ||
|
|
||
| namespace simple_mpc | ||
| { | ||
| class StateInterpolator | ||
| { | ||
| public: | ||
| explicit StateInterpolator(const Model & model); | ||
|
|
||
| void interpolate( | ||
| const double delay, | ||
| const double timestep, | ||
| const std::vector<Eigen::VectorXd> xs, | ||
| Eigen::Ref<Eigen::VectorXd> x_interp); | ||
|
|
||
| // Intermediate differential configuration | ||
| Eigen::VectorXd diff_q_; | ||
|
|
||
| // Pinocchio model | ||
| Model model_; | ||
| }; | ||
|
|
||
| class LinearInterpolator | ||
edantec marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| { | ||
| public: | ||
| explicit LinearInterpolator(const size_t vec_size); | ||
|
|
||
| void interpolate( | ||
| const double delay, | ||
| const double timestep, | ||
| const std::vector<Eigen::VectorXd> vecs, | ||
| Eigen::Ref<Eigen::VectorXd> vec_interp); | ||
|
|
||
| size_t vec_size_; | ||
| }; | ||
| } // namespace simple_mpc | ||
|
|
||
| /* --- Details -------------------------------------------------------------- */ | ||
| /* --- Details -------------------------------------------------------------- */ | ||
| /* --- Details -------------------------------------------------------------- */ | ||
|
|
||
| #endif // SIMPLE_MPC_INTERPOLATOR_HPP_ | ||
This file contains hidden or 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
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.
Uh oh!
There was an error while loading. Please reload this page.