-
Notifications
You must be signed in to change notification settings - Fork 4
Fix #765: Add error handling for OMPL path hard crashes and stop sign… #780
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Changes from 1 commit
d8599f9
8123036
3796cea
f86fa9b
530fefa
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,2 +1,3 @@ | ||
| HelperHeading heading | ||
| uint8 steering | ||
| bool sail |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -212,9 +212,14 @@ def update_if_needed( | |
| ) | ||
| old_ompl_path = self._ompl_path | ||
|
|
||
| heading_new_path, wp_index = self.calculate_desired_heading_and_waypoint_index( | ||
| ompl_path.get_path(), 0, gps.lat_lon | ||
| ) | ||
| try: | ||
| new_path = ompl_path.get_path() | ||
| heading_new_path, wp_index = self.calculate_desired_heading_and_waypoint_index( | ||
| new_path, 0, gps.lat_lon | ||
| ) | ||
| except Exception as e: | ||
| self._logger.error(f"Failed to get new OMPL path: {e}") | ||
| return None, local_waypoint_index | ||
|
|
||
| if received_new_global_waypoint: | ||
| self._logger.debug("Updating local path because we have a new global waypoint") | ||
|
|
@@ -227,9 +232,14 @@ def update_if_needed( | |
| self._update(ompl_path) | ||
| return heading_new_path, wp_index | ||
|
|
||
| heading_old_path, updated_wp_index = self.calculate_desired_heading_and_waypoint_index( | ||
| old_ompl_path.get_path(), local_waypoint_index, gps.lat_lon | ||
| ) | ||
| try: | ||
| old_path = old_ompl_path.get_path() | ||
| heading_old_path, updated_wp_index = self.calculate_desired_heading_and_waypoint_index( | ||
| old_path, local_waypoint_index, gps.lat_lon | ||
| ) | ||
| except Exception as e: | ||
| self._logger.error(f"Failed to get old OMPL path: {e}") | ||
| return None, local_waypoint_index | ||
|
||
| # check if the current path goes through a collision zone. | ||
| # No need to check for new path since it's fresh and ompl doesn't generate path that | ||
| # go through a collision zone | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -180,7 +180,18 @@ def desired_heading_callback(self): | |
|
|
||
| desired_heading = self.get_desired_heading() | ||
| msg = ci.DesiredHeading() | ||
| msg.heading.heading = desired_heading | ||
|
|
||
| # If desired_heading is None, pathfinding failed - signal boat to not sail | ||
| if desired_heading is None: | ||
| self.get_logger().error("Pathfinding failed, signaling boat to stop") | ||
| msg.heading.heading = 0.0 | ||
| msg.steering = 0 | ||
raghumanimehta marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| msg.sail = False | ||
| else: | ||
| msg.heading.heading = desired_heading | ||
| msg.steering = 0 | ||
|
||
| msg.sail = True | ||
|
|
||
| if self.desired_heading is None or desired_heading != self.desired_heading.heading.heading: | ||
| self.get_logger().info(f"Updating desired heading to: {msg.heading.heading:.2f}") | ||
|
|
||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -219,19 +219,23 @@ def get_path(self) -> ci.Path: | |
| self._logger.warning("Trying to get the waypoints of an unsolved OMPLPath") | ||
| return ci.Path() | ||
|
|
||
| solution_path = self._simple_setup.getSolutionPath() | ||
| waypoints = [] | ||
|
|
||
| for state in solution_path.getStates(): | ||
| waypoint_XY = cs.XY(state.getX(), state.getY()) | ||
| waypoint_latlon = cs.xy_to_latlon(self.state.reference_latlon, waypoint_XY) | ||
| waypoints.append( | ||
| ci.HelperLatLon( | ||
| latitude=waypoint_latlon.latitude, longitude=waypoint_latlon.longitude | ||
| try: | ||
| solution_path = self._simple_setup.getSolutionPath() | ||
| waypoints = [] | ||
|
|
||
| for state in solution_path.getStates(): | ||
| waypoint_XY = cs.XY(state.getX(), state.getY()) | ||
| waypoint_latlon = cs.xy_to_latlon(self.state.reference_latlon, waypoint_XY) | ||
| waypoints.append( | ||
| ci.HelperLatLon( | ||
| latitude=waypoint_latlon.latitude, longitude=waypoint_latlon.longitude | ||
| ) | ||
| ) | ||
| ) | ||
|
|
||
| return ci.Path(waypoints=waypoints) | ||
| return ci.Path(waypoints=waypoints) | ||
| except Exception as e: | ||
| self._logger.error(f"Exception occurred while getting path from OMPL: {e}") | ||
| return ci.Path() | ||
|
||
|
|
||
| def update_objectives(self): | ||
| """Update the objectives on the basis of which the path is optimized. | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should perhaps return
Nonefor both.