problem.py
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
"""
system description: a two-body floating system is considered. The above iron ball undergoes
a magnetic force generated by a current. A CuZn ball below is attached to that iron ball
by a spring with the spring constant kf.
problem specification for control problem: plan the trajectory of the CuZn ball by using the trajectory
planning based on the transfer function.then let the real trajectory of the ball converge towards the
target trajectory by using the tracking controller.(the ball moves from 0.04m to 0.05m within 5 seconds.)
"""
import sympy as sp
import numpy as np
from ackrep_core import ResultContainer
class ProblemSpecification(object):
YA = [0.04, 0, 0, 0] # initial conditions of the CuZn-Ball p2 (position in m)
YB = [0.05, 0, 0, 0] # final conditions of the CuZn-Ball p2 (position in m)
t0 = 0 # start time in s
tf = 5 # final time in s
tt = np.linspace(0, 5, 1000) # period of state transition
tt1 = np.linspace(-1, 6, 1000) # period of full transition
tt2 = np.linspace(0, 6, 1000) # period for system with controller
tt3 = np.linspace(3, 5, 200) # time for evaluation
pol = [-50, -50, -15, -15] # desired poles of closed loop
x0_1 = np.array([0.042 / 130, 0, 0, 0]) # initial conditions for closed loop 1
x0_2 = np.array([0, 0, 0, 0]) # initial conditions for closed loop 2
tolerance = 1e-2
@staticmethod
def transfer_func():
s, t, T = sp.symbols("s, t, T")
# transfer function of the linearized system
transfer_func = (-8818) / (s**4 - 4787 * s**2 - 1.309 * 10**6)
return transfer_func
def evaluate_solution(solution_data):
"""
Condition: the position of the CuZn-ball moves from 0.04m to 0.05m after 4 seconds at the latest
:param solution_data: solution data of problem of solution
:return:
"""
P = ProblemSpecification
success = all(abs(solution_data.yy[800:] - solution_data.y_func(P.tt3)) < P.tolerance)
return ResultContainer(success=success, score=1.0)