Skip to content

Commit

Permalink
try/except for file not exists and fuse
Browse files Browse the repository at this point in the history
  • Loading branch information
mgonzs13 committed Nov 13, 2024
1 parent b7a5d6f commit d587d43
Showing 1 changed file with 11 additions and 2 deletions.
13 changes: 11 additions & 2 deletions yolo_ros/yolo_ros/yolo_node.py
Original file line number Diff line number Diff line change
Expand Up @@ -127,8 +127,17 @@ def on_configure(self, state: LifecycleState) -> TransitionCallbackReturn:
def on_activate(self, state: LifecycleState) -> TransitionCallbackReturn:
self.get_logger().info(f"[{self.get_name()}] Activating...")

self.yolo = self.type_to_model[self.model_type](self.model)
self.yolo.fuse()
try:
self.yolo = self.type_to_model[self.model_type](self.model)
except FileNotFoundError:
self.get_logger().error(f"Model file '{self.model}' does not exists")
return TransitionCallbackReturn.ERROR

try:
self.get_logger().info("Trying to fuse model...")
self.yolo.fuse()
except TypeError as e:
self.get_logger().warn(f"Error while fuse: {e}")

self._enable_srv = self.create_service(SetBool, "enable", self.enable_cb)

Expand Down

0 comments on commit d587d43

Please sign in to comment.