blob: 7614390493e3b2bf4833145a16e33c74317e830b [file] [log] [blame]
milind-u18a901d2023-02-17 21:51:55 -08001import abc
2import numpy as np
3import sys
4import traceback
Maxwell Hendersonf5123fe2023-02-04 13:44:41 -08005
6# joint_center in x-y space.
milind-u18a901d2023-02-17 21:51:55 -08007IN_TO_M = 0.0254
8joint_center = (-0.203, 0.787)
Maxwell Hendersonf5123fe2023-02-04 13:44:41 -08009
10# Joint distances (l1 = "proximal", l2 = "distal")
milind-u18a901d2023-02-17 21:51:55 -080011l1 = 20.0 * IN_TO_M
12l2 = 31.5 * IN_TO_M
Maxwell Hendersonf5123fe2023-02-04 13:44:41 -080013
14max_dist = 0.01
milind-u18a901d2023-02-17 21:51:55 -080015max_dist_theta = np.pi / 64
Maxwell Hendersonf5123fe2023-02-04 13:44:41 -080016xy_end_circle_size = 0.01
17theta_end_circle_size = 0.07
18
19
milind-u060e4cf2023-02-22 00:08:52 -080020# Shift the angle between the convention used for input/output and the convention we use for some computations here
21def shift_angle(theta):
22 return np.pi / 2 - theta
23
24
25def shift_angles(thetas):
26 return [shift_angle(theta) for theta in thetas]
27
28
Maxwell Hendersonf5123fe2023-02-04 13:44:41 -080029# Convert from x-y coordinates to theta coordinates.
30# orientation is a bool. This orientation is circular_index mod 2.
31# where circular_index is the circular index, or the position in the
32# "hyperextension" zones. "cross_point" allows shifting the place where
33# it rounds the result so that it draws nicer (no other functional differences).
milind-u600738b2023-02-22 14:42:19 -080034def to_theta(pt, circular_index, cross_point=-np.pi, die=True):
Maxwell Hendersonf5123fe2023-02-04 13:44:41 -080035 orient = (circular_index % 2) == 0
36 x = pt[0]
37 y = pt[1]
38 x -= joint_center[0]
39 y -= joint_center[1]
milind-u18a901d2023-02-17 21:51:55 -080040 l3 = np.hypot(x, y)
41 t3 = np.arctan2(y, x)
42 theta1 = np.arccos((l1**2 + l3**2 - l2**2) / (2 * l1 * l3))
43 if np.isnan(theta1):
milind-u600738b2023-02-22 14:42:19 -080044 print(("Couldn't fit triangle to %f, %f, %f" % (l1, l2, l3)))
45 if die:
46 traceback.print_stack()
47 sys.exit(1)
48 return None
Maxwell Hendersonf5123fe2023-02-04 13:44:41 -080049
50 if orient:
51 theta1 = -theta1
52 theta1 += t3
milind-u18a901d2023-02-17 21:51:55 -080053 theta1 = (theta1 - cross_point) % (2 * np.pi) + cross_point
54 theta2 = np.arctan2(y - l1 * np.sin(theta1), x - l1 * np.cos(theta1))
55 return np.array((theta1, theta2))
Maxwell Hendersonf5123fe2023-02-04 13:44:41 -080056
57
58# Simple trig to go back from theta1, theta2 to x-y
59def to_xy(theta1, theta2):
milind-u18a901d2023-02-17 21:51:55 -080060 x = np.cos(theta1) * l1 + np.cos(theta2) * l2 + joint_center[0]
61 y = np.sin(theta1) * l1 + np.sin(theta2) * l2 + joint_center[1]
62 orient = ((theta2 - theta1) % (2.0 * np.pi)) < np.pi
Maxwell Hendersonf5123fe2023-02-04 13:44:41 -080063 return (x, y, orient)
64
65
milind-u18a901d2023-02-17 21:51:55 -080066END_EFFECTOR_X_LEN = (-1.0 * IN_TO_M, 10.425 * IN_TO_M)
67END_EFFECTOR_Y_LEN = (-4.875 * IN_TO_M, 7.325 * IN_TO_M)
68END_EFFECTOR_Z_LEN = (-11.0 * IN_TO_M, 11.0 * IN_TO_M)
69
70
71def abs_sum(l):
72 result = 0
73 for e in l:
74 result += abs(e)
75 return result
76
77
78def affine_3d(R, T):
79 H = np.eye(4)
80 H[:3, 3] = T
81 H[:3, :3] = R
82 return H
83
84
85# Simple trig to go back from theta1, theta2, and theta3 to
86# the 8 corners on the roll joint x-y-z
87def to_end_effector_points(theta1, theta2, theta3):
88 x, y, _ = to_xy(theta1, theta2)
89 # Homogeneous end effector points relative to the end_effector
90 # ee = end effector
91 endpoints_ee = []
92 for i in range(2):
93 for j in range(2):
94 for k in range(2):
95 endpoints_ee.append(
96 np.array((END_EFFECTOR_X_LEN[i], END_EFFECTOR_Y_LEN[j],
97 END_EFFECTOR_Z_LEN[k], 1.0)))
98
99 # Only roll.
100 # rj = roll joint
101 roll = theta3
102 T_rj_ee = np.zeros(3)
103 R_rj_ee = np.array([[1.0, 0.0, 0.0], [0.0,
104 np.cos(roll), -np.sin(roll)],
105 [0.0, np.sin(roll), np.cos(roll)]])
106 H_rj_ee = affine_3d(R_rj_ee, T_rj_ee)
107
108 # Roll joint pose relative to the origin
109 # o = origin
110 T_o_rj = np.array((x, y, 0))
111 # Only yaw
112 yaw = theta1 + theta2
113 R_o_rj = [[np.cos(yaw), -np.sin(yaw), 0.0],
114 [np.sin(yaw), np.cos(yaw), 0.0], [0.0, 0.0, 1.0]]
115 H_o_rj = affine_3d(R_o_rj, T_o_rj)
116
117 # Now compute the pose of the end effector relative to the origin
118 H_o_ee = H_o_rj @ H_rj_ee
119
120 # Get the translation from these transforms
121 endpoints_o = [(H_o_ee @ endpoint_ee)[:3] for endpoint_ee in endpoints_ee]
122
123 diagonal_distance = np.linalg.norm(
124 np.array(endpoints_o[0]) - np.array(endpoints_o[-1]))
125 actual_diagonal_distance = np.linalg.norm(
126 np.array((abs_sum(END_EFFECTOR_X_LEN), abs_sum(END_EFFECTOR_Y_LEN),
127 abs_sum(END_EFFECTOR_Z_LEN))))
128 assert abs(diagonal_distance - actual_diagonal_distance) < 1e-5
129
130 return np.array(endpoints_o)
131
132
133# Returns all permutations of rectangle points given two opposite corners.
134# x is the two x values, y is the two y values, z is the two z values
135def rect_points(x, y, z):
136 points = []
137 for i in range(2):
138 for j in range(2):
139 for k in range(2):
140 points.append((x[i], y[j], z[k]))
141 return np.array(points)
142
143
144DRIVER_CAM_Z_OFFSET = 3.225 * IN_TO_M
145DRIVER_CAM_POINTS = rect_points(
146 (-5.126 * IN_TO_M + joint_center[0], 0.393 * IN_TO_M + joint_center[0]),
147 (5.125 * IN_TO_M + joint_center[1], 17.375 * IN_TO_M + joint_center[1]),
148 (-8.475 * IN_TO_M - DRIVER_CAM_Z_OFFSET,
149 -4.350 * IN_TO_M - DRIVER_CAM_Z_OFFSET))
150
151
152def compute_face_normals(points):
153 # Return the normal vectors of all the faces
154 normals = []
155 for i in range(points.shape[0]):
156 v1 = points[i]
157 v2 = points[(i + 1) % points.shape[0]]
158 normal = np.cross(v1, v2)
159 normals.append(normal)
160 return np.array(normals)
161
162
163def project_points_onto_axis(points, axis):
164 projections = np.dot(points, axis)
165 return np.min(projections), np.max(projections)
166
167
168def roll_joint_collision(theta1, theta2, theta3):
milind-u060e4cf2023-02-22 00:08:52 -0800169 theta1 = shift_angle(theta1)
170 theta2 = shift_angle(theta2)
171 theta3 = shift_angle(theta3)
172
milind-u18a901d2023-02-17 21:51:55 -0800173 end_effector_points = to_end_effector_points(theta1, theta2, theta3)
174
175 assert len(end_effector_points) == 8 and len(end_effector_points[0]) == 3
176 assert len(DRIVER_CAM_POINTS) == 8 and len(DRIVER_CAM_POINTS[0]) == 3
177
178 # Use the Separating Axis Theorem to check for collision
179 end_effector_normals = compute_face_normals(end_effector_points)
180 driver_cam_normals = compute_face_normals(DRIVER_CAM_POINTS)
181
182 collision = True
183 # Check for separating axes
184 for normal in np.concatenate((end_effector_normals, driver_cam_normals)):
185 min_ee, max_ee = project_points_onto_axis(end_effector_points, normal)
186 min_dc, max_dc = project_points_onto_axis(DRIVER_CAM_POINTS, normal)
187 if max_ee < min_dc or min_ee > max_dc:
188 # Separating axis found, rectangles don't intersect
189 collision = False
190 break
191
192 return collision
193
194
milind-ueeb08c52023-02-21 22:30:16 -0800195# Delta limit means theta2 - theta1.
196# The limit for the proximal and distal is relative,
197# so define constraints for this delta.
198UPPER_DELTA_LIMIT = 0.0
199LOWER_DELTA_LIMIT = -1.9 * np.pi
200
201# TODO(milind): put actual proximal limits
202UPPER_PROXIMAL_LIMIT = np.pi * 1.5
203LOWER_PROXIMAL_LIMIT = -np.pi
204
205UPPER_ROLL_JOINT_LIMIT = 0.75 * np.pi
206LOWER_ROLL_JOINT_LIMIT = -0.75 * np.pi
207
208
209def arm_past_limit(theta1, theta2, theta3):
210 delta = theta2 - theta1
211 return (delta > UPPER_DELTA_LIMIT or delta < LOWER_DELTA_LIMIT) or (
212 theta3 > UPPER_ROLL_JOINT_LIMIT or
213 theta3 < LOWER_ROLL_JOINT_LIMIT) or (theta1 > UPPER_PROXIMAL_LIMIT
214 or theta1 < LOWER_PROXIMAL_LIMIT)
215
216
Maxwell Hendersonf5123fe2023-02-04 13:44:41 -0800217def get_circular_index(theta):
milind-u18a901d2023-02-17 21:51:55 -0800218 return int(np.floor((theta[1] - theta[0]) / np.pi))
Maxwell Hendersonf5123fe2023-02-04 13:44:41 -0800219
220
221def get_xy(theta):
milind-u060e4cf2023-02-22 00:08:52 -0800222 theta1 = shift_angle(theta[0])
223 theta2 = shift_angle(theta[1])
milind-u18a901d2023-02-17 21:51:55 -0800224 x = np.cos(theta1) * l1 + np.cos(theta2) * l2 + joint_center[0]
225 y = np.sin(theta1) * l1 + np.sin(theta2) * l2 + joint_center[1]
226 return np.array((x, y))
Maxwell Hendersonf5123fe2023-02-04 13:44:41 -0800227
228
229# Subdivide in theta space.
230def subdivide_theta(lines):
231 out = []
232 last_pt = lines[0]
233 out.append(last_pt)
234 for n_pt in lines[1:]:
235 for pt in subdivide(last_pt, n_pt, max_dist_theta):
236 out.append(pt)
237 last_pt = n_pt
238
239 return out
240
241
Maxwell Hendersonf5123fe2023-02-04 13:44:41 -0800242def to_theta_with_ci(pt, circular_index):
milind-u18a901d2023-02-17 21:51:55 -0800243 return (to_theta_with_circular_index(pt[0], pt[1], circular_index))
Maxwell Hendersonf5123fe2023-02-04 13:44:41 -0800244
245
246# to_theta, but distinguishes between
247def to_theta_with_circular_index(x, y, circular_index):
248 theta1, theta2 = to_theta((x, y), circular_index)
milind-u18a901d2023-02-17 21:51:55 -0800249 n_circular_index = int(np.floor((theta2 - theta1) / np.pi))
250 theta2 = theta2 + ((circular_index - n_circular_index)) * np.pi
milind-u060e4cf2023-02-22 00:08:52 -0800251 return np.array((shift_angle(theta1), shift_angle(theta2)))
milind-u18a901d2023-02-17 21:51:55 -0800252
253
254# to_theta, but distinguishes between
255def to_theta_with_circular_index_and_roll(x, y, roll, circular_index):
256 theta12 = to_theta_with_circular_index(x, y, circular_index)
257 theta3 = roll
258 return np.array((theta12[0], theta12[1], theta3))
Maxwell Hendersonf5123fe2023-02-04 13:44:41 -0800259
260
261# alpha is in [0, 1] and is the weight to merge a and b.
262def alpha_blend(a, b, alpha):
263 """Blends a and b.
264
265 Args:
266 alpha: double, Ratio. Needs to be in [0, 1] and is the weight to blend a
267 and b.
268 """
269 return b * alpha + (1.0 - alpha) * a
270
271
272def normalize(v):
273 """Normalize a vector while handling 0 length vectors."""
milind-u18a901d2023-02-17 21:51:55 -0800274 norm = np.linalg.norm(v)
Maxwell Hendersonf5123fe2023-02-04 13:44:41 -0800275 if norm == 0:
276 return v
277 return v / norm
278
279
Maxwell Hendersonf5123fe2023-02-04 13:44:41 -0800280# Generic subdivision algorithm.
281def subdivide(p1, p2, max_dist):
282 dx = p2[0] - p1[0]
283 dy = p2[1] - p1[1]
milind-u18a901d2023-02-17 21:51:55 -0800284 dist = np.sqrt(dx**2 + dy**2)
285 n = int(np.ceil(dist / max_dist))
Maxwell Hendersonf5123fe2023-02-04 13:44:41 -0800286 return [(alpha_blend(p1[0], p2[0],
287 float(i) / n), alpha_blend(p1[1], p2[1],
288 float(i) / n))
289 for i in range(1, n + 1)]
290
291
Maxwell Hendersonf5123fe2023-02-04 13:44:41 -0800292def spline_eval(start, control1, control2, end, alpha):
293 a = alpha_blend(start, control1, alpha)
294 b = alpha_blend(control1, control2, alpha)
295 c = alpha_blend(control2, end, alpha)
296 return alpha_blend(alpha_blend(a, b, alpha), alpha_blend(b, c, alpha),
297 alpha)
298
299
milind-u18a901d2023-02-17 21:51:55 -0800300SPLINE_SUBDIVISIONS = 100
301
302
303def subdivide_multistep():
Maxwell Hendersonf5123fe2023-02-04 13:44:41 -0800304 # TODO: pick N based on spline parameters? or otherwise change it to be more evenly spaced?
milind-u18a901d2023-02-17 21:51:55 -0800305 for i in range(0, SPLINE_SUBDIVISIONS + 1):
306 yield i / float(SPLINE_SUBDIVISIONS)
Maxwell Hendersonf5123fe2023-02-04 13:44:41 -0800307
308
milind-u18a901d2023-02-17 21:51:55 -0800309def get_proximal_distal_derivs(t_prev, t, t_next):
310 d_prev = normalize(t - t_prev)
311 d_next = normalize(t_next - t)
312 accel = (d_next - d_prev) / np.linalg.norm(t - t_next)
313 return (ThetaPoint(t[0], d_next[0],
314 accel[0]), ThetaPoint(t[1], d_next[1], accel[1]))
315
316
317def get_roll_joint_theta(theta_i, theta_f, t):
318 # Fit a theta(t) = (1 - cos(pi*t)) / 2,
319 # so that theta(0) = theta_i, and theta(1) = theta_f
320 offset = theta_i
321 scalar = (theta_f - theta_i) / 2.0
322 freq = np.pi
323 theta_curve = lambda t: scalar * (1 - np.cos(freq * t)) + offset
324
325 return theta_curve(t)
326
327
328def get_roll_joint_theta_multistep(alpha_rolls, alpha):
329 # Figure out which segment in the motion we're in
330 theta_i = None
331 theta_f = None
332 t = None
333
334 for i in range(len(alpha_rolls) - 1):
335 # Find the alpha segment we're in
336 if alpha_rolls[i][0] <= alpha <= alpha_rolls[i + 1][0]:
337 theta_i = alpha_rolls[i][1]
338 theta_f = alpha_rolls[i + 1][1]
339
340 total_dalpha = alpha_rolls[-1][0] - alpha_rolls[0][0]
341 assert total_dalpha == 1.0
342 dalpha = alpha_rolls[i + 1][0] - alpha_rolls[i][0]
343 t = (alpha - alpha_rolls[i][0]) * (total_dalpha / dalpha)
344 break
345 assert theta_i is not None
346 assert theta_f is not None
347 assert t is not None
348
349 return get_roll_joint_theta(theta_i, theta_f, t)
Maxwell Hendersonf5123fe2023-02-04 13:44:41 -0800350
351
Maxwell Henderson83cf6d62023-02-10 20:29:26 -0800352# Draw a list of lines to a cairo context.
Maxwell Hendersonf5123fe2023-02-04 13:44:41 -0800353def draw_lines(cr, lines):
354 cr.move_to(lines[0][0], lines[0][1])
355 for pt in lines[1:]:
356 cr.line_to(pt[0], pt[1])
Maxwell Hendersonf5123fe2023-02-04 13:44:41 -0800357
358
milind-u18a901d2023-02-17 21:51:55 -0800359class Path(abc.ABC):
Maxwell Hendersonf5123fe2023-02-04 13:44:41 -0800360
milind-u18a901d2023-02-17 21:51:55 -0800361 def __init__(self, name):
Maxwell Hendersonf5123fe2023-02-04 13:44:41 -0800362 self.name = name
Maxwell Hendersonf5123fe2023-02-04 13:44:41 -0800363
milind-u18a901d2023-02-17 21:51:55 -0800364 @abc.abstractmethod
365 def DoToThetaPoints(self):
366 pass
367
368 @abc.abstractmethod
369 def DoDrawTo(self):
370 pass
371
372 @abc.abstractmethod
373 def roll_joint_thetas(self):
374 pass
375
376 @abc.abstractmethod
377 def intersection(self, event):
378 pass
379
380 def roll_joint_collision(self, points, verbose=False):
381 for point in points:
382 if roll_joint_collision(*point):
383 if verbose:
384 print("Roll joint collision for path %s in point %s" %
385 (self.name, point))
386 return True
387 return False
Maxwell Hendersonf5123fe2023-02-04 13:44:41 -0800388
milind-ueeb08c52023-02-21 22:30:16 -0800389 def arm_past_limit(self, points, verbose=True):
390 for point in points:
391 if arm_past_limit(*point):
392 if verbose:
393 print("Arm past limit for path %s in point %s" %
394 (self.name, point))
395 return True
396 return False
397
Maxwell Hendersonf5123fe2023-02-04 13:44:41 -0800398 def DrawTo(self, cr, theta_version):
milind-ueeb08c52023-02-21 22:30:16 -0800399 points = self.DoToThetaPoints()
400 if self.roll_joint_collision(points):
401 # Draw the spline red
milind-u18a901d2023-02-17 21:51:55 -0800402 cr.set_source_rgb(1.0, 0.0, 0.0)
milind-ueeb08c52023-02-21 22:30:16 -0800403 elif self.arm_past_limit(points):
404 # Draw the spline orange
405 cr.set_source_rgb(1.0, 0.5, 0.0)
406
milind-u18a901d2023-02-17 21:51:55 -0800407 self.DoDrawTo(cr, theta_version)
Maxwell Hendersonf5123fe2023-02-04 13:44:41 -0800408
409 def ToThetaPoints(self):
milind-u18a901d2023-02-17 21:51:55 -0800410 points = self.DoToThetaPoints()
milind-ueeb08c52023-02-21 22:30:16 -0800411 if self.roll_joint_collision(points, verbose=True) or \
412 self.arm_past_limit(points, verbose=True):
milind-u18a901d2023-02-17 21:51:55 -0800413 sys.exit(1)
414 return points
Maxwell Hendersonf5123fe2023-02-04 13:44:41 -0800415
416
milind-u18a901d2023-02-17 21:51:55 -0800417class SplineSegmentBase(Path):
Maxwell Hendersonf5123fe2023-02-04 13:44:41 -0800418
milind-u18a901d2023-02-17 21:51:55 -0800419 def __init__(self, name):
420 super().__init__(name)
Maxwell Hendersonf5123fe2023-02-04 13:44:41 -0800421
milind-u18a901d2023-02-17 21:51:55 -0800422 @abc.abstractmethod
423 # Returns (start, control1, control2, end), each in the form
424 # (theta1, theta2, theta3)
425 def get_controls_theta(self):
426 pass
Maxwell Hendersonf5123fe2023-02-04 13:44:41 -0800427
milind-u18a901d2023-02-17 21:51:55 -0800428 def intersection(self, event):
429 start, control1, control2, end = self.get_controls_theta()
430 for alpha in subdivide_multistep():
431 x, y = get_xy(spline_eval(start, control1, control2, end, alpha))
432 spline_point = np.array([x, y])
433 hovered_point = np.array([event.x, event.y])
434 if np.linalg.norm(hovered_point - spline_point) < 0.03:
435 return alpha
436 return None
Maxwell Hendersonf5123fe2023-02-04 13:44:41 -0800437
438
milind-u18a901d2023-02-17 21:51:55 -0800439class ThetaSplineSegment(SplineSegmentBase):
Maxwell Hendersonf5123fe2023-02-04 13:44:41 -0800440
milind-u18a901d2023-02-17 21:51:55 -0800441 # start and end are [theta1, theta2, theta3].
442 # controls are just [theta1, theta2].
443 # control_alpha_rolls are a list of [alpha, roll]
Maxwell Hendersonf5123fe2023-02-04 13:44:41 -0800444 def __init__(self,
milind-u18a901d2023-02-17 21:51:55 -0800445 name,
Maxwell Hendersonf5123fe2023-02-04 13:44:41 -0800446 start,
447 control1,
448 control2,
449 end,
milind-u18a901d2023-02-17 21:51:55 -0800450 control_alpha_rolls=[],
Maxwell Hendersonf5123fe2023-02-04 13:44:41 -0800451 alpha_unitizer=None,
452 vmax=None):
milind-u18a901d2023-02-17 21:51:55 -0800453 super().__init__(name)
454 self.start = start[:2]
Maxwell Hendersonf5123fe2023-02-04 13:44:41 -0800455 self.control1 = control1
456 self.control2 = control2
milind-u18a901d2023-02-17 21:51:55 -0800457 self.end = end[:2]
458 # There will always be roll at alpha = 0 and 1
459 self.alpha_rolls = [[0.0, start[2]]
460 ] + control_alpha_rolls + [[1.0, end[2]]]
Maxwell Hendersonf5123fe2023-02-04 13:44:41 -0800461 self.alpha_unitizer = alpha_unitizer
462 self.vmax = vmax
463
464 def __repr__(self):
milind-u18a901d2023-02-17 21:51:55 -0800465 return "ThetaSplineSegment(%s, %s, %s, %s)" % (repr(
Maxwell Hendersonf5123fe2023-02-04 13:44:41 -0800466 self.start), repr(self.control1), repr(
467 self.control2), repr(self.end))
468
milind-u18a901d2023-02-17 21:51:55 -0800469 def DoDrawTo(self, cr, theta_version):
Maxwell Hendersonf5123fe2023-02-04 13:44:41 -0800470 if (theta_version):
471 draw_lines(cr, [
milind-u060e4cf2023-02-22 00:08:52 -0800472 shift_angles(
473 spline_eval(self.start, self.control1, self.control2,
474 self.end, alpha))
475 for alpha in subdivide_multistep()
Maxwell Hendersonf5123fe2023-02-04 13:44:41 -0800476 ])
477 else:
478 start = get_xy(self.start)
479 end = get_xy(self.end)
480
481 draw_lines(cr, [
482 get_xy(
483 spline_eval(self.start, self.control1, self.control2,
484 self.end, alpha))
milind-u18a901d2023-02-17 21:51:55 -0800485 for alpha in subdivide_multistep()
Maxwell Hendersonf5123fe2023-02-04 13:44:41 -0800486 ])
487
488 cr.move_to(start[0] + xy_end_circle_size, start[1])
milind-u18a901d2023-02-17 21:51:55 -0800489 cr.arc(start[0], start[1], xy_end_circle_size, 0, 2.0 * np.pi)
Maxwell Hendersonf5123fe2023-02-04 13:44:41 -0800490 cr.move_to(end[0] + xy_end_circle_size, end[1])
milind-u18a901d2023-02-17 21:51:55 -0800491 cr.arc(end[0], end[1], xy_end_circle_size, 0, 2.0 * np.pi)
Maxwell Hendersonf5123fe2023-02-04 13:44:41 -0800492
milind-u18a901d2023-02-17 21:51:55 -0800493 def DoToThetaPoints(self):
494 points = []
495 for alpha in subdivide_multistep():
496 proximal, distal = spline_eval(self.start, self.control1,
497 self.control2, self.end, alpha)
498 roll_joint = get_roll_joint_theta_multistep(
499 self.alpha_rolls, alpha)
500 points.append((proximal, distal, roll_joint))
Maxwell Hendersonf5123fe2023-02-04 13:44:41 -0800501
milind-u18a901d2023-02-17 21:51:55 -0800502 return points
Maxwell Hendersonf5123fe2023-02-04 13:44:41 -0800503
milind-u18a901d2023-02-17 21:51:55 -0800504 def get_controls_theta(self):
505 return (self.start, self.control1, self.control2, self.end)
Maxwell Hendersonf5123fe2023-02-04 13:44:41 -0800506
milind-u18a901d2023-02-17 21:51:55 -0800507 def roll_joint_thetas(self):
508 ts = []
509 thetas = []
510 for alpha in subdivide_multistep():
511 roll_joint = get_roll_joint_theta_multistep(
512 self.alpha_rolls, alpha)
513 thetas.append(roll_joint)
514 ts.append(alpha)
515 return ts, thetas