状態空間表現
以下のシステムを表すオブジェクトを作成します。またシステムが可制御・可観測であるかを判定します
\[
\begin{align}
\frac{d}{dt}
\left [\begin{array}{c}
x_1 \\
x_2
\end{array}
\right ]
&=
\left [\begin{array}{c}
0 & 1 \\
1 & 0.5
\end{array}
\right ]
\left [\begin{array}{c}
x_1 \\
x_2
\end{array}
\right ]
+
\left [\begin{array}{c}
0 \\
0.5
\end{array}
\right ]
u\\
y &=
\left [\begin{array}{c}
1 & 0
\end{array}
\right ]
\left [\begin{array}{c}
x_1 \\
x_2
\end{array}
\right ]
\end{align}
\]
#include <iostream>
#include <cpp_robotics/system.hpp>
#include <cpp_robotics/controller.hpp>
#include <cpp_robotics/controller/modern_control.hpp>
int main()
{
namespace cr = cpp_robotics;
Eigen::Matrix2d A;
Eigen::Matrix<double, 2, 1> B;
Eigen::Matrix<double, 1, 2> C;
A << 0, 1, 1, 0.5;
B << 0, 0.5;
C << 1, 0;
const double dt = 0.01;
cr::StateSpaceSystem sys(A, B, C, dt);
if(cr::is_controllable(A, B))
{
std::cout << "Controllable" << std::endl;
}
else
{
std::cout << "Uncontrollable" << std::endl;
}
if(cr::is_observable(A, C))
{
std::cout << "Observable" << std::endl;
}
else
{
std::cout << "Unobservable" << std::endl;
}
}
出力
Controllable
Observable