15 from dataclasses
import dataclass
17 from helper
import angle_difference, normalize_angle
22 @dataclass(frozen=True)
25 A dataclass that holds the data needed to create the path for a trajectory.
27 turning_radius: The radius of the circle used to generate
29 x_offset: The x coordinate of the circle used to generate
31 y_offset: They y coordinate of the circle used to generate
33 end_point: The end coordinate of the path
34 start_angle: The starting angle of the path
35 - given in radians from -pi to pi where 0 radians is along
37 end_angle: The end angle of the path
38 - given in radians from -pi to pi where 0 radians is along
40 left_turn: Whether the arc in the path turns to the left
41 arc_start_point: Coordinates of the starting position of the arc
42 arc_end_point: Coordinates of the ending position of the arc
53 arc_start_point: float
58 """Arc length of the trajectory."""
59 return self.turning_radius * angle_difference(
60 self.start_angle, self.end_angle, self.left_turn
65 """Length of the straight line from start to arc."""
66 return np.linalg.norm(self.arc_start_point)
70 """Length of the straight line from arc to end."""
71 return np.linalg.norm(self.end_point - self.arc_end_point)
75 """Total length of trajectory."""
80 def no_arc(end_point, start_angle, end_angle):
81 """Create the parameters for a trajectory with no arc."""
87 start_angle=start_angle,
90 arc_start_point=end_point,
91 arc_end_point=end_point,
95 @dataclass(frozen=True)
98 A dataclass that holds the generated poses for a given trajectory.
100 xs: X coordinates of poses along trajectory
101 ys: Y coordinates of poses along trajectory
102 yaws: Yaws of poses along trajectory
110 """Add two paths together by concatenating them."""
114 xs = np.concatenate((self.xs, rhs.xs))
115 ys = np.concatenate((self.ys, rhs.ys))
116 yaws = np.concatenate((self.yaws, rhs.yaws))
118 return Path(xs, ys, yaws)
121 """Return the path data in a format suitable for outputting."""
122 output_xs = self.xs.round(5)
123 output_ys = self.ys.round(5)
126 output_xs = output_xs + 0.0
127 output_ys = output_ys + 0.0
128 output_yaws = self.yaws + 0.0
130 vectorized_normalize_angle = np.vectorize(normalize_angle)
131 output_yaws = vectorized_normalize_angle(output_yaws)
133 stacked = np.vstack([output_xs, output_ys, output_yaws]).transpose()
135 return stacked.tolist()
138 @dataclass(frozen=True)
141 A dataclass that holds the path and parameters for a trajectory.
143 path: The Path that represents the trajectory
144 parameters: The TrajectoryParameters that represent the trajectory
148 parameters: TrajectoryParameters
def to_output_format(self)
def start_straight_length(self)
def end_straight_length(self)
def no_arc(end_point, start_angle, end_angle)