Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions main_loop.py
Original file line number Diff line number Diff line change
Expand Up @@ -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"])

Expand Down
2 changes: 2 additions & 0 deletions robot/constants.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -179,3 +180,4 @@
FUNCTION_UPDATE_CONFIG = 15
FUNCTION_UPDATE_PID = 16
FUNCTION_REQUEST_CONFIG = 17
FUNCTION_REQUEST_PID = 18
9 changes: 6 additions & 3 deletions robot/control/robot_control.py
Original file line number Diff line number Diff line change
Expand Up @@ -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):
Expand Down Expand Up @@ -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()})