Skip to content

Commit

Permalink
fix(lareral_deviation_monitor): update metrics msgs
Browse files Browse the repository at this point in the history
Signed-off-by: Kasunori-Nakajima <[email protected]>
  • Loading branch information
Kazunori-Nakajima committed Nov 20, 2024
1 parent ac6ff25 commit e55939a
Showing 1 changed file with 7 additions and 11 deletions.
18 changes: 7 additions & 11 deletions control/control_debug_tools/scripts/lateral_deviation_monitor.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,11 +18,11 @@

from autoware_control_msgs.msg import Control
from autoware_vehicle_msgs.msg import SteeringReport
from diagnostic_msgs.msg import DiagnosticArray
import matplotlib.pyplot as plt
import rclpy
from rclpy.node import Node
from termcolor import colored
from tier4_metric_msgs.msg import MetricArray


class SteeringAndLateralDeviationMonitor(Node):
Expand All @@ -38,7 +38,7 @@ def __init__(self, plot=False):
)

self.create_subscription(
DiagnosticArray, "/control/control_evaluator/metrics", self.metrics_callback, 10
MetricArray, "/control/control_evaluator/metrics", self.metrics_callback, 10
)

self.control_steering_angle = None
Expand Down Expand Up @@ -77,14 +77,11 @@ def steering_status_callback(self, msg):
self.update_steering_diff()
self.update_max_values()

def metrics_callback(self, msg):
for status in msg.status:
if status.name == "lateral_deviation":
for value in status.values:
if value.key == "metric_value":
self.lateral_deviation = float(value.value)
self.update_max_values()
break
def metrics_callback(self, msgs):
for msg in msgs.metric_array:
if msg.name == "lateral_deviation":
self.lateral_deviation = float(msg.value)
self.update_max_values()

def update_steering_diff(self):
if self.control_steering_angle is not None and self.vehicle_steering_angle is not None:
Expand Down Expand Up @@ -185,7 +182,6 @@ def main(args=None):
if monitor.plot:
plt.ion() # Interactive mode on for real-time plot updates
rclpy.spin(monitor)

monitor.destroy_node()
rclpy.shutdown()
if monitor.plot:
Expand Down

0 comments on commit e55939a

Please sign in to comment.