halsim_gui extension provides a powerful graphical interface for visualizing robot hardware, controlling inputs, and monitoring outputs during simulation.
Starting the GUI
The simulation GUI automatically launches when you run examples or robot programs in simulation mode, provided thehalsim_gui extension is enabled (which it is by default).
GUI Overview
When the simulation GUI opens, you’ll see:- Window title: “Robot Simulation”
- Default size: 1280x720 pixels
- Docking enabled: Shift+drag to dock windows
- Main menu bar: Access to Hardware, NetworkTables, DS, Plot, and Window menus
GUI Architecture
The GUI is built using:- ImGui: Immediate mode GUI framework
- Glass: WPILib’s visualization library
- wpigui: WPILib’s GUI framework wrapper
simgui storage location.
Hardware Menu
The Hardware menu provides access to all simulated hardware devices.Available Hardware Windows
- Accelerometer: Built-in and external accelerometers
- Addressable LED: LED strip visualization and control
- Analog Gyro: Gyroscope simulation
- Analog Input: Analog sensor inputs
- Analog Output: Analog outputs
- DIO (Digital I/O): Digital input/output pins
- Encoder: Quadrature encoder simulation
- Joystick: Joystick/controller input simulation
- PCM (Pneumatics Control Module): Compressor and solenoid control
- PH (Pneumatic Hub): REV Pneumatic Hub simulation
- Power Distribution: Power distribution panel monitoring
- PWM: PWM motor controller outputs
- Relay: Relay outputs (spike, victor, etc.)
- RoboRIO: roboRIO system information
- Solenoids: Consolidated solenoid view
Using Hardware Windows
Each hardware window shows:- Device list: All initialized devices of that type
- Input controls: Sliders, checkboxes, or text fields for inputs
- Output displays: Read-only values showing robot outputs
- Connection status: Whether the device is initialized
Hardware windows only appear for devices that your robot code has initialized. If you don’t see a device, make sure your code creates an instance of it.
Driver Station (DS) Menu
Control robot state and view Driver Station information.DS Controls
- Robot State: Enable/disable robot in TeleOp, Autonomous, or Test mode
- E-Stop: Emergency stop button
- FMS: Simulate Field Management System connection
- Alliance: Set red or blue alliance
- Station: Set driver station position (1, 2, or 3)
- Game Data: Send game-specific data to robot
- Match Time: Control match timer
Joystick Simulation
The DS window includes joystick/gamepad simulation:- Keyboard mapping: Use keyboard as a virtual joystick
- Axis controls: Sliders for analog axes
- Button controls: Checkboxes for buttons
- POV/D-pad: Directional pad control
NetworkTables Menu
View and edit NetworkTables values in real-time.NetworkTables Features
- Tree view: Hierarchical display of all tables and entries
- Value editing: Click to edit number, string, and boolean values
- Type indicators: Icons show value types
- Auto-refresh: Values update automatically
- Search: Filter entries by name
Publishing Custom Data
Robot code can publish data for GUI visualization:SmartDashboard/.
Plot Menu
Create real-time plots of numeric values.Creating Plots
Plot Controls
- Pause All Plots: Freeze all plot updates
- Clear: Reset plot data
- Export: Save plot data to CSV
- Zoom: Scroll wheel to zoom, drag to pan
Window Menu
Manage open windows and layouts.Window Management
- List of windows: Checkboxes to show/hide each window
- Reset Layout: Restore default window positions
- Save Layout: Save current arrangement
- Load Layout: Restore saved arrangement
Docking System
The GUI uses ImGui’s docking system for flexible layouts:How to Dock Windows
Docking Positions
- Center: Create tabbed windows
- Top/Bottom/Left/Right: Split the space
- Outside: Dock to main window edges
Simulating Common Scenarios
Example: Testing an Elevator
Example: Testing Autonomous
GUI Extension API
Other simulation extensions can integrate with the GUI.Registering with GUI
Custom extensions can add GUI elements:Available Extension Points
- HALSIMGUI_EXT_ADDGUIINIT: Run during GUI initialization
- HALSIMGUI_EXT_ADDGUILATEEXECUTE: Run after main GUI update
- HALSIMGUI_EXT_ADDGUIEARLYEXECUTE: Run before main GUI update
- HALSIMGUI_EXT_GUIEXIT: Run during GUI shutdown
- HALSIMGUI_EXT_GETGUICONTEXT: Get wpigui context pointer
- HALSIMGUI_EXT_GETGLASSCONTEXT: Get Glass context pointer
- HALSIMGUI_EXT_GETIMGUICONTEXT: Get ImGui context pointer
Creating Custom Windows
Add custom visualization windows:Configuration Files
GUI settings are saved tosimgui.json in your project directory:
- Commit: Share layouts across your team
- Edit manually: Customize beyond GUI capabilities
- Reset: Delete file to restore defaults
WebSocket Server Integration
Thehalsim_ws_server extension works alongside the GUI to enable web-based visualization.
Configuration
Configure the WebSocket server via environment variables:- HALSIMWS_PORT: Server port (default: 3300)
- HALSIMWS_URI: WebSocket URI (default: “/wpilibws”)
- HALSIMWS_SYSROOT: HTML files directory (default:
./sim) - HALSIMWS_USERROOT: User files directory (default:
./sim/user)
Using the WebSocket Server
ws://localhost:3300/wpilibws to receive hardware state updates.
Keyboard Shortcuts
| Shortcut | Action |
|---|---|
| Shift + Drag | Enable window docking |
| Ctrl + Tab | Cycle through docked tabs |
| Space | Toggle robot enable (in DS window) |
| Esc | Close focused window |
Performance Tips
Reduce Window Count
Only open hardware windows you need - each window adds rendering overhead.Limit Plot History
Long plot histories consume memory. Set reasonable time windows:- Short tests: 10-30 seconds
- Long runs: 60-120 seconds
Disable Unused Features
If you don’t need the GUI, disable it:Troubleshooting
GUI Won’t Start
- Check graphics drivers: Update to latest version
- Verify extension: Ensure
halsim_guiis not disabled - Check console: Look for initialization errors
Hardware Not Showing
- Initialize in code: Hardware only appears if created by robot code
- Check timing: Some devices may initialize after GUI opens
- Refresh: Close and reopen the hardware window
GUI Crashes or Freezes
- Update WPILib: Use the latest version
- Check callbacks: Ensure custom extensions don’t block
- Reset config: Delete
simgui.jsonand restart
Next Steps
Running Examples
Practice using the GUI with example programs
Custom Extensions
Create extensions that integrate with the GUI