mirror of
https://github.com/wpilibsuite/allwpilib
synced 2026-06-22 01:11:42 +00:00
[wpimath] Reorganize LinearSystem factories (#8468)
This commit is contained in:
@@ -16,7 +16,6 @@
|
||||
#include "wpi/math/geometry/Rotation2d.hpp"
|
||||
#include "wpi/math/kinematics/DifferentialDriveKinematics.hpp"
|
||||
#include "wpi/math/trajectory/TrajectoryGenerator.hpp"
|
||||
#include "wpi/math/util/StateSpaceUtil.hpp"
|
||||
#include "wpi/units/angle.hpp"
|
||||
#include "wpi/units/length.hpp"
|
||||
#include "wpi/units/time.hpp"
|
||||
|
||||
@@ -17,7 +17,6 @@
|
||||
#include "wpi/math/geometry/Rotation2d.hpp"
|
||||
#include "wpi/math/kinematics/DifferentialDriveKinematics.hpp"
|
||||
#include "wpi/math/trajectory/TrajectoryGenerator.hpp"
|
||||
#include "wpi/math/util/StateSpaceUtil.hpp"
|
||||
#include "wpi/units/angle.hpp"
|
||||
#include "wpi/units/length.hpp"
|
||||
#include "wpi/units/time.hpp"
|
||||
|
||||
@@ -12,8 +12,8 @@
|
||||
|
||||
#include "wpi/math/linalg/EigenCore.hpp"
|
||||
#include "wpi/math/random/Normal.hpp"
|
||||
#include "wpi/math/system/DCMotor.hpp"
|
||||
#include "wpi/math/system/NumericalJacobian.hpp"
|
||||
#include "wpi/math/system/plant/DCMotor.hpp"
|
||||
#include "wpi/math/trajectory/TrajectoryGenerator.hpp"
|
||||
#include "wpi/units/moment_of_inertia.hpp"
|
||||
|
||||
|
||||
@@ -10,14 +10,14 @@
|
||||
#include <Eigen/Core>
|
||||
#include <gtest/gtest.h>
|
||||
|
||||
#include "wpi/math/system/plant/DCMotor.hpp"
|
||||
#include "wpi/math/system/plant/LinearSystemId.hpp"
|
||||
#include "wpi/math/system/DCMotor.hpp"
|
||||
#include "wpi/math/system/Models.hpp"
|
||||
#include "wpi/units/moment_of_inertia.hpp"
|
||||
#include "wpi/units/time.hpp"
|
||||
|
||||
TEST(KalmanFilterTest, Flywheel) {
|
||||
auto motor = wpi::math::DCMotor::NEO();
|
||||
auto flywheel =
|
||||
wpi::math::LinearSystemId::FlywheelSystem(motor, 1_kg_sq_m, 1.0);
|
||||
wpi::math::Models::FlywheelFromPhysicalConstants(motor, 1_kg_sq_m, 1.0);
|
||||
wpi::math::KalmanFilter<1, 1, 1> kf{flywheel, {1}, {1}, 5_ms};
|
||||
}
|
||||
|
||||
@@ -15,11 +15,11 @@
|
||||
#include "wpi/math/estimator/AngleStatistics.hpp"
|
||||
#include "wpi/math/linalg/EigenCore.hpp"
|
||||
#include "wpi/math/random/Normal.hpp"
|
||||
#include "wpi/math/system/DCMotor.hpp"
|
||||
#include "wpi/math/system/Discretization.hpp"
|
||||
#include "wpi/math/system/Models.hpp"
|
||||
#include "wpi/math/system/NumericalIntegration.hpp"
|
||||
#include "wpi/math/system/NumericalJacobian.hpp"
|
||||
#include "wpi/math/system/plant/DCMotor.hpp"
|
||||
#include "wpi/math/system/plant/LinearSystemId.hpp"
|
||||
#include "wpi/math/trajectory/TrajectoryGenerator.hpp"
|
||||
#include "wpi/units/moment_of_inertia.hpp"
|
||||
|
||||
@@ -183,9 +183,8 @@ TEST(MerweUKFTest, DriveConvergence) {
|
||||
|
||||
TEST(MerweUKFTest, LinearUKF) {
|
||||
constexpr wpi::units::second_t dt = 20_ms;
|
||||
auto plant =
|
||||
wpi::math::LinearSystemId::IdentifyVelocitySystem<wpi::units::meters>(
|
||||
0.02_V / 1_mps, 0.006_V / 1_mps_sq);
|
||||
auto plant = wpi::math::Models::FlywheelFromSysId(0.02_V / 1_rad_per_s,
|
||||
0.006_V / 1_rad_per_s_sq);
|
||||
wpi::math::MerweUKF<1, 1, 1> observer{
|
||||
[&](const wpi::math::Vectord<1>& x, const wpi::math::Vectord<1>& u) {
|
||||
return plant.A() * x + plant.B() * u;
|
||||
|
||||
@@ -15,11 +15,11 @@
|
||||
#include "wpi/math/estimator/AngleStatistics.hpp"
|
||||
#include "wpi/math/linalg/EigenCore.hpp"
|
||||
#include "wpi/math/random/Normal.hpp"
|
||||
#include "wpi/math/system/DCMotor.hpp"
|
||||
#include "wpi/math/system/Discretization.hpp"
|
||||
#include "wpi/math/system/Models.hpp"
|
||||
#include "wpi/math/system/NumericalIntegration.hpp"
|
||||
#include "wpi/math/system/NumericalJacobian.hpp"
|
||||
#include "wpi/math/system/plant/DCMotor.hpp"
|
||||
#include "wpi/math/system/plant/LinearSystemId.hpp"
|
||||
#include "wpi/math/trajectory/TrajectoryGenerator.hpp"
|
||||
#include "wpi/units/moment_of_inertia.hpp"
|
||||
|
||||
@@ -183,9 +183,8 @@ TEST(S3UKFTest, DriveConvergence) {
|
||||
|
||||
TEST(S3UKFTest, LinearUKF) {
|
||||
constexpr wpi::units::second_t dt = 20_ms;
|
||||
auto plant =
|
||||
wpi::math::LinearSystemId::IdentifyVelocitySystem<wpi::units::meters>(
|
||||
0.02_V / 1_mps, 0.006_V / 1_mps_sq);
|
||||
auto plant = wpi::math::Models::FlywheelFromSysId(0.02_V / 1_rad_per_s,
|
||||
0.006_V / 1_rad_per_s_sq);
|
||||
wpi::math::S3UKF<1, 1, 1> observer{
|
||||
[&](const wpi::math::Vectord<1>& x, const wpi::math::Vectord<1>& u) {
|
||||
return plant.A() * x + plant.B() * u;
|
||||
|
||||
@@ -16,7 +16,6 @@
|
||||
#include "wpi/math/kinematics/SwerveDriveKinematics.hpp"
|
||||
#include "wpi/math/trajectory/TrajectoryGenerator.hpp"
|
||||
#include "wpi/util/print.hpp"
|
||||
#include "wpi/util/timestamp.h"
|
||||
|
||||
void testFollowTrajectory(
|
||||
const wpi::math::SwerveDriveKinematics<4>& kinematics,
|
||||
|
||||
@@ -17,7 +17,6 @@
|
||||
#include "wpi/math/kinematics/SwerveDriveKinematics.hpp"
|
||||
#include "wpi/math/trajectory/TrajectoryGenerator.hpp"
|
||||
#include "wpi/util/print.hpp"
|
||||
#include "wpi/util/timestamp.h"
|
||||
|
||||
void testFollowTrajectory(
|
||||
const wpi::math::SwerveDriveKinematics<4>& kinematics,
|
||||
|
||||
Reference in New Issue
Block a user