Пример #1
0
# -*- coding: utf-8 -*-
"""
Created on Fri Nov 16 12:05:08 2018

@author: Alexandre
"""
###############################################################################
import numpy as np
###############################################################################
from pyro.dynamic import pendulum
from pyro.control import nonlinear
###############################################################################

sys = pendulum.SinglePendulum()
#ctl  = nonlinear.ComputedTorqueController( sys )
ctl = nonlinear.SlidingModeController(sys)

ctl.gain = 5

# Set Point
q_target = np.array([3.14])
ctl.rbar = q_target

# New cl-dynamic
cl_sys = ctl + sys

# Simultation
x_start = np.array([-2, 0])
cl_sys.plot_trajectory(x_start, 10, 1001, 'euler')
cl_sys.sim.phase_plane_trajectory_closed_loop(0, 1)
cl_sys.sim.phase_plane_trajectory(0, 1)
Пример #2
0
# PID
kp = 5
kd = 2
ki = 1
pid_ctl = robotcontrollers.JointPID(1, kp, ki, kd)
pid_ctl.rbar = q_goal

# Computed Torque
ctc_ctl = nonlinear.ComputedTorqueController(sys)
ctc_ctl.rbar = q_goal
ctc_ctl.w0 = 2.0
ctc_ctl.zeta = 0.8

# Sliding Mode
sld_ctl = nonlinear.SlidingModeController(sys)
sld_ctl.lam = 1
sld_ctl.gain = 5
sld_ctl.rbar = q_goal

# OpenLoop with traj
traj_ctl = plan.OpenLoopController(traj)

# Computed Torque with traj
traj_ctc_ctl = nonlinear.ComputedTorqueController(sys, traj)
traj_ctc_ctl.rbar = q_goal
traj_ctc_ctl.w0 = 2.0
traj_ctc_ctl.zeta = 0.8

# Sliding Mode with traj
traj_sld_ctl = nonlinear.SlidingModeController(sys, traj)