1
1
from graphics .model_puma560 import *
2
2
3
3
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
+ """
5
9
canvas_grid = init_canvas ()
6
10
while True :
7
11
sleep (1 )
8
12
canvas_grid .update_grid ()
9
- print ("XY:" , canvas_grid .grid_object [0 ].pos )
10
13
11
14
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
+ """
14
20
canvas_grid = init_canvas ()
15
21
16
22
# Test 1 | Position (0, 0, 0), Axis (1, 0, 0), No Rotation
17
- # Drawn
18
23
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
24
22
25
# Test 2 | Position (1, 1, 1), Axis (0, 0, 1), No Rotation
23
- # Drawn
24
26
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
27
28
28
# Test 3 | Position (2, 2, 2), Axis (1, 0, 0), 30 deg rot
29
- # Drawn
30
29
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
30
34
31
# Test 4 | Position (3, 3, 3), Axis (1, 1, 1), No Rotation
35
- # Drawn
36
32
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
33
40
34
# Test 5 | Position (4, 4, 4), Axis (1, 1, 1), 30 deg rot
41
- # Drawn
42
35
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
36
46
37
# Test 6 | Position (5, 5, 5), Axis (2, -1, 4), No Rotation
47
- # Drawn
48
38
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
39
52
40
# Test 7 | Position (6, 6, 6), Axis (2, -1, 4), 30 deg rot
53
- # Drawn
54
41
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
42
58
43
59
44
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
+ """
60
49
canvas_grid = init_canvas ()
61
50
62
51
puma560 = import_puma_560 ()
63
52
puma560 .move_base (vector (1 , 1 , 0 ))
64
53
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
54
105
55
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
+ """
106
63
canvas_grid = init_canvas ()
107
64
# rot = vector(0, 0, 1)
108
65
rot = vector (0 , 1 , 0 )
@@ -113,23 +70,62 @@ def test_rotational_link():
113
70
114
71
# for angle in [0, 45, 90, 135, 180, -135, -90, -45, 33, -66, -125, 162, 360, 450, -270, -333]:
115
72
# sleep(5)
73
+ # rot_link.rotate_joint(radians(angle))
74
+
116
75
for angle in range (0 , 360 ):
117
76
sleep (0.05 )
118
77
rot_link .rotate_joint (radians (angle ))
119
78
120
79
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
+ """
122
85
canvas_grid = init_canvas ()
123
86
124
87
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 ))
126
91
])
127
92
128
- x .set_joint_angle (0 , radians (20 ))
93
+ sleep (2 )
94
+ x .set_all_joint_angles ([radians (- 45 ), radians (45 ), radians (15 )])
129
95
130
96
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 )
133
129
134
130
135
131
def test_animate_joints ():
0 commit comments