Magicbot and the execute() method

I’m doing some testing right now and trying to understand the execute() method with the magicbot framework. I should also mention that I’m simulating this tonight since I don’t have a robot in front of me, but am hoping to teach this to some students this weekend. I’m testing this with the LEDs and have the relevant code here:

This code works if I am in autonomous/teleop with the sim. However, I need to include self.leds.execute() to get them to work if the robot is disabled. I just set them to be enabled in robotPeriodic() and don’t have to call the execute() method for autonomous or teleop and was wondering why that’s needed for the disabled method?

This appears to be because the execute method is only called in _enabled_periodic.

https://robotpy.readthedocs.io/projects/utilities/en/stable/_modules/magicbot/magicrobot.html

Thanks for pointing that out. That makes a lot of sense now that I see the source code.

1 Like