from AlexRobotics.control import ComputedTorque
from AlexRobotics.planning import RandomTree
from AlexRobotics.control import DPO

###########################
# Objectives
###########################

x_start = np.array([-3.0, 0.0])
x_goal = np.array([0.0, 0.0])

###########################
# Create objects
###########################

Robot = Manipulator.OneLinkManipulator()

PD = linear.PD(kp=5, kd=2)
PID = linear.PID(kp=5, kd=2, ki=4)
CTC = ComputedTorque.ComputedTorqueController(Robot)
SLD = ComputedTorque.SlidingModeController(Robot)
RRT = RandomTree.RRT(Robot, x_start)
VI = DPO.ValueIteration1DOF(Robot, 'quadratic')

############################
# Params
############################

tmax = 8  # max motor torque
Robot.u_ub = np.array([tmax])  # Control Upper Bounds
Robot.u_lb = np.array([-tmax])  # Control Lower Bounds
# -*- coding: utf-8 -*-
"""
Created on Sun Mar  6 15:27:04 2016

@author: alex
"""

from AlexRobotics.planning import RandomTree as RPRT
from AlexRobotics.dynamic import Manipulator as M

import numpy as np
import matplotlib.pyplot as plt

R = M.OneLinkManipulator()

tmax = 10

R.u_ub = np.array([tmax])  # Control Upper Bounds
R.u_lb = np.array([-tmax])  # Control Lower Bounds

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

RRT = RPRT.RRT(R, x_start)

RRT.dt = 0.1
RRT.goal_radius = 0.3
RRT.max_nodes = 5000
RRT.max_solution_time = 5

# Dynamic plot