Paul's Tutorials - logo4-1Initialization Routines



A lot of chapter 1 was spent discussing the initialization of various components on the robot, but we still have not yet discussed the individual initialization routines.

It is important to note that the initialization routines being referred to in this lesson are not the class constructor, which is used for component and variable initialization.

RobotInit()

This routine is the second function that is run on robot power-up (barring boot sequences, after the class constructor). This routine is used to perform any other initialization that needs to be performed before the robot moves into a periodic routine that was not performed within the class constructor. What goes here is generally specific to the robot being programmed.

Preparing for a Periodic Routine

Sometimes it is necessary to put the robot in a certain state before launching a periodic routine. Instead of putting in a loop counter and checking if it is the first loop, we instead use the initialization functions provided in the IterativeRobot() class. The roboRIO always runs these functions the CPU loop before entering the associated mode.

Each initialization function is named similarly to its periodic relative, giving the name of the associated mode before Init.

Note that, for each of these functions, (DisabledInit, AutonomousInit, and TeleopInit), all of the restrictions for the associated mode still apply (those for Disabled and Autonomous you will learn later). Additionally, it is usually a good idea not to actuate motors during initialization routines.

Activity

There is nothing that can be readily performed in an activity at this point. If you want, you can play around with initialization routines (do so safely and according to mode limitations!), otherwise, continue to the next lesson.


← Chapter 4 Overview 4-1 Initialization Routines 4-2 Disabled Routines →