Skip to content

Commit 5411c27

Browse files
committed
Updated tester functions and added comments.
1 parent 4dd29c4 commit 5411c27

File tree

1 file changed

+65
-69
lines changed

1 file changed

+65
-69
lines changed

graphics/graphics_test_features.py

Lines changed: 65 additions & 69 deletions
Original file line numberDiff line numberDiff line change
@@ -1,108 +1,65 @@
11
from graphics.model_puma560 import *
22

33

4-
def test_grid():
4+
def test_grid_updating():
5+
"""
6+
This test will create a canvas and update the grid every second.
7+
Eventually, the grid will only update through callbacks of key/button releases.
8+
"""
59
canvas_grid = init_canvas()
610
while True:
711
sleep(1)
812
canvas_grid.update_grid()
9-
print("XY:", canvas_grid.grid_object[0].pos)
1013

1114

12-
def test_reference_frames():
13-
le = 0.2
15+
def test_reference_frame_pose():
16+
"""
17+
This test will create a canvas, and place reference frames at the given positions and orientations.
18+
Each frame must be manually inspected for validity.
19+
"""
1420
canvas_grid = init_canvas()
1521

1622
# Test 1 | Position (0, 0, 0), Axis (1, 0, 0), No Rotation
17-
# Drawn
1823
draw_reference_frame_axes(vector(0, 0, 0), vector(1, 0, 0), radians(0))
19-
# Actual
20-
#arrow(pos=vector(0, 0, 0), axis=vector(1, 0, 0), length=le, color=color.purple)
2124

2225
# Test 2 | Position (1, 1, 1), Axis (0, 0, 1), No Rotation
23-
# Drawn
2426
draw_reference_frame_axes(vector(1, 1, 1), vector(0, 0, 1), radians(0))
25-
# Actual
26-
#arrow(pos=vector(1, 1, 1), axis=vector(0, 0, 1), length=le, color=color.purple)
2727

2828
# Test 3 | Position (2, 2, 2), Axis (1, 0, 0), 30 deg rot
29-
# Drawn
3029
draw_reference_frame_axes(vector(2, 2, 2), vector(1, 0, 0), radians(30))
31-
# Actual
32-
#arrow(pos=vector(2, 2, 2), axis=vector(1, 0, 0), length=le, color=color.purple).rotate(radians(30))
3330

3431
# Test 4 | Position (3, 3, 3), Axis (1, 1, 1), No Rotation
35-
# Drawn
3632
draw_reference_frame_axes(vector(3, 3, 3), vector(1, 1, 1), radians(0))
37-
# Actual
38-
#arrow(pos=vector(3, 3, 3), axis=vector(1, 1, 1), length=le, color=color.purple)
3933

4034
# Test 5 | Position (4, 4, 4), Axis (1, 1, 1), 30 deg rot
41-
# Drawn
4235
draw_reference_frame_axes(vector(4, 4, 4), vector(1, 1, 1), radians(30))
43-
# Actual
44-
#arrow(pos=vector(4, 4, 4), axis=vector(1, 1, 1), length=le, color=color.purple).rotate(radians(30))
4536

4637
# Test 6 | Position (5, 5, 5), Axis (2, -1, 4), No Rotation
47-
# Drawn
4838
draw_reference_frame_axes(vector(5, 5, 5), vector(2, -1, 4), radians(0))
49-
# Actual
50-
#arrow(pos=vector(5, 5, 5), axis=vector(2, -1, 4), length=le, color=color.purple)
5139

5240
# Test 7 | Position (6, 6, 6), Axis (2, -1, 4), 30 deg rot
53-
# Drawn
5441
draw_reference_frame_axes(vector(6, 6, 6), vector(2, -1, 4), radians(30))
55-
# Actual
56-
#arrow(pos=vector(6, 6, 6), axis=vector(2, -1, 4), length=le, color=color.purple).rotate(radians(30))
5742

5843

5944
def test_import_stl():
45+
"""
46+
This test will create a canvas with the Puma560 model loaded in.
47+
The robot should have all joint angles to 0 (Robot is in an 'L' shape from (1, 1, 0) in the +X axis direction)
48+
"""
6049
canvas_grid = init_canvas()
6150

