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 @@ -280,6 +280,7 @@ def main(connection=None):
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,
const.FUNCTION_SET_COIL_INDEX: robot_control.on_set_coil_index,
}
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 @@ -161,6 +161,7 @@
"Neuronavigation to Robot: Update robot control pid factors",
"Neuronavigation to Robot: Request config",
"Dashboard to Robot: Request pid factors",
"Neuronavigation to Robot: Set coil index"
]

FUNCTION_CONNECT_TO_ROBOT = 0
Expand All @@ -182,3 +183,4 @@
FUNCTION_UPDATE_PID = 16
FUNCTION_REQUEST_CONFIG = 17
FUNCTION_REQUEST_PID = 18
FUNCTION_SET_COIL_INDEX = 19
7 changes: 6 additions & 1 deletion robot/control/robot_control.py
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,8 @@ def __init__(self, remote_control, config, site_config, robot_config, connection
listener = keyboard.Listener(on_press=self.on_keypress)
listener.start()

self.coil_index = 2 # Default coil index from tracker system

self.target_set = False
self.m_target_to_head = None
self.target_reached = False
Expand Down Expand Up @@ -240,9 +242,12 @@ def on_update_tracker_poses(self, data):
poses = data["poses"]
visibilities = data["visibilities"]
self.tracker.SetCoordinates(
np.vstack([poses[0], poses[1], poses[2]]), visibilities
np.vstack([poses[0], poses[1], poses[self.coil_index]]), [visibilities[0], visibilities[1], visibilities[self.coil_index]]
)

def on_set_coil_index(self, data):
self.coil_index = data["coil_idx"]

def on_create_point(self, data):
if self.create_calibration_point():
if self.connection:
Expand Down
Loading