MockDS

MockDS is a simple internal UDP packet loop that WPILib created for use on the test bench. We have modified its original code for use with the VMX.

MockDS Overview

../../_images/MockDS.svg

MockDS’ lowest level is a C++ real-time thread that runs in the background with the user code. The thread runs a specific UDP message in a loop that will either enable or disable the robot in autonomous mode. Depending on the user code project type, the thread is accessed by either the Studica C++ Lib or the Studica Java Lib.

While a specific user hardware interface, such as a button, is not required, it is recommended. The start button is good for enabling the robot, while the e-stop is good for disabling the robot. The e-stop is preferred as it is latching.

Important

With the layout of MockDS, if the user code gets bogged down or stuck, the robot will stay enabled. This can be potentially dangerous as there will be no way to disable the robot if this happens.

Adding MockDS

MockDS can be added to the robot code by first upgrading the Studica.json to version 1.1.26 or higher.

To upgrade:

  1. Open the Command Pallete in VSCode.

  2. Select: WPILib: Manage Vendor Libraries

  3. Select: Check for updates (online)

  4. Select: Studica.json

  5. Hit yes to build and cache the new library.

MockDS Code

 1// Import the MockDS Library
 2import com.studica.frc.MockDS;
 3
 4public class Robot extends TimedRobot
 5{
 6
 7    private MockDS ds; // Create the object
 8    private boolean active = false; // active flag prevents calling mockds more than once.
 9
10    @Override
11    public void robotInit()
12    {
13        ds = new MockDS(); // Create the instance
14    }
15
16    @Override
17    public void robotPeriodic()
18    {
19        // If the start button is pushed and the system is not active
20        if (!RobotContainer.driveTrain.getStartButton() && !active)
21        {
22            ds.enable(); // enable the robot.
23            active = true;
24        }
25        // If the e-stop is pushed and the system is active
26        if (!RobotContainer.driveTrain.getEStopButton() && active)
27        {
28            ds.disable(); // disable the robot.
29            active = false;
30        }
31    }
32}

Demo Video