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."""
79 def no_arc(end_point, start_angle, end_angle):
80 """Create the parameters for a trajectory with no arc."""
86 start_angle=start_angle,
89 arc_start_point=end_point,
90 arc_end_point=end_point,
94 @dataclass(frozen=True)
97 A dataclass that holds the generated poses for a given trajectory.
99 xs: X coordinates of poses along trajectory
100 ys: Y coordinates of poses along trajectory
101 yaws: Yaws of poses along trajectory
109 """Add two paths together by concatenating them."""
113 xs = np.concatenate((self.xs, rhs.xs))
114 ys = np.concatenate((self.ys, rhs.ys))
115 yaws = np.concatenate((self.yaws, rhs.yaws))
117 return Path(xs, ys, yaws)
120 """Return the path data in a format suitable for outputting."""
121 output_xs = self.xs.round(5)
122 output_ys = self.ys.round(5)
125 output_xs = output_xs + 0.0
126 output_ys = output_ys + 0.0
127 output_yaws = self.yaws + 0.0
129 vectorized_normalize_angle = np.vectorize(normalize_angle)
130 output_yaws = vectorized_normalize_angle(output_yaws)
132 stacked = np.vstack([output_xs, output_ys, output_yaws]).transpose()
134 return stacked.tolist()
137 @dataclass(frozen=True)
140 A dataclass that holds the path and parameters for a trajectory.
142 path: The Path that represents the trajectory
143 parameters: The TrajectoryParameters that represent the trajectory
147 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)