15 from dataclasses
import dataclass
16 from typing
import Any, Union
18 from nav2_smac_planner.lattice_primitives.helper
import angle_difference, normalize_angle
20 from numpy.typing
import NDArray
22 AnyFloat = np.floating[Any]
23 TrajectoryFloat = Union[float, AnyFloat]
24 FloatNDArray = NDArray[AnyFloat]
27 @dataclass(frozen=True)
30 A dataclass that holds the data needed to create the path for a trajectory.
32 turning_radius: The radius of the circle used to generate
34 x_offset: The x coordinate of the circle used to generate
36 y_offset: They y coordinate of the circle used to generate
38 end_point: The end coordinate of the path
39 start_angle: The starting angle of the path
40 - given in radians from -pi to pi where 0 radians is along
42 end_angle: The end angle of the path
43 - given in radians from -pi to pi where 0 radians is along
45 left_turn: Whether the arc in the path turns to the left
46 arc_start_point: Coordinates of the starting position of the arc
47 arc_end_point: Coordinates of the ending position of the arc
50 turning_radius: TrajectoryFloat
53 end_point: FloatNDArray
58 arc_start_point: FloatNDArray
59 arc_end_point: FloatNDArray
63 """Arc length of the trajectory."""
64 result: TrajectoryFloat = self.turning_radius * angle_difference(
65 self.start_angle, self.end_angle, self.left_turn
71 """Length of the straight line fromnorarc_start_pointm start to arc."""
72 return np.linalg.norm(self.arc_start_point)
76 """Length of the straight line from arc to end."""
77 return np.linalg.norm(self.end_point - self.arc_end_point)
81 """Total length of trajectory."""
85 def no_arc(end_point: FloatNDArray, start_angle: float,
86 end_angle: float) ->
'TrajectoryParameters':
87 """Create the parameters for a trajectory with no arc."""
93 start_angle=start_angle,
96 arc_start_point=end_point,
97 arc_end_point=end_point,
101 @dataclass(frozen=True)
104 A dataclass that holds the generated poses for a given trajectory.
106 xs: X coordinates of poses along trajectory
107 ys: Y coordinates of poses along trajectory
108 yaws: Yaws of poses along trajectory
116 """Add two paths together by concatenating them."""
120 xs = np.concatenate((self.xs, rhs.xs))
121 ys = np.concatenate((self.ys, rhs.ys))
122 yaws = np.concatenate((self.yaws, rhs.yaws))
124 return Path(xs, ys, yaws)
127 """Return the path data in a format suitable for outputting."""
128 output_xs = self.xs.round(5)
129 output_ys = self.ys.round(5)
132 output_xs = output_xs + 0.0
133 output_ys = output_ys + 0.0
134 output_yaws = self.yaws + 0.0
136 vectorized_normalize_angle = np.vectorize(normalize_angle)
137 output_yaws = vectorized_normalize_angle(output_yaws)
139 stacked = np.vstack([output_xs, output_ys, output_yaws]).transpose()
141 return stacked.tolist()
144 @dataclass(frozen=True)
147 A dataclass that holds the path and parameters for a trajectory.
149 path: The Path that represents the trajectory
150 parameters: The TrajectoryParameters that represent the trajectory
154 parameters: TrajectoryParameters
'Path' __add__(self, 'Path' rhs)
Any to_output_format(self)
TrajectoryFloat arc_length(self)
AnyFloat end_straight_length(self)
AnyFloat start_straight_length(self)
'TrajectoryParameters' no_arc(FloatNDArray end_point, float start_angle, float end_angle)
AnyFloat total_length(self)