mirror of
https://github.com/wpilibsuite/allwpilib
synced 2026-06-25 01:41:43 +00:00
[copybara] Resync robotpy (#8585)
Project import generated by Copybara.
GitOrigin-RevId: fd000778e9b78c72cc7ca7b2ebe476129b78c6e0
This commit is contained in:
@@ -1,7 +1,7 @@
|
||||
[build-system]
|
||||
build-backend = "hatchling.build"
|
||||
requires = [
|
||||
"semiwrap~=0.2.1",
|
||||
"semiwrap~=0.2.6",
|
||||
"hatch-meson~=0.1.0",
|
||||
"hatch-robotpy~=0.2.1",
|
||||
"hatchling",
|
||||
@@ -69,8 +69,6 @@ scan_headers_ignore = [
|
||||
"wpi/math/random/Normal.hpp",
|
||||
|
||||
"wpi/math/system/Discretization.hpp",
|
||||
"wpi/math/system/NumericalIntegration.hpp",
|
||||
"wpi/math/system/NumericalJacobian.hpp",
|
||||
|
||||
"wpi/math/proto/*",
|
||||
"wpi/math/*/proto/*",
|
||||
@@ -1566,8 +1564,8 @@ LinearSystem = "wpi/math/system/LinearSystem.hpp"
|
||||
LinearSystemLoop = "wpi/math/system/LinearSystemLoop.hpp"
|
||||
# LinearSystemUtil = "wpi/math/system/LinearSystemUtil.hpp"
|
||||
Models = "wpi/math/system/Models.hpp"
|
||||
# NumericalIntegration = "wpi/math/system/NumericalIntegration.hpp"
|
||||
# NumericalJacobian = "wpi/math/system/NumericalJacobian.hpp"
|
||||
NumericalIntegration = "wpi/math/system/NumericalIntegration.hpp"
|
||||
NumericalJacobian = "wpi/math/system/NumericalJacobian.hpp"
|
||||
|
||||
# wpi/math/trajectory
|
||||
ExponentialProfile = "wpi/math/trajectory/ExponentialProfile.hpp"
|
||||
|
||||
@@ -25,9 +25,31 @@ classes:
|
||||
CalculateX:
|
||||
CalculateY:
|
||||
Slice:
|
||||
# TODO?
|
||||
ignore: true
|
||||
|
||||
template_inline_code: |
|
||||
cls_LinearSystem.def("slice", [](wpi::math::LinearSystem<States, Inputs, Outputs> &self, int idx0) {
|
||||
return self.Slice(idx0);
|
||||
}, py::arg("outputIndex"),
|
||||
py::doc("Returns the LinearSystem with the outputs listed in outputIndices.")
|
||||
);
|
||||
|
||||
if constexpr (Outputs > 1) {
|
||||
cls_LinearSystem.def("slice", [](wpi::math::LinearSystem<States, Inputs, Outputs> &self, int idx0, int idx1) {
|
||||
return self.Slice(idx0, idx1);
|
||||
}, py::arg("outputIndex0"), py::arg("outputIndex1"),
|
||||
py::doc("Returns the LinearSystem with the outputs listed in outputIndices.")
|
||||
);
|
||||
}
|
||||
if constexpr (Outputs > 2) {
|
||||
cls_LinearSystem.def("slice", [](wpi::math::LinearSystem<States, Inputs, Outputs> &self, int idx0, int idx1, int idx2) {
|
||||
return self.Slice(idx0, idx1, idx2);
|
||||
}, py::arg("outputIndex0"), py::arg("outputIndex1"), py::arg("outputIndex2"),
|
||||
py::doc("Returns the LinearSystem with the outputs listed in outputIndices.")
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
templates:
|
||||
LinearSystem_1_1_1:
|
||||
qualname: wpi::math::LinearSystem
|
||||
|
||||
25
wpimath/src/main/python/semiwrap/NumericalIntegration.yml
Normal file
25
wpimath/src/main/python/semiwrap/NumericalIntegration.yml
Normal file
@@ -0,0 +1,25 @@
|
||||
extra_includes:
|
||||
- frc_eigen.h
|
||||
- wpi/math/linalg/EigenCore.hpp
|
||||
- pybind11/functional.h
|
||||
|
||||
functions:
|
||||
RK4:
|
||||
overloads:
|
||||
F&&, T, wpi::units::second_t:
|
||||
template_impls:
|
||||
- [std::function<Eigen::MatrixXd(Eigen::MatrixXd)>, Eigen::MatrixXd]
|
||||
F&&, T, U, wpi::units::second_t:
|
||||
template_impls:
|
||||
- ["std::function<Eigen::MatrixXd(Eigen::MatrixXd, Eigen::MatrixXd)>", Eigen::MatrixXd, Eigen::MatrixXd]
|
||||
F&&, wpi::units::second_t, T, wpi::units::second_t:
|
||||
template_impls:
|
||||
- ["std::function<Eigen::MatrixXd(wpi::units::second_t, Eigen::MatrixXd)>", Eigen::MatrixXd]
|
||||
RKDP:
|
||||
overloads:
|
||||
F&&, T, U, wpi::units::second_t, double:
|
||||
template_impls:
|
||||
- ["std::function<Eigen::MatrixXd(Eigen::MatrixXd, Eigen::MatrixXd)>", Eigen::MatrixXd, Eigen::MatrixXd]
|
||||
F&&, wpi::units::second_t, T, wpi::units::second_t, double:
|
||||
template_impls:
|
||||
- ["std::function<Eigen::MatrixXd(wpi::units::second_t, Eigen::MatrixXd)>", Eigen::MatrixXd]
|
||||
52
wpimath/src/main/python/semiwrap/NumericalJacobian.yml
Normal file
52
wpimath/src/main/python/semiwrap/NumericalJacobian.yml
Normal file
@@ -0,0 +1,52 @@
|
||||
extra_includes:
|
||||
- frc_eigen.h
|
||||
- wpi/math/linalg/EigenCore.hpp
|
||||
- pybind11/functional.h
|
||||
- pybind11/typing.h
|
||||
|
||||
functions:
|
||||
NumericalJacobian:
|
||||
overloads:
|
||||
F&&, const Vectord<Cols>&:
|
||||
ignore: true
|
||||
F&&, const Eigen::VectorXd&:
|
||||
template_impls:
|
||||
- [std::function<Eigen::VectorXd(Eigen::VectorXd)>]
|
||||
NumericalJacobianX:
|
||||
overloads:
|
||||
F&&, const Vectord<States>&, const Vectord<Inputs>&, Args&&...:
|
||||
ignore: true
|
||||
F&&, const Eigen::VectorXd&, const Eigen::VectorXd&, Args&&...:
|
||||
# template_impls:
|
||||
# - ["std::function<Eigen::VectorXd(Eigen::VectorXd, Eigen::VectorXd, py::args)>", py::args, Eigen::MatrixXd]
|
||||
param_override:
|
||||
args:
|
||||
ignore: true
|
||||
no_release_gil: true
|
||||
cpp_code: |
|
||||
[](py::typing::Callable<Eigen::VectorXd(Eigen::VectorXd, Eigen::VectorXd, py::args)> fn,
|
||||
const Eigen::VectorXd& x, const Eigen::VectorXd& u, py::args args) {
|
||||
return wpi::math::NumericalJacobianX([=](const Eigen::VectorXd &ix, const Eigen::VectorXd &iu) {
|
||||
py::object r = fn(ix, iu, *args);
|
||||
return r.cast<Eigen::VectorXd>();
|
||||
}, x, u);
|
||||
}
|
||||
NumericalJacobianU:
|
||||
overloads:
|
||||
F&&, const Vectord<States>&, const Vectord<Inputs>&, Args&&...:
|
||||
ignore: true
|
||||
F&&, const Eigen::VectorXd&, const Eigen::VectorXd&, Args&&...:
|
||||
# template_impls:
|
||||
# - ["std::function<Eigen::VectorXd(Eigen::VectorXd, Eigen::VectorXd, py::args)>", py::args, Eigen::MatrixXd]
|
||||
param_override:
|
||||
args:
|
||||
ignore: true
|
||||
no_release_gil: true
|
||||
cpp_code: |-
|
||||
[](py::typing::Callable<Eigen::VectorXd(Eigen::VectorXd, Eigen::VectorXd, py::args)> fn,
|
||||
const Eigen::VectorXd& x, const Eigen::VectorXd& u, py::args args) {
|
||||
return wpi::math::NumericalJacobianU([=](const Eigen::VectorXd &ix, const Eigen::VectorXd &iu) {
|
||||
py::object r = fn(ix, iu, *args);
|
||||
return r.cast<Eigen::VectorXd>();
|
||||
}, x, u);
|
||||
}
|
||||
@@ -51,9 +51,7 @@ for f in sorted(pathlib.Path(sys.argv[1]).glob("*.h")):
|
||||
ofp.write("\nnamespace pybind11 { namespace detail {\n")
|
||||
|
||||
for single, double in names:
|
||||
ofp.write(
|
||||
inspect.cleandoc(
|
||||
f"""
|
||||
ofp.write(inspect.cleandoc(f"""
|
||||
|
||||
template <> struct handle_type_name<units::{single}_t> {{
|
||||
static constexpr auto name = _("{double}");
|
||||
@@ -63,9 +61,7 @@ for f in sorted(pathlib.Path(sys.argv[1]).glob("*.h")):
|
||||
static constexpr auto name = _("{double}");
|
||||
}};
|
||||
|
||||
"""
|
||||
)
|
||||
)
|
||||
"""))
|
||||
ofp.write("\n\n")
|
||||
|
||||
ofp.write("\n}\n}\n\n")
|
||||
|
||||
@@ -101,6 +101,8 @@ from ._wpimath import (
|
||||
ProfiledPIDControllerRadians,
|
||||
Quaternion,
|
||||
QuinticHermiteSpline,
|
||||
RK4,
|
||||
RKDP,
|
||||
Rectangle2d,
|
||||
RectangularRegionConstraint,
|
||||
Rotation2d,
|
||||
@@ -184,6 +186,9 @@ from ._wpimath import (
|
||||
angleModulus,
|
||||
applyDeadband,
|
||||
inputModulus,
|
||||
numericalJacobian,
|
||||
numericalJacobianU,
|
||||
numericalJacobianX,
|
||||
objectToRobotPose,
|
||||
slewRateLimit,
|
||||
)
|
||||
@@ -288,6 +293,8 @@ __all__ = [
|
||||
"ProfiledPIDControllerRadians",
|
||||
"Quaternion",
|
||||
"QuinticHermiteSpline",
|
||||
"RK4",
|
||||
"RKDP",
|
||||
"Rectangle2d",
|
||||
"RectangularRegionConstraint",
|
||||
"Rotation2d",
|
||||
@@ -371,6 +378,9 @@ __all__ = [
|
||||
"angleModulus",
|
||||
"applyDeadband",
|
||||
"inputModulus",
|
||||
"numericalJacobian",
|
||||
"numericalJacobianU",
|
||||
"numericalJacobianX",
|
||||
"objectToRobotPose",
|
||||
"slewRateLimit",
|
||||
]
|
||||
|
||||
Reference in New Issue
Block a user