1
+ """
2
+ These functions are not ordinary testing functions.
3
+ These tests cannot be automated, and must be manually validated.
4
+
5
+ To execute, import all from this file into the console. "from graphics.graphics_test_features import *"
6
+ Next select which test you which to run, and call the function.
7
+ A canvas will be created and display the respective graphics.
8
+ Verify the output is as expected.
9
+ Then close the browser window and run a different function. (Help clear graphics. Currently, no clearing implemented)
10
+ """
11
+
1
12
from graphics .model_puma560 import *
2
13
3
14
4
- def test_grid ():
15
+ def test_grid_updating ():
16
+ """
17
+ This test will create a canvas and update the grid every second.
18
+ Eventually, the grid will only update through callbacks of key/button releases.
19
+ """
5
20
canvas_grid = init_canvas ()
6
21
while True :
7
22
sleep (1 )
8
23
canvas_grid .update_grid ()
9
- print ("XY:" , canvas_grid .grid_object [0 ].pos )
10
24
11
25
12
- def test_reference_frames ():
13
- le = 0.2
26
+ def test_reference_frame_pose ():
27
+ """
28
+ This test will create a canvas, and place reference frames at the given positions and orientations.
29
+ Each frame must be manually inspected for validity.
30
+ """
14
31
canvas_grid = init_canvas ()
15
32
16
33
# Test 1 | Position (0, 0, 0), Axis (1, 0, 0), No Rotation
17
- # Drawn
18
34
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)
21
35
22
36
# Test 2 | Position (1, 1, 1), Axis (0, 0, 1), No Rotation
23
- # Drawn
24
37
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)
27
38
28
39
# Test 3 | Position (2, 2, 2), Axis (1, 0, 0), 30 deg rot
29
- # Drawn
30
40
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))
33
41
34
42
# Test 4 | Position (3, 3, 3), Axis (1, 1, 1), No Rotation
35
- # Drawn
36
43
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)
39
44
40
45
# Test 5 | Position (4, 4, 4), Axis (1, 1, 1), 30 deg rot
41
- # Drawn
42
46
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))
45
47
46
48
# Test 6 | Position (5, 5, 5), Axis (2, -1, 4), No Rotation
47
- # Drawn
48
49
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)
51
50
52
51
# Test 7 | Position (6, 6, 6), Axis (2, -1, 4), 30 deg rot
53
- # Drawn
54
52
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))
57
53
58
54
59
55
def test_import_stl ():
56
+ """
57
+ This test will create a canvas with the Puma560 model loaded in.
58
+ The robot should have all joint angles to 0 (Robot is in an 'L' shape from (1, 1, 0) in the +X axis direction)
59
+ """
60
60
canvas_grid = init_canvas ()
61
61
62
62
puma560 = import_puma_560 ()
63
63
puma560 .move_base (vector (1 , 1 , 0 ))
64
64
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
-
104
65
105
66
def test_rotational_link ():
67
+ """
68
+ This test will create a simple rotational link from (0, 0, 0) to (1, 0, 0).
69
+ Depending on which for loop is commented out:
70
+ The joint will then rotate in a positive direction about it's +y axis.
71
+ OR
72
+ The joint will rotate to the given angles in the list.
73
+ """
106
74
canvas_grid = init_canvas ()
107
75
# rot = vector(0, 0, 1)
108
76
rot = vector (0 , 1 , 0 )
@@ -113,23 +81,62 @@ def test_rotational_link():
113
81
114
82
# for angle in [0, 45, 90, 135, 180, -135, -90, -45, 33, -66, -125, 162, 360, 450, -270, -333]:
115
83
# sleep(5)
84
+ # rot_link.rotate_joint(radians(angle))
85
+
116
86
for angle in range (0 , 360 ):
117
87
sleep (0.05 )
118
88
rot_link .rotate_joint (radians (angle ))
119
89
120
90
121
- def test_graphical_robot ():
91
+ def test_graphical_robot_creation ():
92
+ """
93
+ This test will create a simple 3-link graphical robot.
94
+ The joints are then set to particular angles to show rotations.
95
+ """
122
96
canvas_grid = init_canvas ()
123
97
124
98
x = GraphicalRobot ([
125
- RotationalJoint (vector (0 , 0 , 0 ), vector (1 , 1 , 1 ))
99
+ RotationalJoint (vector (0 , 0 , 0 ), vector (1 , 0 , 0 )),
100
+ RotationalJoint (vector (1 , 0 , 0 ), vector (2 , 0 , 0 )),
101
+ RotationalJoint (vector (2 , 0 , 0 ), vector (3 , 0 , 0 ))
126
102
])
127
103
128
- x .set_joint_angle (0 , radians (20 ))
104
+ sleep (2 )
105
+ x .set_all_joint_angles ([radians (- 45 ), radians (45 ), radians (15 )])
129
106
130
107
131
- def test_place_joint ():
132
- pass
108
+ def test_puma560_angle_change ():
109
+ """
110
+ This test loads in the Puma560 model and changes its angles over time.
111
+ Joint angles are printed for validation.
112
+ """
113
+ canvas_grid = init_canvas ()
114
+
115
+ puma560 = import_puma_560 ()
116
+ puma560 .move_base (vector (1 , 1 , 0 ))
117
+
118
+ puma560 .set_reference_visibility (False )
119
+ print ("Prior Angles" )
120
+ puma560 .print_joint_angles (True )
121
+
122
+ sleep (2 )
123
+ puma560 .set_all_joint_angles ([
124
+ radians (45 ), 0 , 0 , 0 , 0 , 0 , 0 ,
125
+ ])
126
+
127
+ sleep (2 )
128
+ puma560 .set_all_joint_angles ([
129
+ radians (45 ), 0 , radians (- 90 ), 0 , 0 , 0 , 0 ,
130
+ ])
131
+
132
+ sleep (2 )
133
+ puma560 .set_joint_angle (4 , radians (156 ))
134
+
135
+ sleep (2 )
136
+ puma560 .set_joint_angle (2 , radians (- 23 ))
137
+
138
+ print ("Final Angles" )
139
+ puma560 .print_joint_angles (True )
133
140
134
141
135
142
def test_animate_joints ():
0 commit comments