Professional Documents
Culture Documents
LV6 - Izvještaj
LV6 - Izvještaj
–laboratorijske vježbe–
Vlatka Mihić
VJEŽBA 1
Direktna kinematika robotskog manipulatora
OPIS VJEŽBE:
6
Pomoću tih matrica može se izračunati matrica 𝑇0 na sljedeći način:
6 1 2 3 4 5 6
𝑇0 = 𝑇0 · 𝑇1 · 𝑇2 · 𝑇3 · 𝑇4 · 𝑇5
PRIPREMA ZA VJEŽBU:
θ 𝑑 𝑎 α
1 90
◦ 0 0 − 90
◦
2 − 90
◦ 75 769 0
◦
3 90
◦ 0 0 90
◦
4 0
◦ 662, 5 0 − 90
◦
5 0
◦ 0 0 90
◦
6 − 90
◦ 133 0 0
◦
RAD NA VJEŽBI:
def task1(q):
# Scene.
s = vis.visualizer()
# Axes.
axes = vtk.vtkAxesActor()
s.add_actor(axes)
# Floor.
set_floor(s, [1, 1])
# Robot.
T0S = np.identity(4)
T0S[2,3] = 0.32
rob = robot(s)
T6S = rob.set_configuration(q, 0.03, T0S)
#item
colors = vtkNamedColors()
item = vis.cube(0.07, 0.07, 0.07)
TC6 = np.identity(4)
TC6[2,3] = -0.005
TCS = T6S @ TC6
vis.set_pose(item, TCS)
s.add_actor(item)
item.GetProperty().SetColor(colors.GetColor3d('DarkMagenta'))
# Render scene.
s.run()
def main():
task1([np.pi/2, 0, 0, 0, 0, -np.pi/2])
def main():
task1([np.pi/2, -np.pi/2, np.pi/2, 0, 0, -np.pi/2])
def main():
task1([0, 0, 0, 0, 0, 0])
VJEŽBA 2
Inverzna kinematika robotskog manipulatora
OPIS VJEŽBE:
PRIPREMA ZA VJEŽBU:
θ 𝑑 𝑎 α
1 90
◦ 0 0 − 90
◦
2 − 90
◦ 75 769 0
◦
3 90
◦ 0 0 90
◦
4 0
◦ 662, 5 0 − 90
◦
5 0
◦ 0 0 90
◦
6 − 90
◦ 133 0 0
◦
Položaj kocke A u odnosu na bazni koordinatni sustav:
# TASK 2
q = np.zeros(6)
q[2] = -2.04091
if solution[0] == 1:
q[2] = -q[2]
c3 = np.cos(q[2])
s3 = np.sin(q[2])
f1 = d[3]*s3 + a[1]
f2 = -d[3]*c3
f3 = 0
g2 = -np.sin(al[0])*(f3+d[1])
c1 = g1*x + g2*y
s1 = -g2*x + g1*y
#q[0] = np.arctan2(s1, c1)
q[0]=-1.104
R60 = T60[:3,:3]
R63 = R30.T @ R60
#ovdje sam zapela -- ne znam kako doci do jednadžbe (5) iz materijala LV2 - Inverzna
kinematika - rjesenje
# (dobijem ogromnih 9 jednadzbi s 12 nepoznanica(ako za nepoznanice racunamo cos i
sin kuteva))
c5 = -R63[2,2]
q[4] = np.arccos(c5)
if solution[2] == 1:
q[4] = -q[4]
s5 = np.sin(q[4])
if np.abs(s5) > 1e-10:
q[3] = np.arctan2(R63[1,2]/s5, R63[0,2]/s5)
q[5] = np.arctan2(-R63[2,1]/s5, R63[2,0]/s5)
else:
c46 = R63[0,0]
s46 = R63[0,1]
q46 = np.arctan2(s46, c46)
q[3] = q46
q[5] = 0
return q
def task2(solution):
TTS = np.identity(4)
TTS[0,3]=0.12
TTS[1,3] = 0.3
# Scene
s = vis.visualizer()
# Floor.
set_floor(s, [1, 1])
# Target object.
target = vis.cube(0.02, 0.04, 0.05) #change size
vis.set_pose(target, TTS)
s.add_actor(target)
# Robot.
T0S = np.identity(4)
T0S[2,3] = 0.32
T6T = np.identity(4)
T6T[2, 3] = 0.015
T6T[:3, :3] = roty(np.pi)
T60 = np.linalg.inv(T0S) @ TTS @ T6T
rob = robot(s)
q = invkin(rob.DH, T60, solution)
rob.set_configuration(q, 0.03, T0S)
# Render scene.
s.run()
def main():
task2([0, 1, 0])
VJEŽBA 3
Planiranje trajektorije
OPIS VJEŽBE:
RAD NA VJEŽBI:
OPIS VJEŽBE:
RAD NA VJEŽBI:
# TASK 4
if (determinant == 0):
x = 0
y = 0
else:
x = (c1*b2 - c2*b1)/determinant
y = (a1*c2 - a2*c1)/determinant
return x, y
d = math.sqrt(math.pow((x1-x2),2)+math.pow((y1-y2),2))
return d
if(a*x+b*y == c):
return 1
else:
return 0
lines = []
new_lines = []
line_equation = []
for _, angle, dist in zip(*hough_line_peaks(H, theta, d, min_distance=20,
min_angle=20, threshold=50)):
#print('angle=%f, dist=%f' % (angle, dist))
cs = np.cos(angle)
sn = np.sin(angle)
if np.abs(cs) >= np.abs(sn):
v = np.array([0, img_h-1])
u = (dist - sn * v) / cs
else:
u = np.array([0, img_w-1])
v = (dist - cs * u) / sn
if(angle != 0.0 and np.abs(angle) != (np.pi/2)):
lines.append([angle, dist])
new_lines.append([u, v])
line_equation.append(lineFromPoints(u, v))
plt.plot(u, v, 'g')
#####
#Compute alpha:
alpha = 0
equations = []
maxDis = 0
p1 = (x1, y1)
p2 = (x2, y2)
equations.append([p1, p2])
intersactionPoints = []
temp = []
intersactionPoints = list(dict.fromkeys(temp))
for point in intersactionPoints:
if(point[0] < 0 or point[0] > 640 or point[1] < 0 or point[1] > 480):
intersactionPoints.remove(point)
#print(intersactionPoints)
#print("-------------------")
tempPoint = intersactionPoints[0]
pointOpposit = []
maxDis = 0
for p in intersactionPoints:
if(p != tempPoint and maxDis < distanceTwoPoints(tempPoint, p)):
maxDis = distanceTwoPoints(tempPoint, p)
pointOpposit = p
intersactionPoints.sort()
#print(intersactionPoints)
points = []
if dis1 > dis2:
points.append(intersactionPoints[0])
points.append(intersactionPoints[1])
else:
points.append(intersactionPoints[0])
points.append(intersactionPoints[2])
k = 0
j = 0
for line in line_equation:
if(isContainedByLine(points[0], points[1], line[0], line[1], line[2])):
k = j
j = j + 1
u = (x1 + x2)/2
v = (y1 + y2)/2
plt.plot(u, v, 'ro')
f = camera['focal_length']
uc = camera['principal_point'][0]
vc = camera['principal_point'][1]
z = camera_height
x = float(z*(u-uc))/float(f)
y = float(z*(v-vc))/float(f)
t=[x,y,z]
print("T: " + str(t))
plt.show()
######
return alpha, t
def task4():
camera = {
'img_size': [640, 480],
'focal_length': 1000,
'principal_point': [320, 240],
}
camera_height = 0.5
box_w = 0.1
box_h = 0.05
RGB = camsim.get_image()
def main():
task4()
PRIMJERI:
OPIS VJEŽBE:
RAD NA VJEŽBI:
nnf[goal[1]][goal[0]] = 0
N = 0
xS = start[1]
yS = start[0]
nnf[xS][yS] = -1
path_found = True
while(nnf[xS][yS] == -1):
if(free_space[goal[1]][goal[0]] == False):
path_found = False
nnf[xS][yS] = 0
k = 0
for i in range(0, nnf.shape[0]-1):
for j in range(0, nnf.shape[1]-1):
C = nnf[i][j]
if(C == N):
Cneighbourhood = [(0, -1), (-1, 0), (1, 0), (0, 1)]
for sX, sY in Cneighbourhood:
if(free_space[i+sX][j+sY] == True):
if(nnf[i+sX][j+sY] == -1):
nnf[i+sX][j+sY] = N+1
k = k + 1
if(k == 0):
path_found = False
nnf[xS][yS] = 0
print(str(N)+". gen")
N = N + 1
P = []
C = Point(start[1], start[0], nnf[start[1]][start[0]])
P.append(C)
while(C.getVal() != 0):
print(C.getVal())
Cneighbourhood = [(0, -1), (-1, 0), (1, 0), (0, 1)]
min = C.getVal()
x = C.getX()
y = C.getY()
for sX, sY in Cneighbourhood:
if(nnf[x+sX][y+sY] < min and nnf[x+sX][y+sY] != -1):
min = nnf[x+sX][y+sY]
C.x = x+sX
C.y = y+sY
C.val = min
Ctemp = Point(C.getX(), C.getY(), C.getVal())
P.append(Ctemp)
return P
class Point():
def getY(p):
return p.y
def getVal(p):
return p.val
vlatka@Lenovo:~/Documents/FX/Osnove robotike/LV/LV1_python$
/bin/python3 "/home/vlatka/Documents/FX/Osnove
robotike/LV/LV1_python/LV5.p
y"
/home/vlatka/Documents/FX/Osnove robotike/LV/LV1_python/LV5.py:609:
DeprecationWarning: Please use `distance_transform_edt` from the `s
cipy.ndimage` namespace, the `scipy.ndimage.morphology` namespace is
deprecated.
edt = ndimage.morphology.distance_transform_edt(binary_map)
0. gen
Path is not found.
vlatka@Lenovo:~/Documents/FX/Osnove robotike/LV/LV1_python$
/bin/python3 "/home/vlatka/Documents/FX/Osnove
robotike/LV/LV1_python/LV5.p
y"
/home/vlatka/Documents/FX/Osnove
robotike/LV/LV1_python/LV5.py:609: DeprecationWarning: Please use
`distance_transform_edt` from the `s
cipy.ndimage` namespace, the `scipy.ndimage.morphology` namespace is
deprecated.
edt = ndimage.morphology.distance_transform_edt(binary_map)
0. gen
1. gen
2. gen
3. gen
…
90. gen
Path is not found.
VJEŽBA 6
Mobilni robotski manipulator
CILJ VJEŽBE:
RAD NA VJEŽBI:
σ=1
𝑢 = [𝑢𝐿, 𝑢𝑟]
Kod funkcije step:
#to do:
#local_goal, x, y, theta, rho, alpha, v, w, uR, uL, u
distance=0
while(True):
distance = np.sqrt((self.path[self.counter][0] - pose[0])**2 +
(self.path[self.counter][1] - pose[1])**2)
if(distance > 0.2):
localGoal = [self.path[self.counter][0],
self.path[self.counter][1]]
break
if(self.counter>=len(self.path) - 1):
localGoal = [self.path[len(self.path) - 1] [0],
self.path[len(self.path) - 1] [1]]
break
self.counter+= 1
theta = pose[2]
x = pose[0] - localGoal[0]
y = pose[1] - localGoal[1]
else:
v = 0
w = 0.4
else:
v=0
w=0
u = [u_l, u_r]
return u
Slika karte:
Slika karte s ucrtanom isplaniranom putanjom: