diff --git a/src/proto/robot_statistic.proto b/src/proto/robot_statistic.proto index e314e16724..1de7c4e03c 100644 --- a/src/proto/robot_statistic.proto +++ b/src/proto/robot_statistic.proto @@ -3,4 +3,5 @@ syntax = "proto3"; message RobotStatistic { double round_trip_time_seconds = 1; + uint32 robot_id = 2; } diff --git a/src/software/thunderscope/robot_communication.py b/src/software/thunderscope/robot_communication.py index d5d02c37a6..130ef3cf43 100644 --- a/src/software/thunderscope/robot_communication.py +++ b/src/software/thunderscope/robot_communication.py @@ -337,11 +337,13 @@ def __receive_robot_status(self, robot_status: Message) -> None: round_trip_time_seconds = time.time() - ( robot_status.adjusted_time_sent.epoch_timestamp_seconds ) - self.__forward_to_proto_unix_io( - RobotStatistic, - RobotStatistic(round_trip_time_seconds=round_trip_time_seconds), + robot_statistic = RobotStatistic( + robot_id=robot_status.robot_id, + round_trip_time_seconds=round_trip_time_seconds, ) + self.__forward_to_proto_unix_io(RobotStatus, robot_status) + self.__forward_to_proto_unix_io(RobotStatistic, robot_statistic) def __exit__(self, type, value, traceback) -> None: """Exit RobotCommunication context manager diff --git a/src/software/thunderscope/robot_diagnostics/robot_view.py b/src/software/thunderscope/robot_diagnostics/robot_view.py index 972c4d1e21..32bb7eda19 100644 --- a/src/software/thunderscope/robot_diagnostics/robot_view.py +++ b/src/software/thunderscope/robot_diagnostics/robot_view.py @@ -70,9 +70,13 @@ def update( :param robot_status: the new message data to update the widget with :param round_trip_time: robot statistic proto to update with new metrics """ - self.robot_info.update(robot_status, round_trip_time) - if self.robot_status: - self.robot_status.update(robot_status) + if robot_status is not None: + self.robot_info.update(robot_status, round_trip_time) + if self.robot_status: + self.robot_status.update(robot_status) + + if round_trip_time is not None: + self.robot_info.update_rtt(round_trip_time) class RobotView(QScrollArea): @@ -125,7 +129,21 @@ def refresh(self) -> None: block=False, return_cached=False ) - if robot_status is not None and round_trip_time is not None: + if ( + robot_status is not None + and round_trip_time is not None + and robot_status.robot_id == round_trip_time.robot_id + ): # if both pieces of data are available self.robot_view_widgets[robot_status.robot_id].update( - robot_status, round_trip_time + robot_status=robot_status, round_trip_time=round_trip_time ) + else: + if robot_status is not None: + self.robot_view_widgets[robot_status.robot_id].update( + robot_status, + round_trip_time=None, + ) + if round_trip_time is not None: + self.robot_view_widgets[round_trip_time.robot_id].update( + robot_status=None, round_trip_time=round_trip_time + )