Skip to content

Commit

Permalink
bug fix
Browse files Browse the repository at this point in the history
  • Loading branch information
ibrahimhroob committed Oct 10, 2024
1 parent 45beadd commit 41e5c43
Showing 1 changed file with 13 additions and 3 deletions.
16 changes: 13 additions & 3 deletions src/autonomy_metrics/autonomy_metrics/metric_logger.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,12 +24,19 @@
from sensor_msgs.msg import NavSatFix
from std_msgs.msg import Float32, Bool, Int8, String
from nav_msgs.msg import Odometry
from hunter_msgs.msg import HunterStatus
from topological_navigation_msgs.msg import ExecutePolicyModeGoal
from autonomy_metrics.db_mgr import DatabaseMgr as DBMgr
from datetime import datetime, timezone
from rclpy.qos import qos_profile_sensor_data

# Try to import HunterStatus and handle if it is unavailable
try:
from hunter_msgs.msg import HunterStatus
HUNTER_MSG_AVAILABLE = True
except ImportError:
HUNTER_MSG_AVAILABLE = False
print("Warning: hunter_msgs.HunterStatus is not available. Hunter status callbacks will be disabled.")


class AutonomyMetricsLogger(Node):
"""
Expand Down Expand Up @@ -166,9 +173,12 @@ def create_subscriptions(self):
self.create_subscription(Bool, self.params['estop_status_topic'], self.estop_sub_callback, qos_profile=qos_profile_sensor_data)
self.create_subscription(NavSatFix, self.params['gps_topic'], self.gps_fix_callback, qos_profile=qos_profile_sensor_data)
self.create_subscription(Odometry, self.params['gps_odom_topic'], self.gps_odom_callback, qos_profile=qos_profile_sensor_data)
self.create_subscription(HunterStatus, self.params['hunter_status_topic'], self.hunter_status_callback, qos_profile=qos_profile_sensor_data)
self.create_subscription(ExecutePolicyModeGoal, self.params['actioned_by_coordinator_topic'], self.coordinator_callback, qos_profile=qos_profile_sensor_data)

# Only subscribe to hunter status if the message is available
if HUNTER_MSG_AVAILABLE:
self.create_subscription(HunterStatus, self.params['hunter_status_topic'], self.hunter_status_callback, qos_profile=qos_profile_sensor_data)
else:
self.get_logger().warn("HunterStatus message not available, skipping hunter status subscription.")

def get_git_info(self, repo_path="."):
try:
Expand Down

0 comments on commit 41e5c43

Please sign in to comment.