RobotInit help

What do I type in robot init or robot periodic to make the code run, I am a nuwbie and I wrote some siple code that I want to test, but it comes up with an error RobotInit 0. I dont know exactly what to do,
Thank you

Can you post your code?

Please take a read through the docs. This should be a good start for your specific question: https://docs.wpilib.org/en/latest/docs/software/wpilib-overview/creating-robot-program.html

1 Like

Three things.

First, I am not sure what you mean by “error RobotInit 0”. Could you provide a stack trace from the exception or a picture of what you referring to?

Second, I do not see anywhere that you are setting an instance of DriveManuallyCommand as the default command of the DriveSubsystem. I looks like you could do this in the RobotContainer constructor. The robot will not drive until you do this.

Third, it would be better practice to make the fields in RobotContainer private (subsystem, joystick, etc) and pass/inject them to the constructors of the commands that need them. For future learning, there is even a better way to deal with joystick axis values using something called lambdas but do not worry about that now. One step at a time.

Hope this helps,
Steve

I’ve also not heard of the error you are saying you see, and it seems impossible because the robotInit() method actually is a void return, so it wouldn’t really ever return 0 as a value.

Feel free to reference (or all out copy) any relevant pieces of code from our github account. At a minimum, here is a link to our Default Command for our DriveTrain object. You can see how the Subystems are all private and instantiated in RobotContainer, and then when needed, they are passed to the individual Commands as a dependency.

Then in the DefaultDrive command linked above, you’ll see the Command assigns a local reference to the dependency it was passed in the constructor, and then later on in the execute method uses that variable to do the driving.

This topic was automatically closed 365 days after the last reply. New replies are no longer allowed.