|
3 | 3 | from graphics.common_functions import *
|
4 | 4 | from graphics.graphics_stl import set_stl_origin, import_object_from_numpy_stl
|
5 | 5 | from time import perf_counter
|
| 6 | +from spatialmath import SE3 |
6 | 7 |
|
7 | 8 |
|
8 | 9 | class DefaultJoint:
|
@@ -581,7 +582,9 @@ def __init__(self, graphics_canvas, name, seriallink=None):
|
581 | 582 | zero_angles = [0] * len(self.seriallink.links)
|
582 | 583 | all_poses = self.seriallink.fkine(zero_angles, alltout=True)
|
583 | 584 | # 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 |
585 | 588 | # Create the joints
|
586 | 589 | i = 0
|
587 | 590 | for link in self.seriallink.links:
|
@@ -727,6 +730,14 @@ def set_joint_poses(self, all_poses):
|
727 | 730 | if self.num_joints == 0:
|
728 | 731 | raise UserWarning("Robot has 0 joints. Create some using append_link()")
|
729 | 732 |
|
| 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 |
730 | 741 | if self.num_joints != len(all_poses):
|
731 | 742 | err = "Number of given poses {0} does not equal number of joints {1}"
|
732 | 743 | raise UserWarning(err.format(len(all_poses), self.num_joints))
|
|
0 commit comments