|
4 | 4 | from roboticstoolbox.robot.Link import *
|
5 | 5 | from spatialmath.pose3d import *
|
6 | 6 | from scipy.optimize import minimize
|
| 7 | +from graphics.graphics_test_features import * |
7 | 8 |
|
8 | 9 | class SerialLink:
|
9 | 10 |
|
@@ -95,7 +96,7 @@ def fkine(self, jointconfig, unit='rad', alltout=False):
|
95 | 96 | t[k] = tt * SE3(self.tool)
|
96 | 97 |
|
97 | 98 | if alltout:
|
98 |
| - return t, allt |
| 99 | + return allt |
99 | 100 | else:
|
100 | 101 | return t
|
101 | 102 |
|
@@ -128,26 +129,24 @@ def objective(x):
|
128 | 129 | else:
|
129 | 130 | return sol.x
|
130 | 131 |
|
| 132 | + def plot(self, jointconfig, unit='rad'): |
| 133 | + |
| 134 | + if type(jointconfig) == list: |
| 135 | + jointconfig = argcheck.getvector(jointconfig) |
| 136 | + if unit == 'deg': |
| 137 | + jointconfig = jointconfig * pi / 180 |
| 138 | + if jointconfig.size == self.length: |
| 139 | + poses = self.fkine(jointconfig, unit, alltout=True) |
| 140 | + t = list(range(len(poses))) |
| 141 | + for i in range(len(poses)): |
| 142 | + t[i] = poses[i].t |
| 143 | + # add the base |
| 144 | + t.insert(0, SE3(self.base).t) |
| 145 | + grjoints = list(range(len(t))) |
131 | 146 |
|
| 147 | + canvas_grid = init_canvas() |
132 | 148 |
|
133 |
| - def plot(self, jointconfig, unit='rad'): |
| 149 | + 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])) |
134 | 151 |
|
135 |
| - # if type(jointconfig) == list: |
136 |
| - # jointconfig = argcheck.getvector(jointconfig) |
137 |
| - # if unit == 'deg': |
138 |
| - # jointconfig = jointconfig * pi / 180 |
139 |
| - # # if no trajectory joint config just call fkine for pose |
140 |
| - # if jointconfig.size == self.length: |
141 |
| - # endpose = self.fkine(jointconfig, unit, alltout=True) |
142 |
| - # else: |
143 |
| - # assert jointconfig.shape[1] == self.length, "joinconfig must have {self.length} columns" |
144 |
| - # t = list(range(0, jointconfig.shape[0])) |
145 |
| - # |
146 |
| - # for j in range(jointconfig.shape[1]): |
147 |
| - # jset = jointconfig[:, j] |
148 |
| - # for k in range(jointconfig.shape[0]): |
149 |
| - # row = jointconfig[k, :] |
150 |
| - # tt = SE3(self.base) |
151 |
| - # for i in range(self.length): |
152 |
| - # tt = tt * self.links[i].A(row[i]) |
153 |
| - # t[k] = tt * SE3(self.tool) |
| 152 | + x = GraphicalRobot(grjoints) |
0 commit comments