Issues specifying a different timedcommandrobot period

I am doing a lot in our robot code this year and have basically given up on getting it under the 20ms loop so for PID’s sake I want to have a solid, exact robot loop time however when I try to specify this in the robot class initiation I get the following error, though I am not sure how else to format the parameter. I am sure I am missing something fundamental here, I just can’t see it.

class MyRobot(commands2.TimedCommandRobot(period = 0.035)):
    def robotInit(self):

You need to override the __init__ method and call super().__init__() with your desired arguments.

1 Like
def __init__(self, period = 0.035) -> None:
        super().__init__(period)

Worked flawlessly thank you. I’ve been using polymorphism extensively in the code base and have been overriding inits in the command base but I never thought to add in the init() function into the code as robotInit() is already present. Thanks again.

I’m curious about this. What exactly are you doing that’s taking up so much time?

Honestly I am not sure if we are overrunning it every loop but I keep getting warnings about it, 35ms is probably overkill. In autonomous I am running through all my subsystem periodics as well as going through all the path planner commands. In teleop I am running PIDs on a drive command based off the joystick. This is all on top of pose estimation and such. The code hasn’t reached a “final” state yet so I am not sure how it will be in the end. I will check again tomorrow to see what exact runtime is looping. Also just want to check there was no python implementation of the files located in the “auto” and “commands” folders located Here right? I translated all that logic over by hand because I didn’t see it in the robotpy PPLib.

That’s correct. RobotPy uses its own fork of the command library which isn’t compatible with the original command library.

1 Like