8000 Added uprighttl · lordkeks/robotics-toolbox-python@a1cc4f7 · GitHub
[go: up one dir, main page]

Skip to content

Commit a1cc4f7

Browse files
committed
Added uprighttl
Fixed serial link plot and added example code to create and plot an upright 3-link arm
1 parent 3e221a4 commit a1cc4f7

File tree

5 files changed

+67
-13
lines changed

5 files changed

+67
-13
lines changed

roboticstoolbox/robot/Link.py

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,6 @@
11
"""
22
Link object.
3-
Python implementation by: Luis Fernando Lara Tobar and Peter Corke.
4-
Based on original Robotics Toolbox for Matlab code by Peter Corke.
5-
Permission to use and copy is granted provided that acknowledgement of
6-
the authors is made.
7-
@author: Luis Fernando Lara Tobar and Peter Corke
3+
Python implementation by Samuel Drew
84
"""
95

106
from numpy import *
@@ -19,8 +15,8 @@ class Link(list):
1915

2016
def __init__(self, *argv):
2117
"""
22-
%Link Create robot link object
23-
%
18+
Link Create robot link object
19+
2420
% This the class constructor which has several call signatures.
2521
%
2622
% L = Link() is a Link object with default parameters.

roboticstoolbox/robot/serial_link.py

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -130,7 +130,12 @@ def objective(x):
130130
return sol.x
131131

132132
def plot(self, jointconfig, unit='rad'):
133-
133+
"""
134+
Creates a 3D plot of the robot in your web browser
135+
:param jointconfig: takes an array or list of joint angles
136+
:param unit: unit of angles. radians if not defined
137+
:return: a vpython robot object.
138+
"""
134139
if type(jointconfig) == list:
135140
jointconfig = argcheck.getvector(jointconfig)
136141
if unit == 'deg':
@@ -142,11 +147,13 @@ def plot(self, jointconfig, unit='rad'):
142147
t[i] = poses[i].t
143148
# add the base
144149
t.insert(0, SE3(self.base).t)
145-
grjoints = list(range(len(t)))
150+
grjoints = list(range(len(t)-1))
146151

147152
canvas_grid = init_canvas()
148153

149154
for i in range(1, len(t)):
150-
grjoints[i] = RotationalJoint(vector(t[i-1][0], t[i-1][1], t[i-1][2]), vector(t[i][0], t[i][1], t[i][2]))
151-
155+
grjoints[i-1] = RotationalJoint(vector(t[i-1][0], t[i-1][1], t[i-1][2]), vector(t[i][0], t[i][1], t[i][2]))
156+
print(grjoints)
152157
x = GraphicalRobot(grjoints)
158+
159+
return x

roboticstoolbox/robot/threelink.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
"""
2-
Defines the object 'robot' in the current workspace
2+
Defines the object 'tl' in the current workspace
33
4-
Also define the vector q = [0 0 0] which corresponds to the zero joint
4+
Also define the vector qz = [0 0 0] which corresponds to the zero joint
55
angle configuration.
66
77
@author: Luis Fernando Lara Tobar and Peter Corke

roboticstoolbox/robot/uprighttl.py

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
"""
2+
Defines the object 'arm' in the current workspace
3+
4+
Also define the vector qz = [pi/4,0,-pi/3]
5+
"""
6+
7+
from roboticstoolbox.robot.serial_link import *
8+
9+
L = []
10+
11+
L.append(Link('a', 0.1, 'd', 1, 'alpha', pi/2, 'type', 'revolute'))
12+
L.append(Link('a', 1, 'type', 'revolute'))
13+
L.append(Link('a', 0.5, 'type', 'revolute'))
14+
15+
16+
qz = [pi/4,0,-pi/3]
17+
18+
arm = SerialLink(L, name='Upright Arm')
19+

tests/Sam1.py

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
"""
2+
NOT A UNIT TEST
3+
Simple Example for Serial_link plot function
4+
Starts by creating a robot arm.
5+
uncomment and copy code to console as needed
6+
"""
7+
8+
from roboticstoolbox.robot.serial_link import *
9+
10+
L = []
11+
12+
# create links
13+
L.append(Link('a', 0.1, 'd', 1, 'alpha', pi/2, 'type', 'revolute'))
14+
L.append(Link('a', 1, 'type', 'revolute'))
15+
L.append(Link('a', 0.5, 'type', 'revolute'))
16+
17+
# create initial joint array to be passed into plot as joint configuration
18+
qz = [pi/4,0,-pi/3]
19+
20+
# create serial link robot
21+
arm = SerialLink(L, name='Upright Arm')
22+
23+
# plot robot
24+
plotbot = arm.plot(qz)
25+
26+
## Use this code to change the joint angles
27+
## lift arm
28+
# plotbot.set_joint_angle(1, -pi/2)
29+
30+
## rotate base:
31+
# plotbot.set_joint_angle(0, pi/2)
32+

0 commit comments

Comments
 (0)
0