Skip to content

Commit ff34211

Browse files
committed
Add check that when using non-stl seriallink, that the base pose is ignored when using poses from fkine
1 parent 0d4e062 commit ff34211

File tree

1 file changed

+12
-1
lines changed

1 file changed

+12
-1
lines changed

graphics/graphics_robot.py

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
from graphics.common_functions import *
44
from graphics.graphics_stl import set_stl_origin, import_object_from_numpy_stl
55
from time import perf_counter
6+
from spatialmath import SE3
67

78

89
class DefaultJoint:
@@ -581,7 +582,9 @@ def __init__(self, graphics_canvas, name, seriallink=None):
581582
zero_angles = [0] * len(self.seriallink.links)
582583
all_poses = self.seriallink.fkine(zero_angles, alltout=True)
583584
# Create the base
584-
self.append_link("s", all_poses[0], str(seriallink.basemesh), [0, 0], 0)
585+
if seriallink.basemesh is not None:
586+
self.append_link("s", all_poses[0], str(seriallink.basemesh), [0, 0], 0)
587+
# else: assume no base joint
585588
# Create the joints
586589
i = 0
587590
for link in self.seriallink.links:
@@ -727,6 +730,14 @@ def set_joint_poses(self, all_poses):
727730
if self.num_joints == 0:
728731
raise UserWarning("Robot has 0 joints. Create some using append_link()")
729732

733+
# If given a base pose, when there isn't one
734+
if self.num_joints == len(all_poses) - 1 and all_poses[0] == SE3():
735+
# Update the joints
736+
for idx in range(self.num_joints):
737+
self.joints[idx].update_pose(all_poses[idx+1])
738+
return
739+
740+
# If incorrect number of joints
730741
if self.num_joints != len(all_poses):
731742
err = "Number of given poses {0} does not equal number of joints {1}"
732743
raise UserWarning(err.format(len(all_poses), self.num_joints))

0 commit comments

Comments
 (0)