Might be useful to segregate the microcontroller code into separate concurrent instances with segregation of responsibility.
For example:
AVR1 - movement and positioning:
- Motors
- Lidar
- Remote ctrl
- Field, Robot, Start buttons
AVR2 - thrower system:
- Thrower engine control
- Ball roller engine control
- Ball sensors