Your indentation is wrong. Python cares about formatting. Lines 63-99 (excepting lines 70-73) aren’t indented far enough to be part of the
while True: on line 62.
The reason the error shows up when you put the controller printing stuff in is lines 70-73 are indented properly, so there is no syntax error until you add them. With or without them you have a logic error because lines 76-99 aren’t indented to be part of the
while on line 62. Additionally, you will find that there’s an additional logic error in calling two controller prints back-to-back, as the controller ignores messages for 50ms after receiving a message.
The easy way to indent several lines at once is to select all of them then hit the Tab key. It will indent all lines with highlighted text (as long as parts of more than one line are selected). The same can be done for undoing an indent, but with Shift+Tab instead of Tab.