8000 Merge pull request #35 from petercorke/micah-dev · lordkeks/robotics-toolbox-python@e145bd9 · GitHub
[go: up one dir, main page]

Skip to content

Commit e145bd9

Browse files
authored
Merge pull request petercorke#35 from petercorke/micah-dev
Micah dev -> testing functionality
2 parents ca51ef5 + b1c4e20 commit e145bd9

File tree

2 files changed

+77
-70
lines changed

2 files changed

+77
-70
lines changed

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ This is a Python implementation of the [Robotics Toolbox for MATLAB<sup>&reg;</s
1414

1515
* GitHub repository [https://github.com/petercorke/robotics-toolbox-python](https://github.com/petercorke/robotics-toolbox-python)
1616
* Documentation [https://petercorke.github.io/robotics-toolbox-python](https://petercorke.github.io/robotics-toolbox-python)
17-
* Dependencies: `spatialmath-python`, `numpy`
17+
* Dependencies: `spatialmath-python`, `numpy`, `vpython`
1818

1919
# Getting going
2020

graphics/graphics_test_features.py renamed to tests/graphics_test_features.py

Lines changed: 76 additions & 69 deletions
Original file line numberDiff line numberDiff line change
@@ -1,108 +1,76 @@
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+
112
from graphics.model_puma560 import *
213

314

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+
"""
520
canvas_grid = init_canvas()
621
while True:
722
sleep(1)
823
canvas_grid.update_grid()
9-
print("XY:", canvas_grid.grid_object[0].pos)
1024

1125

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+
"""
1431
canvas_grid = init_canvas()
1532

1633
# Test 1 | Position (0, 0, 0), Axis (1, 0, 0), No Rotation
17-
# Drawn
1834
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)
2135

2236
# Test 2 | Position (1, 1, 1), Axis (0, 0, 1), No Rotation
23-
# Drawn
2437
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)
2738

2839
# Test 3 | Position (2, 2, 2), Axis (1, 0, 0), 30 deg rot
29-
# Drawn
3040
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))
3341

3442
# Test 4 | Position (3, 3, 3), Axis (1, 1, 1), No Rotation
35-
# Drawn
3643
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)
3944

4045
# Test 5 | Position (4, 4, 4), Axis (1, 1, 1), 30 deg rot
41-
# Drawn
4246
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))
4547

4648
# Test 6 | Position (5, 5, 5), Axis (2, -1, 4), No Rotation
47-
# Drawn
4849
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)
5150

5251
# Test 7 | Position (6, 6, 6), Axis (2, -1, 4), 30 deg rot
53-
# Drawn
5452
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))
5753

5854

5955
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+
"""
6060
canvas_grid = init_canvas()
6161

6262
puma560 = import_puma_560()
6363
puma560.move_base(vector(1, 1, 0))
6464

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-
10465

10566
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+
"""
10674
canvas_grid = init_canvas()
10775
# rot = vector(0, 0, 1)
10876
rot = vector(0, 1, 0)
@@ -113,23 +81,62 @@ def test_rotational_link():
11381

11482
# for angle in [0, 45, 90, 135, 180, -135, -90, -45, 33, -66, -125, 162, 360, 450, -270, -333]:
11583
# sleep(5)
84+
# rot_link.rotate_joint(radians(angle))
85+
11686
for angle in range(0, 360):
11787
sleep(0.05)
11888
rot_link.rotate_joint(radians(angle))
11989

12090

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+
"""
12296
canvas_grid = init_canvas()
12397

12498
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))
126102
])
127103

128-
x.set_joint_angle(0, radians(20))
104+
sleep(2)
105+
x.set_all_joint_angles([radians(-45), radians(45), radians(15)])
129106

130107

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)
133140

134141

135142
def test_animate_joints():

0 commit comments

Comments
 (0)
0