diff --git a/main_loop.py b/main_loop.py index a6209a9..5c4c524 100644 --- a/main_loop.py +++ b/main_loop.py @@ -279,6 +279,7 @@ def main(connection=None): const.FUNCTION_UPDATE_CONFIG: robot_control.set_config, const.FUNCTION_UPDATE_PID: robot_control.update_pid_values, const.FUNCTION_REQUEST_CONFIG: robot_control.send_config, + const.FUNCTION_REQUEST_PID: robot_control.send_pid_factors, } get_function[const.PUB_MESSAGES.index(topic[i])](buf[i]["data"]) diff --git a/robot/constants.py b/robot/constants.py index efa90d4..017b975 100644 --- a/robot/constants.py +++ b/robot/constants.py @@ -159,6 +159,7 @@ "Neuronavigation to Robot: Update config", "Neuronavigation to Robot: Update robot control pid factors", "Neuronavigation to Robot: Request config", + "Dashboard to Robot: Request pid factors", ] FUNCTION_CONNECT_TO_ROBOT = 0 @@ -179,3 +180,4 @@ FUNCTION_UPDATE_CONFIG = 15 FUNCTION_UPDATE_PID = 16 FUNCTION_REQUEST_CONFIG = 17 +FUNCTION_REQUEST_PID = 18 diff --git a/robot/control/robot_control.py b/robot/control/robot_control.py index 43e491e..695e9f6 100644 --- a/robot/control/robot_control.py +++ b/robot/control/robot_control.py @@ -1127,8 +1127,7 @@ def update(self): def send_config(self, data): self.remote_control.send_message( "Robot to Neuronavigation: Initial config", - {"config": self.config, - "pid_factors": self.pid_group.get_pid_factors()}, + {"config": self.config}, ) def set_config(self, data: dict): @@ -1179,4 +1178,8 @@ def set_config(self, data: dict): def update_pid_values(self, pids_factors: dict): if "translations" in pids_factors and "rotations" in pids_factors: self.pid_group.update_pid_factors(pids_factors["translations"], pids_factors["rotations"]) - + + def send_pid_factors(self, data): + self.remote_control.send_message( + "Robot to Dashboard: PID factors", + {"pid_factors": self.pid_group.get_pid_factors()})