A class representing an obstacle.
| 142 | |
| 143 | |
| 144 | class Obstacle(ABC): |
| 145 | """ |
| 146 | A class representing an obstacle. |
| 147 | """ |
| 148 | |
| 149 | def __init__(self, |
| 150 | obstacle_id: str, |
| 151 | shape: Shape, |
| 152 | obstacle_type: ObsType, |
| 153 | current_state: State, |
| 154 | lane_id: str, |
| 155 | edge: str = "") -> None: |
| 156 | super().__init__() |
| 157 | |
| 158 | self._obstacle_id = obstacle_id |
| 159 | self._shape: Shape = shape |
| 160 | self._obstacle_type: ObsType = obstacle_type |
| 161 | self._current_state: State = current_state |
| 162 | self._lane_id: str = lane_id |
| 163 | self._affiliated_edge: str = edge |
| 164 | |
| 165 | @property |
| 166 | def type(self) -> ObsType: |
| 167 | return self._obstacle_type |
| 168 | |
| 169 | @property |
| 170 | def current_state(self) -> State: |
| 171 | return self._current_state |
| 172 | |
| 173 | @property |
| 174 | def shape(self) -> Shape: |
| 175 | return self._shape |
| 176 | |
| 177 | @property |
| 178 | def lane_id(self) -> str: |
| 179 | return self._lane_id |
| 180 | |
| 181 | def update_frenet_coord_in_lane(self, lane) -> State: |
| 182 | course_spline = lane.course_spline |
| 183 | |
| 184 | rs = course_spline.find_nearest_rs(self.current_state.x, |
| 185 | self.current_state.y) |
| 186 | |
| 187 | rx, ry = course_spline.calc_position(rs) |
| 188 | ryaw = course_spline.calc_yaw(rs) |
| 189 | rkappa = course_spline.calc_curvature(rs) |
| 190 | |
| 191 | s, s_d, d, d_d = cartesian_to_frenet2D(rs, rx, ry, ryaw, rkappa, |
| 192 | self.current_state) |
| 193 | return State(s=s, s_d=s_d, d=d, d_d=d_d, |
| 194 | x=self.current_state.x, |
| 195 | y=self.current_state.y, |
| 196 | yaw=self.current_state.yaw, |
| 197 | vel=self.current_state.vel, |
| 198 | acc=self.current_state.acc) |
| 199 | |
| 200 | |
| 201 | @classmethod |
nothing calls this directly
no outgoing calls
no test coverage detected