blob: 8f1145d96dfc3a222f90b1be11f9a1060663ae4b [file] [log] [blame]
Austin Schuh812d0d12021-11-04 20:16:48 -07001// Copyright (c) FIRST and other WPILib contributors.
2// Open Source Software; you can modify and/or share it under the terms of
3// the WPILib BSD license file in the root directory of this project.
Austin Schuh1e69f942020-11-14 15:06:14 -08004
5#include "frc/StateSpaceUtil.h"
6
7namespace frc {
8
Austin Schuh812d0d12021-11-04 20:16:48 -07009Eigen::Vector<double, 3> PoseTo3dVector(const Pose2d& pose) {
10 return Eigen::Vector<double, 3>{pose.Translation().X().value(),
11 pose.Translation().Y().value(),
12 pose.Rotation().Radians().value()};
13}
14
15Eigen::Vector<double, 4> PoseTo4dVector(const Pose2d& pose) {
16 return Eigen::Vector<double, 4>{pose.Translation().X().value(),
17 pose.Translation().Y().value(),
18 pose.Rotation().Cos(), pose.Rotation().Sin()};
19}
20
Austin Schuh1e69f942020-11-14 15:06:14 -080021template <>
22bool IsStabilizable<1, 1>(const Eigen::Matrix<double, 1, 1>& A,
23 const Eigen::Matrix<double, 1, 1>& B) {
24 return detail::IsStabilizableImpl<1, 1>(A, B);
25}
26
27template <>
28bool IsStabilizable<2, 1>(const Eigen::Matrix<double, 2, 2>& A,
29 const Eigen::Matrix<double, 2, 1>& B) {
30 return detail::IsStabilizableImpl<2, 1>(A, B);
31}
32
Austin Schuh812d0d12021-11-04 20:16:48 -070033Eigen::Vector<double, 3> PoseToVector(const Pose2d& pose) {
34 return Eigen::Vector<double, 3>{pose.X().value(), pose.Y().value(),
35 pose.Rotation().Radians().value()};
Austin Schuh1e69f942020-11-14 15:06:14 -080036}
37
38} // namespace frc