7. 切換超平面の設計(1)
連続時間系のスライディングモード制御における切換超平面の設計を考える。
極配置による設計法
式(1)の線形時不変系で考える。\dot x_a = A x_a + B u \;\;\; \cdots (1)
極配置による設計例
制御対象として3次の線形時不変系を考える。\dot{x} = A x + B u, \quad A = \begin{bmatrix} 0 & 1 & 0 \\ 0 & 0 & 1 \\ 0 & 0 & a \end{bmatrix}, \quad B = \begin{bmatrix} 0 \\ 0 \\ b \end{bmatrix}
スライディングモードに入ると、制御入力は等価制御により \dot{\sigma} = 0を保つ。よって、\dot{\sigma} = S \dot{x} = S (A x + B u) = 0
スライディング面上のダイナミクス(縮約系)が2次系であることに注目し、希望する固有値(極)を2つ指定する。例えば、\lambda_1=-3, \lambda_2=-4。その2次系の特性方程式は、\lambda^2 + \alpha_1 \lambda + \alpha_0 = 0 \Rightarrow \alpha_1 = -(\lambda_1 + \lambda_2),\quad \alpha_0 = \lambda_1 \lambda_2 \;\;\; \cdots (7)
Pythonスクリプトとシミュレーション結果を示す。図1は、状態量x_1,x_2,x_3の時間応答である。全ての応答が0に収束している。図2は、スライディング面\sigmaと制御入力の時間変化である。約1.3 sでスライディング面に到達し、スライディングモードで[0,0,0]に向かっている様子が分かる。図3は、状態量x_1,x_2による位相平面軌跡でx_1=0.12,\;x_2=-0.12において、スライディングモードに入っていることが分かる。図4は、状態量x_1,x_2,x_3の3次元位相軌跡で、スライディングモードで[0,0,0]に収束している様子がわかる。




import numpy as np
import matplotlib.pyplot as plt
from scipy.integrate import solve_ivp
from mpl_toolkits.mplot3d import Axes3D # 3D plot support
# Define system parameters
a = 1.0 # Example value for 'a'
b = 1.0 # Example value for 'b'
# Given eigenvalues
lambda1 = -1
lambda2 = -2
# Compute k1, k2 from the given relationship
k1 = lambda1 * lambda2
k2 = -(lambda1 + lambda2)
# Define sliding surface S
S = np.array([k1, k2, 1])
# Define system matrices
A = np.array([[0, 1, 0],
[0, 0, 1],
[0, 0, a]])
B = np.array([[0], [0], [b]])
# Define the sliding mode dynamics
def smc_dynamics(t, x, A, B, S):
# Sliding surface
sigma = np.dot(S, x) # スカラー値
# Sliding mode control law
u = -np.sign(sigma) # スカラー制御入力
# 状態方程式: dx = A*x + B*u(B: (3,1), u: スカラー)
dx = A @ x + (B * u).flatten()
return dx
# Initial condition for the state
x0 = np.array([0.1, 0.1, 0.2]) # Example initial state
# Time span for the simulation
t_span = [0, 10]
t_eval = np.linspace(t_span[0], t_span[1], 500)
# Solve the system with the sliding mode control
sol = solve_ivp(smc_dynamics, t_span, x0, args=(A, B, S), t_eval=t_eval)
# Plot the results: States
plt.figure(figsize=(10, 6))
plt.subplot(3, 1, 1)
plt.plot(sol.t, sol.y[0], label='x1')
plt.title('State x1')
plt.xlabel('Time [s]')
plt.ylabel('x1')
plt.grid(True)
plt.subplot(3, 1, 2)
plt.plot(sol.t, sol.y[1], label='x2')
plt.title('State x2')
plt.xlabel('Time [s]')
plt.ylabel('x2')
plt.grid(True)
plt.subplot(3, 1, 3)
plt.plot(sol.t, sol.y[2], label='x3')
plt.title('State x3')
plt.xlabel('Time [s]')
plt.ylabel('x3')
plt.grid(True)
plt.tight_layout()
plt.show()
# Calculate the Sliding Surface (sigma) for all time points
sigma_values = np.array([np.dot(S, sol.y[:, i]) for i in range(sol.y.shape[1])])
# Plot the Sliding Surface (sigma)
plt.figure(figsize=(8, 4))
plt.plot(sol.t, sigma_values, label='$\sigma(t)$')
plt.axhline(0, color='red', linestyle='--', label='Sliding Surface $\sigma=0$')
plt.title('Sliding Surface ($\sigma(t)$)')
plt.xlabel('Time [s]')
plt.ylabel('Sliding Surface $\sigma(t)$')
plt.grid(True)
plt.legend()
plt.tight_layout()
plt.show()
# Plot control input u
u_values = -np.sign(sigma_values) # Control input based on the sliding surface
plt.figure(figsize=(8, 4))
plt.plot(sol.t, u_values, label='$u(t)$', color='green')
plt.title('Control Input ($u(t)$)')
plt.xlabel('Time [s]')
plt.ylabel('Control Input $u$')
plt.grid(True)
plt.legend()
plt.tight_layout()
plt.show()
# Phase plane plot (x1 vs x2)
plt.figure(figsize=(6, 6))
plt.plot(sol.y[0], sol.y[1], label='Phase Plane (x1 vs x2)')
plt.title('Phase Plane (x1 vs x2)')
plt.xlabel('x1')
plt.ylabel('x2')
plt.grid(True)
plt.axis('equal')
plt.legend()
plt.tight_layout()
plt.show()
# 3D Phase trajectory: x1 vs x2 vs x3
fig = plt.figure(figsize=(8, 6))
ax = fig.add_subplot(111, projection='3d')
ax.plot(sol.y[0], sol.y[1], sol.y[2], label='Phase Trajectory (x1-x2-x3)')
ax.set_title('3D Phase Trajectory')
ax.set_xlabel('x1')
ax.set_ylabel('x2')
ax.set_zlabel('x3')
ax.grid(True)
ax.legend()
plt.tight_layout()
plt.show()