Skip to content

Commit 0d4e062

Browse files
committed
Updated to draw correct STLs for each joint, and apply fkine when sliders change.
1 parent 6cb95a4 commit 0d4e062

File tree

4 files changed

+38
-31
lines changed

4 files changed

+38
-31
lines changed

graphics/graphics_canvas.py

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -453,6 +453,9 @@ def __setup_joint_sliders(self):
453453
"""
454454
i = 1
455455
for joint in self.__teachpanel[self.__selected_robot]:
456+
if joint[self.__idx_qlim_min] == joint[self.__idx_qlim_max]:
457+
# If a slider with (effectively) no values, skip it
458+
continue
456459
# Add a title
457460
self.scene.append_to_caption('Joint {0}:\t'.format(i))
458461
i += 1
@@ -597,12 +600,11 @@ def __joint_slider(self, s):
597600

598601
# Get all angles for the robot
599602
angles = []
600-
for joint_slider in self.__teachpanel_sliders:
601-
angles.append(joint_slider.value)
603+
for idx in range(len(self.__teachpanel_sliders)):
604+
angles.append(self.__teachpanel_sliders[idx].value)
602605

603606
# Run fkine
604607
poses = self.__robots[self.__selected_robot].fkine(angles)
605-
poses = poses[1:len(poses)] # Ignore the first item
606608

607609
# Update joints
608610
self.__robots[self.__selected_robot].set_joint_poses(poses)

graphics/graphics_robot.py

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -580,12 +580,14 @@ def __init__(self, graphics_canvas, name, seriallink=None):
580580
# Get initial poses
581581
zero_angles = [0] * len(self.seriallink.links)
582582
all_poses = self.seriallink.fkine(zero_angles, alltout=True)
583+
# Create the base
584+
self.append_link("s", all_poses[0], str(seriallink.basemesh), [0, 0], 0)
583585
# Create the joints
584586
i = 0
585587
for link in self.seriallink.links:
586588
# Get info
587589
j_type = link.jointtype # Type of
588-
pose = all_poses[i] # Pose
590+
pose = all_poses[i+1] # Pose
589591
if link.mesh is None:
590592
x1, x2 = all_poses[i].t[0], all_poses[i + 1].t[0]
591593
y1, y2 = all_poses[i].t[1], all_poses[i + 1].t[1]
@@ -725,9 +727,9 @@ def set_joint_poses(self, all_poses):
725727
if self.num_joints == 0:
726728
raise UserWarning("Robot has 0 joints. Create some using append_link()")
727729

728-
# if self.num_joints != len(all_poses):
729-
# err = "Number of given poses {0} does not equal number of joints {1}"
730-
# raise UserWarning(err.format(len(all_poses), self.num_joints))
730+
if self.num_joints != len(all_poses):
731+
err = "Number of given poses {0} does not equal number of joints {1}"
732+
raise UserWarning(err.format(len(all_poses), self.num_joints))
731733

732734
# Update the joints
733735
for idx in range(self.num_joints):

roboticstoolbox/robot/serial_link.py

Lines changed: 6 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -185,17 +185,14 @@ def plot(self, jointconfig, unit='rad'):
185185

186186
if self.roplot is None:
187187
# No current plot, create robot plot
188+
self.g_canvas = gph.GraphicsCanvas3D()
189+
print("canvas created")
188190

189-
self.g_canvas = gph.GraphicsCanvas3D()
190-
print("canvas created")
191+
self.roplot = gph.GraphicalRobot(self.g_canvas, self.name, self)
191192

192-
self.roplot = gph.GraphicalRobot(self.g_canvas, self.name, self)
193-
194-
return
195-
else:
196-
# Move existing plot
197-
self.roplot.set_joint_poses(poses)
198-
return
193+
# Move existing plot
194+
self.roplot.set_joint_poses(poses)
195+
return
199196

200197
def animate(self, q1, q2, unit='rad', frames=10, fps=5):
201198
"""

tests/_test_teachpanel.py

Lines changed: 21 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,22 +1,28 @@
11
import graphics as gph
22
from roboticstoolbox.robot.serial_link import SerialLink, Link
3+
from roboticstoolbox.models.Puma560 import Puma560
34

45
if __name__ == "__main__":
5-
canvas = gph.GraphicsCanvas3D()
66

7-
L = []
8-
L2 = []
7+
puma = Puma560()
98

10-
L.append(Link(a=1, jointtype='R'))
11-
L.append(Link(a=1, jointtype='R'))
12-
L.append(Link(a=1, jointtype='R'))
9+
puma.plot(puma.qz)
1310

14-
L2.append(Link(a=1, jointtype='R'))
15-
L2.append(Link(a=1, jointtype='R'))
16-
L2.append(Link(a=1, jointtype='R'))
17-
18-
tl = SerialLink(L, name='R1')
19-
tl2 = SerialLink(L, name='R2')
20-
21-
robot = gph.GraphicalRobot(canvas, '', seriallink=tl)
22-
robot2 = gph.GraphicalRobot(canvas, '', seriallink=tl2)
11+
# canvas = gph.GraphicsCanvas3D()
12+
#
13+
# L = []
14+
# L2 = []
15+
#
16+
# L.append(Link(a=1, jointtype='R'))
17+
# L.append(Link(a=1, jointtype='R'))
18+
# L.append(Link(a=1, jointtype='R'))
19+
#
20+
# L2.append(Link(a=1, jointtype='R'))
21+
# L2.append(Link(a=1, jointtype='R'))
22+
# L2.append(Link(a=1, jointtype='R'))
23+
#
24+
# tl = SerialLink(L, name='R1')
25+
# tl2 = SerialLink(L, name='R2')
26+
#
27+
# robot = gph.GraphicalRobot(canvas, '', seriallink=tl)
28+
# robot2 = gph.GraphicalRobot(canvas, '', seriallink=tl2)

0 commit comments

Comments
 (0)