Skip to main content

MockDS

MockDS provides a simple internal UDP packet loop that WPILib created for use on the test bench. Studica modified the original code for VMX support.

MockDS Overview​

C++ Thread
JNI
Java Lib
C++ Lib
Start Button
Stop / E-Stop
User Code

At the lowest level, MockDS uses a C++ real-time thread that runs in the background alongside the user code. The thread continuously sends a specific UDP message that either enables or disables the robot in autonomous mode. Depending on the user code project type, either the Studica C++ Lib or the Studica Java Lib accesses the thread.

While MockDS does not require a specific user hardware interface, such as a button, Studica recommends one. Use the start button to enable the robot, and use the e-stop to disable the robot. Prefer the e-stop because it latches.

important

With the layout of MockDS, if the user code gets bogged down or stuck, the robot will stay enabled. This can create a dangerous condition because the user may have no way to disable the robot.

Adding MockDS​

Add MockDS to the robot code by first upgrading Studica.json to version 2.0.0 or higher.

To Upgrade:

  1. Open the Command Palette in VS Code.
  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​

// Import the MockDS Library
import com.studica.frc.MockDS;

public class Robot extends TimedRobot
{

private MockDS ds; // Create the object
private boolean active = false; // active flag prevents calling mockds more than once.

@Override
public void robotInit()
{
ds = new MockDS(); // Create the instance
}

@Override
public void robotPeriodic()
{
// If the start button is pushed and the system is not active
if (!RobotContainer.driveTrain.getStartButton() && !active)
{
ds.enable(); // enable the robot.
active = true;
}
// If the e-stop is pushed and the system is active
if (!RobotContainer.driveTrain.getEStopButton() && active)
{
ds.disable(); // disable the robot.
active = false;
}
}
}

Demo Video​