Skip to content

Commit

Permalink
Small updates.
Browse files Browse the repository at this point in the history
  • Loading branch information
myeatman-bdai committed Oct 22, 2024
1 parent 8dbc059 commit 02b1f52
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 10 deletions.
14 changes: 7 additions & 7 deletions spatialmath/spline.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@

from abc import ABC, abstractmethod
from functools import cached_property
from typing import List, Optional, Tuple
from typing import List, Optional, Tuple, Set

import matplotlib.pyplot as plt
import numpy as np
Expand All @@ -29,16 +29,16 @@ def __call__(self, t: float) -> SE3:
def visualize(
self,
sample_times: List[float],
input_trajectory: Optional[List[SE3]] = None,
pose_marker_length: float = 0.2,
animate: bool = False,
repeat: bool = True,
ax: Optional[plt.Axes] = None,
input_trajectory: Optional[List[SE3]] = None,
) -> None:
"""Displays an animation of the trajectory with the control poses against an optional input trajectory.
Args:
times: which times to sample the spline at and plot
sample_times: which times to sample the spline at and plot
"""
if ax is None:
fig = plt.figure(figsize=(10, 10))
Expand Down Expand Up @@ -180,10 +180,10 @@ def stochastic_downsample_interpolation(
normalize_time=normalize_time,
bc_type=bc_type,
)
chosen_indices: set[int] = set()
chosen_indices: Set[int] = set()
interpolation_indices = list(range(len(self.pose_data)))
interpolation_indices.remove(0)
interpolation_indices.remove(len(self.pose_data) - 1)
chosen_indices.add(0)
chosen_indices.add(len(self.pose_data) - 1)

for _ in range(len(self.time_data) - 2): # you must have at least 2 indices
choices = list(set(interpolation_indices).difference(chosen_indices))
Expand Down Expand Up @@ -263,7 +263,7 @@ def __init__(
- degree: int that controls degree of the polynomial that governs any given point on the spline.
- knots: list of floats that govern which control points are active during evaluating the spline
at a given t input. If none, they are automatically, uniformly generated based on number of control poses and
degree of spline.
degree of spline on the range [0,1].
"""
super().__init__()
self.control_poses = control_poses
Expand Down
6 changes: 3 additions & 3 deletions tests/test_spline.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ def test_evaluation(self):

def test_visualize(self):
spline = BSplineSE3(self.control_poses)
spline.visualize(np.linspace(0, 1.0, 100), animate=True, repeat=False)
spline.visualize(sample_times= np.linspace(0, 1.0, 100), animate=True, repeat=False)

class TestInterpSplineSE3:
waypoints = [
Expand Down Expand Up @@ -62,7 +62,7 @@ def test_small_delta_t(self):

def test_visualize(self):
spline = InterpSplineSE3(self.times, self.waypoints)
spline.visualize(np.linspace(0, self.time_horizon, 100), animate=True, repeat=False)
spline.visualize(sample_times= np.linspace(0, self.time_horizon, 100), animate=True, repeat=False)


class TestSplineFit:
Expand All @@ -89,4 +89,4 @@ def test_spline_fit(self):

assert( fit.max_angular_error() < np.deg2rad(5.0) )
assert( fit.max_angular_error() < 0.1 )
spline.visualize(np.linspace(0, self.time_horizon, 100), animate=True, repeat=False)
spline.visualize(sample_times= np.linspace(0, self.time_horizon, 100), animate=True, repeat=False)

0 comments on commit 02b1f52

Please sign in to comment.