6251
puma560 = import_puma_560()
6352
puma560.move_base(vector(1, 1, 0))
6453

65-
"""
66-
puma560.set_reference_visibility(False)
67-
puma560.print_joint_angles(True)
68-
69-
sleep(2)
70-
puma560.set_joint_angle(4, radians(35))
71-
72-
sleep(2)
73-
puma560.set_joint_angle(2, radians(-56))
74-
75-
sleep(2)
76-
puma560.set_joint_angle(0, radians(78))
77-
78-
sleep(2)
79-
puma560.set_all_joint_angles([
80-
0, 0, 0, 0, 0, 0, 0
81-
])
82-
83-
84-
sleep(2)
85-
puma560.set_all_joint_angles([
86-
radians(45), 0, 0, 0, 0, 0, 0,
87-
])
88-
89-
sleep(2)
90-
puma560.set_all_joint_angles([
91-
radians(45), 0, radians(-90), 0, 0, 0, 0,
92-
])
93-
94-
sleep(2)
95-
puma560.set_joint_angle(4, radians(156))
96-
97-
sleep(2)
98-
puma560.set_joint_angle(2, radians(-23))
99-
100-
101-
puma560.print_joint_angles(True)
102-
"""
103-
10454

10555
def test_rotational_link():
56+
"""
57+
This test will create a simple rotational link from (0, 0, 0) to (1, 0, 0).
58+
Depending on which for loop is commented out:
59+
The joint will then rotate in a positive direction about it's +y axis.
60+
OR
61+
The joint will rotate to the given angles in the list.
62+
"""
10663
canvas_grid = init_canvas()
10764
# rot = vector(0, 0, 1)
10865
rot = vector(0, 1, 0)
@@ -113,23 +70,62 @@ def test_rotational_link():
11370

11471
# for angle in [0, 45, 90, 135, 180, -135, -90, -45, 33, -66, -125, 162, 360, 450, -270, -333]:
11572
# sleep(5)
73+
# rot_link.rotate_joint(radians(angle))
74+
11675
for angle in range(0, 360):
11776
sleep(0.05)
11877
rot_link.rotate_joint(radians(angle))
11978

12079

121-
def test_graphical_robot():
80+
def test_graphical_robot_creation():
81+
"""
82+
This test will create a simple 3-link graphical robot.
83+
The joints are then set to particular angles to show rotations.
84+
"""
12285
canvas_grid = init_canvas()
12386

12487
x = GraphicalRobot([
125-
RotationalJoint(vector(0, 0, 0), vector(1, 1, 1))
88+
RotationalJoint(vector(0, 0, 0), vector(1, 0, 0)),
89+
RotationalJoint(vector(1, 0, 0), vector(2, 0, 0)),
90+
RotationalJoint(vector(2, 0, 0), vector(3, 0, 0))
12691
])
12792

128-
x.set_joint_angle(0, radians(20))
93+
sleep(2)
94+
x.set_all_joint_angles([radians(-45), radians(45), radians(15)])
12995

13096

131-
def test_place_joint():
132-
pass
97+
def test_puma560_angle_change():
98+
"""
99+
This test loads in the Puma560 model and changes its angles over time.
100+
Joint angles are printed for validation.
101+
"""
102+
canvas_grid = init_canvas()
103+
104+
puma560 = import_puma_560()
105+
puma560.move_base(vector(1, 1, 0))
106+
107+
puma560.set_reference_visibility(False)
108+
print("Prior Angles")
109+
puma560.print_joint_angles(True)
110+
111+
sleep(2)
112+
puma560.set_all_joint_angles([
113+
radians(45), 0, 0, 0, 0, 0, 0,
114+
])
115+
116+
sleep(2)
117+
puma560.set_all_joint_angles([
118+
radians(45), 0, radians(-90), 0, 0, 0, 0,
119+
])
120+
121+
sleep(2)
122+
puma560.set_joint_angle(4, radians(156))
123+
124+
sleep(2)
125+
puma560.set_joint_angle(2, radians(-23))
126+
127+
print("Final Angles")
128+
puma560.print_joint_angles(True)
133129

134130

135131
def test_animate_joints():

0 commit comments

Comments
 (0)