Skip to content

Commit 0f86b25

Browse files
committed
Projet Asimov fait par Bruno-Pier Busque
1 parent 2c94091 commit 0f86b25

5 files changed

Lines changed: 217 additions & 0 deletions

File tree

projects/asimov/asimov.py

Lines changed: 113 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,113 @@
1+
# -*- coding: utf-8 -*-
2+
"""
3+
Created on Mon July 22 2019
4+
5+
@author: Bruno-Pier Busque
6+
"""
7+
8+
###############################################################################
9+
import numpy as np
10+
###############################################################################
11+
from pyro.dynamic import manipulator
12+
###############################################################################
13+
14+
15+
###############################################################################
16+
# 3D Asimov
17+
###############################################################################
18+
19+
class Asimov( manipulator.ThreeLinkManipulator3D ):
20+
"""
21+
Asimov Manipulator Class
22+
-------------------------------
23+
"""
24+
25+
############################
26+
def __init__(self):
27+
""" """
28+
29+
# initialize standard params
30+
manipulator.ThreeLinkManipulator3D.__init__(self)
31+
32+
# Name
33+
self.name = 'Asimov Manipulator'
34+
35+
# Kinematic params
36+
self.l1 = 0.5 # [m]
37+
self.baseradius = 0.3 # [m]
38+
self.armradius = 0.05 # [m]
39+
self.l2 = 0.525 # [m]
40+
self.l3 = 0.375 # [m]
41+
self.lc1 = self.l1/2 # [m]
42+
self.lc2 = self.l2/2 # [m]
43+
self.lc3 = self.l3/2 # [m]
44+
self.lw = (self.l1 + self.l2 + self.l3) # Total length
45+
46+
# Inertia params
47+
self.m1 = 3.703 # [kg]
48+
self.mbras = 0.915 # [kg]
49+
self.mcoude = 0.832 # [kg]
50+
self.m2 = self.mbras + self.mcoude # [kg]
51+
self.m3 = 0.576 # [kg]
52+
53+
self.I1z = self.m1*(self.baseradius**2)/2
54+
55+
self.I2x = (self.mbras*self.l2**2)/3 + self.mcoude*self.l2**2
56+
self.I2y = self.I2x
57+
self.I2z = self.m2*(self.armradius**2)/2
58+
59+
self.I3x = (self.m3*self.l3**2)/3
60+
self.I3y = self.I3x
61+
self.I3z = self.m3*(self.armradius**2)/2
62+
63+
# Labels, bounds and units
64+
self.x_ub = np.array([np.pi/2, -np.pi/4, np.pi/2])
65+
self.x_lb = np.array([-np.pi/2, -3*np.pi/4, -np.pi/2])
66+
67+
68+
###############################################################################
69+
# 2D Asimov
70+
###############################################################################
71+
72+
class Asimov2D( manipulator.TwoLinkManipulator ):
73+
"""
74+
Asimov 2D Manipulator Class
75+
-------------------------------
76+
A model of Asimov without the rotating base
77+
"""
78+
79+
############################
80+
def __init__(self):
81+
""" """
82+
83+
# initialize standard params
84+
manipulator.TwoLinkManipulator.__init__(self)
85+
86+
# Name
87+
self.name = 'Asimov 2D Manipulator'
88+
89+
self.l1 = 0.525 # [m]
90+
self.l2 = 0.375
91+
self.lc1 = self.l1/2
92+
self.lc2 = self.l2/2
93+
94+
self.mbras = 0.915 # [kg]
95+
self.mcoude = 0.832 # [kg]
96+
self.m1 = self.mbras + self.mcoude # [kg]
97+
self.m2 = 0.576 # [kg]
98+
self.I1 = (self.mbras*self.l1**2)/3 + self.mcoude*self.l1**2
99+
self.I2 = (self.m2*self.l2**2)/3
100+
101+
102+
if __name__ == "__main__":
103+
""" MAIN TEST """
104+
105+
sys = Asimov()
106+
dsys = manipulator.SpeedControlledManipulator(sys)
107+
dsys.ubar = np.array([1, 1, 1])
108+
dsys.show3([0.1, 0.1, 0.1])
109+
x02 = np.array([0, 1, 1]) # Position initiale
110+
111+
dsys.plot_animation(x02)
112+
dsys.sim.plot('xu')
113+
Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
###############################################################################
2+
import numpy as np
3+
import matplotlib.pyplot as plt
4+
###############################################################################
5+
from asimov import Asimov
6+
from pyro.control import nonlinear
7+
###############################################################################
8+
9+
asimov = Asimov() # Asimov
10+
x0 = np.array([-np.pi/4, -3*np.pi/4, np.pi/2, 0, 0, 0]) # Position initiale
11+
12+
ctl = nonlinear.ComputedTorqueController(asimov) # Déclaration du controlleur
13+
ctl.rbar = np.array([0.5, 0.25, 0]) # Cible
14+
ctl.w0 = 2
15+
ctl.zeta = 1
16+
17+
closed_loop_robot = ctl + asimov # Système boucle fermé
18+
19+
closed_loop_robot.plot_trajectory(x0, 5) # Calcul de la trajectoire
20+
closed_loop_robot.sim.plot('x') # Affichage des états
21+
closed_loop_robot.sim.plot('u') # Affichage des commandes
22+
closed_loop_robot.animate_simulation(1, True) # Animation et enregistrement
23+
24+
plt.show()
Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
###############################################################################
2+
import numpy as np
3+
import matplotlib.pyplot as plt
4+
###############################################################################
5+
from asimov import Asimov
6+
from pyro.control import robotcontrollers
7+
###############################################################################
8+
kp = 80
9+
ki = 0
10+
kd = 0
11+
12+
asimov = Asimov() # Asimov
13+
x0 = np.array([-np.pi/4, -3*np.pi/4, np.pi/2, 0, 0, 0]) # Position initiale
14+
15+
qd = np.array([0.5, -np.pi/4, 0.5]) # Cible au joint
16+
rd = asimov.forward_kinematic_effector(qd)
17+
18+
ctl = robotcontrollers.EndEffectorPID(asimov, kp, ki, kd) # Déclaration du controlleur
19+
ctl.rbar = rd # Cible
20+
ctl.kd = np.array([10, 30, 30])
21+
22+
closed_loop_robot = ctl + asimov # Système boucle fermé
23+
24+
closed_loop_robot.plot_trajectory(x0, 5) # Calcul de la trajectoire
25+
closed_loop_robot.sim.plot('x') # Affichage des états
26+
closed_loop_robot.sim.plot('u') # Affichage des commandes
27+
closed_loop_robot.animate_simulation(1, True ) # Animation et enregistrement
28+
29+
plt.show()
Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
###############################################################################
2+
import numpy as np
3+
import matplotlib.pyplot as plt
4+
###############################################################################
5+
from asimov import Asimov
6+
from pyro.control import robotcontrollers
7+
###############################################################################
8+
kp = 40
9+
ki = 0
10+
kd = 0
11+
12+
asimov = Asimov() # Asimov
13+
x0 = np.array([-np.pi/4, -3*np.pi/4, np.pi/2, 0, 0, 0]) # Position initiale
14+
15+
qd = np.array([0.5, -np.pi/4, 0.5]) # Cible au joint
16+
17+
ctl = robotcontrollers.JointPID(3, kp, ki, kd) # Déclaration du controlleur
18+
ctl.rbar = qd
19+
ctl.kd = np.array([5, 8, 1])
20+
21+
closed_loop_robot = ctl + asimov # Système boucle fermé
22+
23+
closed_loop_robot.plot_trajectory(x0, 5) # Calcul de la trajectoire
24+
closed_loop_robot.sim.plot('x') # Affichage des états
25+
closed_loop_robot.sim.plot('u') # Affichage des commandes
26+
closed_loop_robot.animate_simulation(1, True) # Animation
27+
28+
plt.show()
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
###############################################################################
2+
import numpy as np
3+
import matplotlib.pyplot as plt
4+
###############################################################################
5+
from pyro.control import robotcontrollers
6+
from pyro.dynamic import manipulator
7+
from asimov import Asimov
8+
###############################################################################
9+
gain = 1 # Gain du controlleur
10+
11+
asimov = Asimov() # Asimov
12+
sc_asimov = manipulator.SpeedControlledManipulator(asimov) # Asimov controllé en vitesse
13+
x0 = np.array([3*np.pi/4, -np.pi/2, np.pi/2]) # Position initiale [q1, q2, q3]
14+
15+
ctl = robotcontrollers.EndEffectorKinematicController(sc_asimov, gain) # Déclaration du controlleur
16+
ctl.rbar = np.array([0.5, 0.25, 0]) # Cible
17+
18+
closed_loop_robot = ctl + sc_asimov # Système boucle fermé
19+
20+
closed_loop_robot.plot_trajectory(x0, 5) # Calcul de la trajectoire
21+
closed_loop_robot.animate_simulation(1.0, True ) # Animation
22+
23+
plt.show()

0 commit comments

Comments
 (0)