def __init__(self, R=HM.HybridTwoLinkManipulator()):
        """ """

        RminComputedTorqueController.__init__(self, R)

        self.lam = 1  # Sliding surface slope
        self.D = 1  # Discontinuous gain
        self.nab = 0.1  # min convergence rate
    def __init__(self, R=HM.HybridTwoLinkManipulator(), R_index=0):
        """ """

        CTC.ComputedTorqueController.__init__(self, R)

        self.R_index = R_index  # Fixed gear ratio index

        # Integral action with dist observer (beta)
        self.dist_obs_active = False
        self.obs = OBS.DistObserver(R)
        self.obs.ishybrid = True
    def __init__(self, R=HM.HybridTwoLinkManipulator(), R_index=0):
        """ """

        CTC.ComputedTorqueController.__init__(self, R)

        self.R_index = R_index  # Fixed gear ratio index

        # Slding Params
        self.lam = 1  # Sliding surface slope
        self.D = 1  # Discontinuous gain
        self.nab = 0.1  # min convergence rate

        # Integral action with dist observer (beta)
        self.dist_obs_active = False
        self.obs = OBS.DistObserver(R)
        self.obs.ishybrid = True
    def __init__(self, R=HM.HybridTwoLinkManipulator()):
        """ """

        CTC.ComputedTorqueController.__init__(self, R)

        self.n_gears = 4

        self.hysteresis = False
        self.hys_level = 1
        self.last_gear_i = 0  # Default gear
        self.min_delay = -10000  # default is not constraint
        self.last_shift_t = -1

        # Integral action with dist observer (beta)
        self.dist_obs_active = False
        self.obs = OBS.DistObserver(R)
    def __init__( self , R = HM.HybridTwoLinkManipulator() ):
        """ """
        
        RCTC.RminSlidingModeController.__init__( self , R  )
        
        
        self.FixCtl = RCTC.RfixSlidingModeController( R )
        

        # Assign Rollout Controller to Simulation Model
        self.R.ctl = self.FixCtl.ctl
        
        # Rollout Params
        self.horizon = 1
        self.sim_dt  = 0.02
        self.sim_n   =  self.horizon / self.sim_dt + 1
        
        # Domain check in simulation?
        self.domain_check     = True
        self.domain_fail_cost = 1
# -*- coding: utf-8 -*-
"""
Created on Sun Mar  6 15:27:04 2016

@author: alex
"""

from AlexRobotics.dynamic import Hybrid_Manipulator as HM
from AlexRobotics.planning import RandomTree as RPRT
from AlexRobotics.control import RminComputedTorque as RminCTC

import numpy as np
import matplotlib.pyplot as plt

R = HM.HybridTwoLinkManipulator()

R.ubar = np.array([0, 0, 3])

x_start = np.array([3, 0, 0, 0])
x_goal = np.array([0, 0, 0, 0])

RRT = RPRT.RRT(R, x_start)

T = 5
#
RRT.U = np.array([[T, 0, 0], [0, 0, 0], [-T, 0, 0], [0, T, 0], [0, -T, 0],
                  [T, T, 0], [-T, -T, 0], [-T, T, 0], [T, -T, 0], [T, 0, 1],
                  [0, 0, 1], [-T, 0, 1], [0, T, 1], [0, -T, 1], [T, T, 1],
                  [-T, -T, 1], [-T, T, 1], [T, -T, 1], [T, 0, 2], [0, 0, 2],
                  [-T, 0, 2], [0, T, 2], [0, -T, 2], [T, T, 2], [-T, -T, 2],
                  [-T, T, 2], [T, -T, 2], [T, 0, 3], [0, 0, 3], [-T, 0, 3],
# -*- coding: utf-8 -*-
"""
Created on Sun Mar  6 15:27:04 2016

@author: alex
"""

from AlexRobotics.dynamic  import Hybrid_Manipulator     as HM
from AlexRobotics.planning import RandomTree             as RPRT
from AlexRobotics.control  import RminComputedTorque     as RminCTC
from AlexRobotics.control  import RolloutComputedTorque  as RollCTC

import numpy as np
import matplotlib.pyplot as plt

R_ctl  =  HM.HybridTwoLinkManipulator() # Controller model
R      =  HM.HybridTwoLinkManipulator() # Simulator


# Assign controller
Rollout     = RollCTC.RolloutSlidingModeController( R_ctl )

Rollout.goal         = np.array([0,0,0,0])
Rollout.FixCtl.lam   = 1.0
Rollout.FixCtl.D     = 2.0
Rollout.FixCtl.nab   = 1.0
Rollout.n_gears      = 4
Rollout.hysteresis   = True
Rollout.min_delay    = 0.5
Rollout.horizon      = 0.5