diff --git a/source/docs/networking/networking-utilities/portforwarding.rst b/source/docs/networking/networking-utilities/portforwarding.rst index 56db516a75..4e9810d59c 100644 --- a/source/docs/networking/networking-utilities/portforwarding.rst +++ b/source/docs/networking/networking-utilities/portforwarding.rst @@ -9,14 +9,13 @@ Often teams may wish to connect directly to the roboRIO for controlling their ro .. tab-set-code:: ```java - @Override - public void robotInit() { + public Robot() { PortForwarder.add(8888, "wpilibpi.local", 80); } ``` ```c++ - void Robot::RobotInit { + Robot::Robot() { wpi::PortForwarder::GetInstance().Add(8888, "wpilibpi.local", 80); } ``` @@ -34,14 +33,13 @@ To stop forwarding on a specified port, simply call ``remove(int port)`` with po .. tab-set-code:: ```java - @Override - public void robotInit() { + public Robot() { PortForwarder.remove(8888); } ``` ```c++ - void Robot::RobotInit { + Robot::Robot() { wpi::PortForwarder::GetInstance().Remove(8888); } ``` diff --git a/source/docs/software/advanced-controls/trajectories/trajectory-generation.rst b/source/docs/software/advanced-controls/trajectories/trajectory-generation.rst index e408bda5a1..532189ca7f 100644 --- a/source/docs/software/advanced-controls/trajectories/trajectory-generation.rst +++ b/source/docs/software/advanced-controls/trajectories/trajectory-generation.rst @@ -63,7 +63,7 @@ Here is an example of generating a trajectory using clamped cubic splines for th .. note:: The Java code utilizes the [Units](https://github.wpilib.org/allwpilib/docs/development/java/edu/wpi/first/math/util/Units.html) utility, for easy unit conversions. -.. 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``). +.. 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 in the ``Robot`` constructor. ## Concatenating Trajectories diff --git a/source/docs/software/basic-programming/java-gc.rst b/source/docs/software/basic-programming/java-gc.rst index 0ff2acdfdb..a90eb3b48c 100644 --- a/source/docs/software/basic-programming/java-gc.rst +++ b/source/docs/software/basic-programming/java-gc.rst @@ -130,7 +130,7 @@ Sometimes the garbage collector won't run frequently enough to keep up with the ```java Timer m_gcTimer = new Timer(); -public void robotInit() { +public Robot() { m_gcTimer.start(); } public void periodic() { diff --git a/source/docs/software/basic-programming/robot-preferences.rst b/source/docs/software/basic-programming/robot-preferences.rst index 7a2560f45d..87328f6627 100644 --- a/source/docs/software/basic-programming/robot-preferences.rst +++ b/source/docs/software/basic-programming/robot-preferences.rst @@ -44,7 +44,7 @@ This example shows how to utilize Preferences to change the setpoint of a PID co Preferences are stored using a name, the key. It's helpful to store the key in a constant, like ``kArmPositionKey`` and ``kArmPKey`` in the code above to avoid typing it multiple times and avoid typos. We also declare variables, ``kArmKp`` and ``armPositionDeg`` to hold the data retrieved from preferences. -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. +In ``Arm`` constructor, 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. If using the Command Framework, this type of code could be placed in the constructor of a Subsystem or Command. diff --git a/source/docs/software/dashboards/smartdashboard/displaying-status-of-commands-and-subsystems.rst b/source/docs/software/dashboards/smartdashboard/displaying-status-of-commands-and-subsystems.rst index 2c628244e7..9162aa8901 100644 --- a/source/docs/software/dashboards/smartdashboard/displaying-status-of-commands-and-subsystems.rst +++ b/source/docs/software/dashboards/smartdashboard/displaying-status-of-commands-and-subsystems.rst @@ -34,7 +34,7 @@ In the following examples, you'll see what the screen would look like when there SmartDashboard.putData(CommandScheduler.getInstance()) ``` -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. +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 ``Robot`` constructor in your Robot program 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. .. image:: images/displaying-status-of-commands-and-subsystems/commands-running.png :alt: The schedulers is showing which commands are being run. diff --git a/source/docs/software/dashboards/smartdashboard/test-mode-and-live-window/enabling-test-mode.rst b/source/docs/software/dashboards/smartdashboard/test-mode-and-live-window/enabling-test-mode.rst index 6477f9ae46..b2c4592f1a 100644 --- a/source/docs/software/dashboards/smartdashboard/test-mode-and-live-window/enabling-test-mode.rst +++ b/source/docs/software/dashboards/smartdashboard/test-mode-and-live-window/enabling-test-mode.rst @@ -12,14 +12,13 @@ To run LiveWindow in Test Mode, the following code is needed in the ``Robot`` cl .. tab-set-code:: ```java - @Override - public void robotInit() { + public Robot() { enableLiveWindowInTest(true); } ``` ```c++ - void Robot::RobotInit() { + Robot::Robot() { EnableLiveWindowInTest(true); } ``` @@ -38,8 +37,8 @@ To run LiveWindow in Test Mode, the following code is needed in the ``Robot`` cl PWMSparkMax rightDrive; PWMVictorSPX arm; BuiltInAccelerometer accel; - @Override - public void robotInit() { + + public Robot() { leftDrive = new PWMSparkMax(0); rightDrive = new PWMSparkMax(1); arm = new PWMVictorSPX(2); @@ -54,7 +53,7 @@ To run LiveWindow in Test Mode, the following code is needed in the ``Robot`` cl frc::PWMSparkMax rigthDrive{1}; frc::BuiltInAccelerometer accel{}; frc::PWMVictorSPX arm{3}; - void Robot::RobotInit() { + Robot::Robot() { wpi::SendableRegistry::SetName(&arm, "SomeSubsystem", "Arm"); wpi::SendableRegistry::SetName(&accel, "SomeSubsystem", "Accelerometer"); } diff --git a/source/docs/software/hardware-apis/motors/wpi-drive-classes.rst b/source/docs/software/hardware-apis/motors/wpi-drive-classes.rst index 208fb3bbc8..0eb728feff 100644 --- a/source/docs/software/hardware-apis/motors/wpi-drive-classes.rst +++ b/source/docs/software/hardware-apis/motors/wpi-drive-classes.rst @@ -32,8 +32,8 @@ It is the responsibility of the user to manage proper inversions for their drive ```java PWMSparkMax m_motorRight = new PWMSparkMax(0); - @Override - public void robotInit() { + + public Robot() { m_motorRight.setInverted(true); } ``` @@ -41,7 +41,7 @@ It is the responsibility of the user to manage proper inversions for their drive ```c++ frc::PWMSparkMax m_motorLeft{0}; public: - void RobotInit() override { + Robot::Robot() { m_motorRight.SetInverted(true); } ``` @@ -159,7 +159,7 @@ Many FRC\ |reg| drivetrains have more than 1 motor on each side. Classes derived :language: java :lines: 19-25 - In robotInit or Subsystem constructor: + In Robot or Subsystem constructor: .. remoteliteralinclude:: https://raw.githubusercontent.com/wpilibsuite/allwpilib/v2024.3.2/wpilibjExamples/src/main/java/edu/wpi/first/wpilibj/examples/ramsetecommand/subsystems/DriveSubsystem.java :language: java @@ -175,7 +175,7 @@ Many FRC\ |reg| drivetrains have more than 1 motor on each side. Classes derived .. tab-item:: C++ (Source) :sync: C++ (Source) - In robotInit or Subsystem constructor: + In Robot or Subsystem constructor: .. remoteliteralinclude:: https://raw.githubusercontent.com/wpilibsuite/allwpilib/v2024.3.2/wpilibcExamples/src/main/cpp/examples/RamseteCommand/cpp/subsystems/DriveSubsystem.cpp :language: c++ diff --git a/source/docs/software/hardware-apis/sensors/counters.rst b/source/docs/software/hardware-apis/sensors/counters.rst index ae842a1313..880a03468c 100644 --- a/source/docs/software/hardware-apis/sensors/counters.rst +++ b/source/docs/software/hardware-apis/sensors/counters.rst @@ -31,8 +31,8 @@ In two-pulse mode, the :code:`Counter` will count up for every edge/pulse on the ```java // Create a new Counter object in two-pulse mode Counter counter = new Counter(Counter.Mode.k2Pulse); - @Override - public void robotInit() { + + public Robot() { // Set up the input channels for the counter counter.setUpSource(1); counter.setDownSource(2); @@ -45,7 +45,7 @@ In two-pulse mode, the :code:`Counter` will count up for every edge/pulse on the ```c++ // Create a new Counter object in two-pulse mode frc::Counter counter{frc::Counter::Mode::k2Pulse}; - void Robot::RobotInit() { + Robot::Robot() { // Set up the input channels for the counter counter.SetUpSource(1); counter.SetDownSource(2); @@ -63,8 +63,8 @@ In semi-period mode, the :code:`Counter` will count the duration of the pulses o ```java // Create a new Counter object in two-pulse mode Counter counter = new Counter(Counter.Mode.kSemiperiod); - @Override - public void robotInit() { + + public Robot() { // Set up the input channel for the counter counter.setUpSource(1); // Set the encoder to count pulse duration from rising edge to falling edge @@ -105,8 +105,8 @@ In pulse-length mode, the counter will count either up or down depending on the ```java // Create a new Counter object in two-pulse mode Counter counter = new Counter(Counter.Mode.kPulseLength); - @Override - public void robotInit() { + + public Robot() { // Set up the input channel for the counter counter.setUpSource(1); // Set the decoding type to 2X @@ -119,7 +119,7 @@ In pulse-length mode, the counter will count either up or down depending on the ```c++ // Create a new Counter object in two-pulse mode frc::Counter counter{frc::Counter::Mode::kPulseLength}; - void Robot::RobotInit() { + Robot::Robot() { // Set up the input channel for the counter counter.SetUpSource(1); // Set the decoding type to 2X @@ -137,8 +137,8 @@ In external direction mode, the counter counts either up or down depending on th ```java // Create a new Counter object in two-pulse mode Counter counter = new Counter(Counter.Mode.kExternalDirection); - @Override - public void robotInit() { + + public Robot() { // Set up the input channels for the counter counter.setUpSource(1); counter.setDownSource(2); diff --git a/source/docs/software/hardware-apis/sensors/encoders-software.rst b/source/docs/software/hardware-apis/sensors/encoders-software.rst index 132c3c055f..9f34c2e208 100644 --- a/source/docs/software/hardware-apis/sensors/encoders-software.rst +++ b/source/docs/software/hardware-apis/sensors/encoders-software.rst @@ -430,8 +430,8 @@ Encoders can be used on a robot drive to create a simple "drive to distance" rou Spark rightLeader = new Spark(2); Spark rightFollower = new Spark(3); DifferentialDrive drive = new DifferentialDrive(leftLeader::set, rightLeader::set); - @Override - public void robotInit() { + + public Robot() { // Configures the encoder's distance-per-pulse // The robot moves forward 1 foot per encoder rotation // There are 256 pulses per encoder rotation @@ -442,6 +442,7 @@ Encoders can be used on a robot drive to create a simple "drive to distance" rou leftLeader.addFollower(leftFollower); rightLeader.addFollower(rightFollower); } + @Override public void autonomousPeriodic() { // Drives forward at half speed until the robot has moved 5 feet, then stops: @@ -463,7 +464,7 @@ Encoders can be used on a robot drive to create a simple "drive to distance" rou frc::Spark rightFollower{3}; frc::DifferentialDrive drive{[&](double output) { leftLeader.Set(output); }, [&](double output) { rightLeader.Set(output); }}; - void Robot::RobotInit() { + Robot::Robot() { // Configures the encoder's distance-per-pulse // The robot moves forward 1 foot per encoder rotation // There are 256 pulses per encoder rotation diff --git a/source/docs/software/hardware-apis/sensors/gyros-software.rst b/source/docs/software/hardware-apis/sensors/gyros-software.rst index f15d66151f..65644d4020 100644 --- a/source/docs/software/hardware-apis/sensors/gyros-software.rst +++ b/source/docs/software/hardware-apis/sensors/gyros-software.rst @@ -162,7 +162,7 @@ Gyros are extremely useful in FRC for both measuring and controlling robot headi ```java // Use gyro declaration from above here - public void robotInit() { + public Robot() { // Places a compass indicator for the gyro heading on the dashboard Shuffleboard.getTab("Example tab").add(gyro); } @@ -170,7 +170,7 @@ Gyros are extremely useful in FRC for both measuring and controlling robot headi ```c++ // Use gyro declaration from above here - void Robot::RobotInit() { + Robot::Robot() { // Places a compass indicator for the gyro heading on the dashboard frc::Shuffleboard.GetTab("Example tab").Add(gyro); } @@ -208,8 +208,8 @@ The following example shows how to stabilize heading using a simple P loop close Spark rightLeader = new Spark(2); Spark rightFollower = new Spark(3); DifferentialDrive drive = new DifferentialDrive(leftLeader::set, rightLeader::set); - @Override - public void robotInit() { + + public Robot() { // Configures the encoder's distance-per-pulse // The robot moves forward 1 foot per encoder rotation // There are 256 pulses per encoder rotation @@ -220,6 +220,7 @@ The following example shows how to stabilize heading using a simple P loop close leftLeader.addFollower(leftFollower); rightLeader.addFollower(rightFollower); } + @Override public void autonomousPeriodic() { // Setpoint is implicitly 0, since we don't want the heading to change @@ -240,7 +241,7 @@ The following example shows how to stabilize heading using a simple P loop close frc::Spark rightFollower{3}; frc::DifferentialDrive drive{[&](double output) { leftLeader.Set(output); }, [&](double output) { rightLeader.Set(output); }}; - void Robot::RobotInit() { + Robot::Robot() { // Invert the right side of the drivetrain. You might have to invert the other side rightLeader.SetInverted(true); // Configure the followers to follow the leaders @@ -303,15 +304,17 @@ The following example shows how to stabilize heading using a simple P loop close MotorControllerGroup leftMotors = new MotorControllerGroup(left1, left2); MotorControllerGroup rightMotors = new MotorControllerGroup(right1, right2); DifferentialDrive drive = new DifferentialDrive(leftMotors, rightMotors); - @Override - public void robotInit() { + + public Robot() { rightMotors.setInverted(true); } + @Override public void autonomousInit() { // Set setpoint to current heading at start of auto heading = gyro.getAngle(); } + @Override public void autonomousPeriodic() { double error = heading - gyro.getAngle(); @@ -334,7 +337,7 @@ The following example shows how to stabilize heading using a simple P loop close frc::MotorControllerGroup leftMotors{left1, left2}; frc::MotorControllerGroup rightMotors{right1, right2}; frc::DifferentialDrive drive{leftMotors, rightMotors}; - void Robot::RobotInit() { + Robot::Robot() { rightMotors.SetInverted(true); } void Robot::AutonomousInit() { @@ -396,10 +399,11 @@ Much like with heading stabilization, this is often accomplished with a PID loop MotorControllerGroup leftMotors = new MotorControllerGroup(left1, left2); MotorControllerGroup rightMotors = new MotorControllerGroup(right1, right2); DifferentialDrive drive = new DifferentialDrive(leftMotors, rightMotors); - @Override - public void robotInit() { + + public Robot() { rightMotors.setInverted(true); } + @Override public void autonomousPeriodic() { // Find the heading error; setpoint is 90 @@ -421,7 +425,7 @@ Much like with heading stabilization, this is often accomplished with a PID loop frc::MotorControllerGroup leftMotors{left1, left2}; frc::MotorControllerGroup rightMotors{right1, right2}; frc::DifferentialDrive drive{leftMotors, rightMotors}; - void Robot::RobotInit() { + Robot::Robot() { rightMotors.SetInverted(true); } void Robot::AutonomousPeriodic() { diff --git a/source/docs/software/networktables/reading-array-values-published-by-networktables.rst b/source/docs/software/networktables/reading-array-values-published-by-networktables.rst index 6683323a8a..394761d1d8 100644 --- a/source/docs/software/networktables/reading-array-values-published-by-networktables.rst +++ b/source/docs/software/networktables/reading-array-values-published-by-networktables.rst @@ -20,11 +20,12 @@ Both of the following examples are extremely simplified programs that just illus ```java DoubleArraySubscriber areasSub; - @Override - public void robotInit() { + + public Robot() { NetworkTable table = NetworkTableInstance.getDefault().getTable("GRIP/mycontoursReport"); areasSub = table.getDoubleArrayTopic("area").subscribe(new double[] {}); } + @Override public void teleopPeriodic() { double[] areas = areasSub.get(); @@ -38,7 +39,7 @@ Both of the following examples are extremely simplified programs that just illus ```c++ nt::DoubleArraySubscriber areasSub; - void Robot::RobotInit() override { + Robot::Robot() { auto table = nt::NetworkTableInstance::GetDefault().GetTable("GRIP/myContoursReport"); areasSub = table->GetDoubleArrayTopic("area").Subscribe({}); } diff --git a/source/docs/software/networktables/robot-program.rst b/source/docs/software/networktables/robot-program.rst index b8d52203db..a307840c9c 100644 --- a/source/docs/software/networktables/robot-program.rst +++ b/source/docs/software/networktables/robot-program.rst @@ -15,7 +15,8 @@ The example robot program below publishes incrementing X and Y values to a table public class EasyNetworkTableExample extends TimedRobot { DoublePublisher xPub; DoublePublisher yPub; - public void robotInit() { + + public Robot() { // Get the default instance of NetworkTables that was created automatically // when the robot program starts NetworkTableInstance inst = NetworkTableInstance.getDefault(); @@ -29,6 +30,7 @@ The example robot program below publishes incrementing X and Y values to a table xPub = table.getDoubleTopic("x").publish(); yPub = table.getDoubleTopic("y").publish(); } + double x = 0; double y = 0; public void teleopPeriodic() { @@ -50,7 +52,7 @@ The example robot program below publishes incrementing X and Y values to a table public: nt::DoublePublisher xPub; nt::DoublePublisher yPub; - void RobotInit() { + Robot() { // Get the default instance of NetworkTables that was created automatically // when the robot program starts auto inst = nt::NetworkTableInstance::GetDefault(); diff --git a/source/docs/software/pathplanning/pathweaver/integrating-robot-program.rst b/source/docs/software/pathplanning/pathweaver/integrating-robot-program.rst index e5d69bd3e0..df723a536d 100644 --- a/source/docs/software/pathplanning/pathweaver/integrating-robot-program.rst +++ b/source/docs/software/pathplanning/pathweaver/integrating-robot-program.rst @@ -13,8 +13,8 @@ The ``fromPathweaverJson`` (Java) / ``FromPathweaverJson`` (C++) static methods ```java String trajectoryJSON = "paths/YourPath.wpilib.json"; Trajectory trajectory = new Trajectory(); - @Override - public void robotInit() { + + public Robot() { try { Path trajectoryPath = Filesystem.getDeployDirectory().toPath().resolve(trajectoryJSON); trajectory = TrajectoryUtil.fromPathweaverJson(trajectoryPath); @@ -29,7 +29,7 @@ The ``fromPathweaverJson`` (Java) / ``FromPathweaverJson`` (C++) static methods #include #include frc::Trajectory trajectory; - void Robot::RobotInit() { + Robot::Robot()) { fs::path deployDirectory = frc::filesystem::GetDeployDirectory(); deployDirectory = deployDirectory / "paths" / "YourPath.wpilib.json"; trajectory = frc::TrajectoryUtil::FromPathweaverJson(deployDirectory.string()); diff --git a/source/docs/software/telemetry/datalog.rst b/source/docs/software/telemetry/datalog.rst index 34f956da34..10e7f22f6c 100644 --- a/source/docs/software/telemetry/datalog.rst +++ b/source/docs/software/telemetry/datalog.rst @@ -20,7 +20,7 @@ Log files are initially named ``FRC_TBD_{random}.wpilog`` until the DS connects. On startup, all existing log files where a DS has not been connected will be deleted. If there is less than 50 MB of free space on the target storage, ``FRC_`` log files are deleted (oldest to newest) until there is 50 MB free OR there are 10 files remaining. -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. +The most basic usage of DataLogManager only requires a single line of code (typically this would be called from ``Robot`` constructor). This will record all NetworkTables changes to the data log. .. tab-set-code:: @@ -104,7 +104,8 @@ The LogEntry classes can be used in conjunction with DataLogManager to record va BooleanLogEntry myBooleanLog; DoubleLogEntry myDoubleLog; StringLogEntry myStringLog; - public void robotInit() { + + public Robot() { // Starts recording to data log DataLogManager.start(); // Set up custom log entries @@ -129,7 +130,7 @@ The LogEntry classes can be used in conjunction with DataLogManager to record va wpi::log::BooleanLogEntry myBooleanLog; wpi::log::DoubleLogEntry myDoubleLog; wpi::log::StringLogEntry myStringLog; - void RobotInit() { + Robot() { // Starts recording to data log frc::DataLogManager::Start(); // Set up custom log entries diff --git a/source/docs/software/vision-processing/roborio/using-multiple-cameras.rst b/source/docs/software/vision-processing/roborio/using-multiple-cameras.rst index 1e3ee1e1f5..05dc64ad9a 100644 --- a/source/docs/software/vision-processing/roborio/using-multiple-cameras.rst +++ b/source/docs/software/vision-processing/roborio/using-multiple-cameras.rst @@ -14,8 +14,8 @@ If you're interested in just switching what the driver sees, and are using Smart UsbCamera camera2; Joystick joy1 = new Joystick(0); NetworkTableEntry cameraSelection; - @Override - public void robotInit() { + + public Robot() { camera1 = CameraServer.startAutomaticCapture(0); camera2 = CameraServer.startAutomaticCapture(1); cameraSelection = NetworkTableInstance.getDefault().getTable("").getEntry("CameraSelection"); @@ -40,7 +40,7 @@ If you're interested in just switching what the driver sees, and are using Smart cs::UsbCamera camera2; frc::Joystick joy1{0}; nt::NetworkTableEntry cameraSelection; - void RobotInit() override { + Robot() { camera1 = frc::CameraServer::StartAutomaticCapture(0); camera2 = frc::CameraServer::StartAutomaticCapture(1); cameraSelection = nt::NetworkTableInstance::GetDefault().GetTable("")->GetEntry("CameraSelection"); @@ -109,8 +109,8 @@ If you're using some other dashboard, you can change the camera used by the came UsbCamera camera2; VideoSink server; Joystick joy1 = new Joystick(0); - @Override - public void robotInit() { + + public Robot() { camera1 = CameraServer.startAutomaticCapture(0); camera2 = CameraServer.startAutomaticCapture(1); server = CameraServer.getServer(); @@ -133,7 +133,7 @@ If you're using some other dashboard, you can change the camera used by the came cs::VideoSink server; frc::Joystick joy1{0}; bool prevTrigger = false; - void RobotInit() override { + Robot() { camera1 = frc::CameraServer::StartAutomaticCapture(0); camera2 = frc::CameraServer::StartAutomaticCapture(1); server = frc::CameraServer::GetServer(); @@ -169,8 +169,8 @@ By default, the cscore library is pretty aggressive in turning off cameras not i UsbCamera camera2; VideoSink server; Joystick joy1 = new Joystick(0); - @Override - public void robotInit() { + + public Robot() { camera1 = CameraServer.startAutomaticCapture(0); camera2 = CameraServer.startAutomaticCapture(1); server = CameraServer.getServer(); @@ -198,7 +198,7 @@ By default, the cscore library is pretty aggressive in turning off cameras not i cs::VideoSink server; frc::Joystick joy1{0}; bool prevTrigger = false; - void RobotInit() override { + Robot() { camera1 = frc::CameraServer::StartAutomaticCapture(0); camera2 = frc::CameraServer::StartAutomaticCapture(1); server = frc::CameraServer::GetServer(); @@ -274,4 +274,4 @@ By default, the cscore library is pretty aggressive in turning off cameras not i (VIDIOC_STREAMON: No space left on device) ``` - 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. + If you're using Option 3 it will give you this error during the ``Robot`` constructor. 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. diff --git a/source/docs/software/vision-processing/roborio/using-the-cameraserver-on-the-roborio.rst b/source/docs/software/vision-processing/roborio/using-the-cameraserver-on-the-roborio.rst index 3154ae81a0..46a071b940 100644 --- a/source/docs/software/vision-processing/roborio/using-the-cameraserver-on-the-roborio.rst +++ b/source/docs/software/vision-processing/roborio/using-the-cameraserver-on-the-roborio.rst @@ -27,7 +27,7 @@ The following program starts automatic capture of a USB camera like the Microsof ## Advanced Camera Server Program -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. +In the following example a thread created in ``Robot`` constructor 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. .. tab-set::