wpilibsuite / frc-docs

Official FRC Documentation powered by Read the Docs
https://docs.wpilib.org
Other
148 stars 261 forks source link

Remove usage of robotInit #2679

Open spacey-sooty opened 3 months ago

sciencewhiz commented 3 months ago

There's 109 instances, not including the ones in RemoteLiteralIncludes

Search "robotInit" (109 hits in 25 files of 442 searched)
  C:\Users\chris\Documents\Robotics\frc-docs\source\docs\networking\networking-utilities\portforwarding.rst (4 hits)
    Line 16:       public void robotInit() {
    Line 22:       void Robot::RobotInit {
    Line 42:       public void robotInit() {
    Line 48:       void Robot::RobotInit {
  C:\Users\chris\Documents\Robotics\frc-docs\source\docs\software\advanced-controls\trajectories\trajectory-generation.rst (1 hit)
    Line  70: .. note:: Generating a typical trajectory takes about 10 ms to 25 ms. This isn't long, but it's still highly recommended to generate all trajectories on startup (``robotInit``).
  C:\Users\chris\Documents\Robotics\frc-docs\source\docs\software\basic-programming\alliancecolor.rst (1 hit)
    Line  6: Note that there are three cases: red, blue, and no color yet.  It is important that code handles the third case correctly because the alliance color will not be available until the Driver Station connects.  In particular, code should not assume that the alliance color will be available during constructor methods or `robotInit`, but it should be available by the time `autoInit` or `teleopInit` is called.  FMS will set the alliance color automatically; when not connected to FMS, the alliance color can be set from the Driver Station (see :ref:`"Team Station" on the Operation Tab <docs/software/driverstation/driver-station:Operation Tab>`).
  C:\Users\chris\Documents\Robotics\frc-docs\source\docs\software\basic-programming\java-gc.rst (1 hit)
    Line 145:     public void robotInit() {
  C:\Users\chris\Documents\Robotics\frc-docs\source\docs\software\basic-programming\reading-stacktraces.rst (30 hits)
    Line  45:          Error at frc.robot.Robot.robotInit(Robot.java:24): Unhandled exception: java.lang.NullPointerException
    Line  46:                   at frc.robot.Robot.robotInit(Robot.java:24)
    Line  62:          * ``robotInit`` was the name of the method executing when the error happened.
    Line  64:       * ``robotInit`` is a function in the ``frc.robot.Robot`` package (AKA, your team's code)
    Line  66:       * ``robotInit`` was called from a number of functions from the ``edu.wpi.first.wpilibj`` package (AKA, the WPILib libraries)
    Line  78:                   at frc.robot.Robot.robotInit(Robot.java:24)
    Line  84:       In this case: ``robotInit`` called ``fooInit``, which in turn called ``barInit``, which in turn called ``buggyMethod``. Then, during the execution of ``buggyMethod``, the ``NullPointerException`` occurred.
    Line 109:          * ``RobotInit`` was the name of the method executing when the error happened.
    Line 111:       * ``RobotInit`` is a function in the ``Robot::`` namespace (AKA, your team's code)
    Line 113:       * ``RobotInit`` was called from a number of functions from the ``frc::`` namespace (AKA, the WPILib libraries)
    Line 178:          public void robotInit() {
    Line 188:             void RobotInit() override {
    Line 208:          Error at frc.robot.Robot.robotInit(Robot.java:23): Unhandled exception: java.lang.NullPointerException
    Line 209:                  at frc.robot.Robot.robotInit(Robot.java:23)
    Line 221:       Reading the stack trace, you can see that the issue happened inside of the ``robotInit()`` function, on line 23, and the exception involved "Null Pointer".
    Line 263:          public void robotInit() {
    Line 274:             void RobotInit() override {
    Line 304:          public void robotInit() {
    Line 314:             void RobotInit() override {
    Line 336:          Error at frc.robot.Robot.robotInit(Robot.java:24): Unhandled exception: java.lang.ArithmeticException: / by zero
    Line 337:                  at frc.robot.Robot.robotInit(Robot.java:24)
    Line 392:          public void robotInit() {
    Line 405:             void RobotInit() override {
    Line 438:          public void robotInit() {
    Line 449:             void RobotInit() override {
    Line 471:          Error at frc.robot.Robot.robotInit(Robot.java:25): Unhandled exception: edu.wpi.first.hal.util.AllocationException: Code: -1029
    Line 474:                  at frc.robot.Robot.robotInit(Robot.java:24)
    Line 485:                  at frc.robot.Robot.robotInit(Robot.java:25)
    Line 569:          public void robotInit() {
    Line 583:             void RobotInit() override {
  C:\Users\chris\Documents\Robotics\frc-docs\source\docs\software\basic-programming\robot-preferences.rst (1 hit)
    Line  49: In ``robotInit``, each key is checked to see if it already exists in the Preferences database. The ``containsKey`` method takes one parameter, the key to check if data for that key already exists in the preferences database. If it doesn't exist, a default value is written. The ``setDouble`` method takes two parameters, the key to write and the data to write. There are similar methods for other data types like booleans, ints, and strings.
  C:\Users\chris\Documents\Robotics\frc-docs\source\docs\software\commandbased\structuring-command-based-project.rst (1 hit)
    Line  30: In Java, an instance of ``RobotContainer`` should be constructed during the ``robotInit()`` method - this is important, as most of the declarative robot setup will be called from the ``RobotContainer`` constructor.
  C:\Users\chris\Documents\Robotics\frc-docs\source\docs\software\dashboards\shuffleboard\layouts-with-code\sending-data.rst (1 hit)
    Line  49:       def robotInit(self):
  C:\Users\chris\Documents\Robotics\frc-docs\source\docs\software\dashboards\smartdashboard\choosing-an-autonomous-program-from-smartdashboard.rst (1 hit)
    Line  48: The chooser allows you to pick from a list of defined elements, in this case the strings we defined above. In ``robotInit``, add your options created as strings above using ``setDefaultOption`` or ``addOption``. ``setDefaultOption`` will be the one selected by default when the dashboard starts. The ``putData`` function will push it to the dashboard on your driver station computer.
  C:\Users\chris\Documents\Robotics\frc-docs\source\docs\software\dashboards\smartdashboard\displaying-status-of-commands-and-subsystems.rst (1 hit)
    Line 41: You can display the status of the Scheduler (the code that schedules your commands to run). This is easily done by adding a single line to the ``RobotInit`` method in your RobotProgram as shown here. In this example the Scheduler instance is written using the ``putData`` method to SmartDashboard. This line of code produces the display in the previous image.
  C:\Users\chris\Documents\Robotics\frc-docs\source\docs\software\dashboards\smartdashboard\test-mode-and-live-window\enabling-test-mode.rst (6 hits)
    Line 19:       public void robotInit() {
    Line 25:       void Robot::RobotInit() {
    Line 31:       def robotInit(self) -> None:
    Line 47:       public void robotInit() {
    Line 63:       void Robot::RobotInit() {
    Line 73:       def robotInit(self) -> None:
  C:\Users\chris\Documents\Robotics\frc-docs\source\docs\software\hardware-apis\motors\wpi-drive-classes.rst (6 hits)
    Line  44:       public void robotInit() {
    Line  53:        void RobotInit() override {
    Line  59:       def robotInit(self):
    Line 177:         In robotInit or Subsystem constructor:
    Line 193:         In robotInit or Subsystem constructor:
    Line 206:           def robotInit(self):
  C:\Users\chris\Documents\Robotics\frc-docs\source\docs\software\hardware-apis\sensors\counters.rst (7 hits)
    Line  41:         public void robotInit() {
    Line  56:         void Robot::RobotInit() {
    Line  78:         public void robotInit() {
    Line 125:         public void robotInit() {
    Line 141:         void Robot::RobotInit() {
    Line 164:         public void robotInit() {
    Line 178:         void RobotInit() {
  C:\Users\chris\Documents\Robotics\frc-docs\source\docs\software\hardware-apis\sensors\encoders-software.rst (2 hits)
    Line 484:           public void robotInit() {
    Line 523:         void Robot::RobotInit() {
  C:\Users\chris\Documents\Robotics\frc-docs\source\docs\software\hardware-apis\sensors\gyros-software.rst (12 hits)
    Line 185:         public void robotInit() {
    Line 194:         void Robot::RobotInit() {
    Line 203:         def robotInit(self):
    Line 242:         public void robotInit() {
    Line 282:         void Robot::RobotInit() {
    Line 305:         def robotInit(self):
    Line 365:         public void robotInit() {
    Line 404:         void Robot::RobotInit() {
    Line 426:         def robotInit(self):
    Line 486:         public void robotInit() {
    Line 517:         void Robot::RobotInit() {
    Line 535:         def robotInit(self):
  C:\Users\chris\Documents\Robotics\frc-docs\source\docs\software\kinematics-and-odometry\swerve-drive-odometry.rst (1 hit)
    Line  82:         def robotInit(self):
  C:\Users\chris\Documents\Robotics\frc-docs\source\docs\software\networktables\reading-array-values-published-by-networktables.rst (4 hits)
    Line 17: Both of the following examples are extremely simplified programs that just illustrate the use of NetworkTables. All the code is in the robotInit() method so it's only run when the program starts up. In your programs, you would more likely get the values in code that is evaluating which direction to aim the robot in a command or a control loop during the autonomous or teleop periods.
    Line 29:       public void robotInit() {
    Line 51:       void Robot::RobotInit() override {
    Line 70:         def robotInit(self):
  C:\Users\chris\Documents\Robotics\frc-docs\source\docs\software\networktables\robot-program.rst (3 hits)
    Line  23:           public void robotInit() {
    Line  64:           void RobotInit() {
    Line 102:             def robotInit(self) -> None:
  C:\Users\chris\Documents\Robotics\frc-docs\source\docs\software\pathplanning\pathweaver\integrating-robot-program.rst (2 hits)
    Line 20:       public void robotInit() {
    Line 37:       void Robot::RobotInit() {
  C:\Users\chris\Documents\Robotics\frc-docs\source\docs\software\telemetry\datalog.rst (4 hits)
    Line  26: The most basic usage of DataLogManager only requires a single line of code (typically this would be called from ``robotInit``). This will record all NetworkTables changes to the data log.
    Line 127:         public void robotInit() {
    Line 156:         void RobotInit() {
    Line 187:             def robotInit(self):
  C:\Users\chris\Documents\Robotics\frc-docs\source\docs\software\vision-processing\grip\using-generated-code-in-a-robot-program.rst (2 hits)
    Line  73:         public void robotInit() {
    Line  92: The **robotInit()** method is called once when the program starts up. It creates a **CameraServer** instance that begins
  C:\Users\chris\Documents\Robotics\frc-docs\source\docs\software\vision-processing\roborio\using-multiple-cameras.rst (9 hits)
    Line  22:        public void robotInit() {
    Line  51:        void RobotInit() override {
    Line  81:            def robotInit(self):
    Line 131:        public void robotInit() {
    Line 156:        void RobotInit() override {
    Line 196:        public void robotInit() {
    Line 226:        void RobotInit() override {
    Line 258:            def robotInit(self):
    Line 310:     If you're using Option 3 it will give you this error during ``RobotInit()``. Thus you should just try your desired resolution and adjusting as necessary until you both don't get that error and don't exceed the radio bandwidth limitations.
  C:\Users\chris\Documents\Robotics\frc-docs\source\docs\software\vision-processing\roborio\using-the-cameraserver-on-the-roborio.rst (1 hit)
    Line  33: In the following example a thread created in robotInit() gets the Camera Server instance. Each frame of the video is individually processed, in this case drawing a rectangle on the image using the OpenCV ``rectangle()`` method. The resultant images are then passed to the output stream and sent to the dashboard. You can replace the ``rectangle`` operation with any image processing code that is necessary for your application. You can even annotate the image using OpenCV methods to write targeting information onto the image being sent to the dashboard.
  C:\Users\chris\Documents\Robotics\frc-docs\source\docs\software\wpilib-tools\robotbuilder\introduction\robotbuilder-created-code.rst (3 hits)
    Line  93:                 public void robotInit() {
    Line 199:               void RobotInit() override;
    Line 232:             void Robot::RobotInit() {}
  C:\Users\chris\Documents\Robotics\frc-docs\source\docs\zero-to-robot\step-4\creating-test-drivetrain-program-cpp-java-python.rst (5 hits)
    Line 362:                  def robotInit(self):
    Line 515:          void RobotInit() {}
    Line 522:          def robotInit(self):
    Line 524: The ``RobotInit`` method is run when the robot program is starting up, but after the constructor. The ``RobotInit`` for our sample program inverts the right side of the drivetrain. Depending on your drive setup, you might need to invert the left side instead.
spacey-sooty commented 3 months ago

There shouldn't be any in RLIs? The examples were updated to not have them https://github.com/wpilibsuite/allwpilib/pull/6623

sciencewhiz commented 2 months ago

RLIs are referenced by tag and by line number, both of which need to be updated.

DJB755 commented 2 months ago

I would love to work on this!