Skip to content

SmartDashboard / Cameras

SmartDashboard is a key component in the FRC Control System produced by FIRST. It's a desktop application that provides a real-time view of the operation of your robot, by displaying values from your robot code. Whether you want to monitor sensor readings, tune parameters, or pick autonomous modes, SmartDashboard plays an integral role.

Writing Data to SmartDashboard

To send data from your robot code to the SmartDashboard, use the static putXXX methods in the SmartDashboard class. Here's a breakdown:

  1. Sending Basic Data Types
    • Numbers: SmartDashboard.putNumber("Speed", 5.5);
    • Strings: SmartDashboard.putString("Status", "Running");
    • Booleans: SmartDashboard.putBoolean("Is Active", true);
  2. Sending Complex Data Types
    • For any data type implementing the Sendable interface, you can put it directly:
      AnalogPotentiometer pot = new AnalogPotentiometer(1);
      SmartDashboard.putData("Potentiometer", pot);
      

Reading Data from SmartDashboard

Reading from the SmartDashboard allows your robot to react to inputs or configurations set by drivers or operators.

Fetching Basic Data Types - Numbers: double speed = SmartDashboard.getNumber("Speed", 0.0); - Strings: String status = SmartDashboard.getString("Status", "Default"); - Booleans: boolean isActive = SmartDashboard.getBoolean("Is Active", false);

The second argument in each method is a default value, which is returned if the specified key does not exist.

Widgets and Layouts

The data you put on the SmartDashboard can be represented in various ways, called widgets. By default, SmartDashboard selects an appropriate widget based on the type of data. However, you can change this by right-clicking on an entry and selecting another widget.

SmartDashboard also supports different layouts to help organize your data in a more logical or aesthetically pleasing manner. Experiment with the "Add" menu on SmartDashboard to see available options.

Integrating Camera Feed with SmartDashboard

A live camera feed can be invaluable for FRC teams, whether it's for drivers to better navigate the field or for processing images on the fly. The WPILib suite, in tandem with SmartDashboard, makes streaming a camera feed straightforward.

Setting Up the Camera

  1. Connect the Camera: Most teams use USB cameras due to their simplicity. Connect your camera to the roboRIO's USB port.

  2. Initialize the Camera in Code: You can utilize the CameraServer class to quickly start streaming a camera feed.

    import edu.wpi.first.cameraserver.CameraServer;

    // In your robot's initialization code: CameraServer.getInstance().startAutomaticCapture(); The above code automatically configures the camera with default settings and starts streaming.

Viewing Camera Feed on SmartDashboard

  1. Open SmartDashboard: Once you've initialized your camera in code and the robot code is running, open the SmartDashboard.

  2. Add the Camera Stream: From the SmartDashboard menu, click on View > Add > Camera Stream. If your camera is streaming correctly, it should appear in the dropdown list. Select it, and the stream will appear on your SmartDashboard.

  3. Position and Resize: Like other widgets on the SmartDashboard, you can move and resize the camera stream to fit your layout preferences.

Additional Features

  • Multiple Cameras: If you have multiple cameras on your robot, you can initialize each one and give them distinct names. This allows you to switch between different views on the SmartDashboard. CameraServer.getInstance().startAutomaticCapture(0).setName("Front Camera"); CameraServer.getInstance().startAutomaticCapture(1).setName("Rear Camera");
  • Adjusting Camera Settings: Many USB cameras allow settings adjustments like resolution, frames per second (FPS), and brightness. Refer to the camera's documentation and WPILib's UsbCamera class to tweak these settings programmatically.

Tasks

  1. Set up a basic robot project and write code that sends a variety of data types to the SmartDashboard.
  2. Experiment with retrieving data in your robot code that you set directly on the SmartDashboard.
  3. Connect a USB camera to your roboRIO and initialize it in your robot code.
  4. Display the camera feed on the SmartDashboard and adjust its position and size.
  5. Organize your dashboard using a layout of your choice.

Additional Resources

WPILib: SmartDashboard Basics

WPILib: Using the CameraServer on the roboRIO