Austin Schuh | 812d0d1 | 2021-11-04 20:16:48 -0700 | [diff] [blame] | 1 | // 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 Schuh | 1e69f94 | 2020-11-14 15:06:14 -0800 | [diff] [blame] | 4 | |
| 5 | #include "frc/StateSpaceUtil.h" |
| 6 | |
| 7 | namespace frc { |
| 8 | |
James Kuszmaul | cf32412 | 2023-01-14 14:07:17 -0800 | [diff] [blame^] | 9 | Vectord<3> PoseTo3dVector(const Pose2d& pose) { |
| 10 | return Vectord<3>{pose.Translation().X().value(), |
| 11 | pose.Translation().Y().value(), |
| 12 | pose.Rotation().Radians().value()}; |
Austin Schuh | 812d0d1 | 2021-11-04 20:16:48 -0700 | [diff] [blame] | 13 | } |
| 14 | |
James Kuszmaul | cf32412 | 2023-01-14 14:07:17 -0800 | [diff] [blame^] | 15 | Vectord<4> PoseTo4dVector(const Pose2d& pose) { |
| 16 | return Vectord<4>{pose.Translation().X().value(), |
| 17 | pose.Translation().Y().value(), pose.Rotation().Cos(), |
| 18 | pose.Rotation().Sin()}; |
Austin Schuh | 812d0d1 | 2021-11-04 20:16:48 -0700 | [diff] [blame] | 19 | } |
| 20 | |
Austin Schuh | 1e69f94 | 2020-11-14 15:06:14 -0800 | [diff] [blame] | 21 | template <> |
James Kuszmaul | cf32412 | 2023-01-14 14:07:17 -0800 | [diff] [blame^] | 22 | bool IsStabilizable<1, 1>(const Matrixd<1, 1>& A, const Matrixd<1, 1>& B) { |
Austin Schuh | 1e69f94 | 2020-11-14 15:06:14 -0800 | [diff] [blame] | 23 | return detail::IsStabilizableImpl<1, 1>(A, B); |
| 24 | } |
| 25 | |
| 26 | template <> |
James Kuszmaul | cf32412 | 2023-01-14 14:07:17 -0800 | [diff] [blame^] | 27 | bool IsStabilizable<2, 1>(const Matrixd<2, 2>& A, const Matrixd<2, 1>& B) { |
Austin Schuh | 1e69f94 | 2020-11-14 15:06:14 -0800 | [diff] [blame] | 28 | return detail::IsStabilizableImpl<2, 1>(A, B); |
| 29 | } |
| 30 | |
James Kuszmaul | cf32412 | 2023-01-14 14:07:17 -0800 | [diff] [blame^] | 31 | Vectord<3> PoseToVector(const Pose2d& pose) { |
| 32 | return Vectord<3>{pose.X().value(), pose.Y().value(), |
| 33 | pose.Rotation().Radians().value()}; |
Austin Schuh | 1e69f94 | 2020-11-14 15:06:14 -0800 | [diff] [blame] | 34 | } |
| 35 | |
| 36 | } // namespace frc |