Troubleshooting Guide¶
This guide helps you diagnose and resolve common issues when working with the Webots-Simulink integration framework.
Installation Issues¶
MATLAB Cannot Find Webots Libraries¶
Symptoms:
- Error: Undefined function 'wb_robot_init'
- MATLAB crashes when starting controller
Solutions:
-
Verify Webots installation path:
-
Add Webots MATLAB library manually:
-
Set environment variable:
Webots Doesn't Recognize MATLAB Controller¶
Symptoms: - Controller selection shows empty or error - "Controller not found" message
Solutions:
- Ensure MATLAB is installed and licensed
- Check that controller file has
.mextension - Verify the controller directory structure:
Simulink Connection Issues¶
Simulink Model Won't Load¶
Symptoms:
- open_system('simulink_control') fails
- Error: "File not found"
Solutions:
-
Check current MATLAB directory:
-
Verify model file exists:
-
Check Simulink license:
Simulink Runs But No Data Transfer¶
Symptoms: - Simulink model runs but robot doesn't move - Sensor values always zero
Solutions:
-
Verify sensor initialization:
-
Check TIME_STEP matching:
-
Confirm wb_robot_step is called:
Simulation Performance Issues¶
Simulation Runs Very Slowly¶
Symptoms: - Low FPS in Webots - Laggy response - High CPU usage
Solutions:
| Issue | Solution |
|---|---|
| Complex physics | Increase basicTimeStep in world file |
| Too many sensors | Disable unused sensors |
| High-poly meshes | Use simpler bounding objects |
| Debug output | Remove disp() calls in loop |
| Simulink overhead | Use Simulink Accelerator mode |
Optimize Simulink model:
Simulation Freezes or Crashes¶
Symptoms: - Webots becomes unresponsive - MATLAB shows "busy" indefinitely
Solutions:
-
Check for infinite loops:
-
Memory leak prevention:
-
Reduce data logging:
Sensor Issues¶
Sensor Returns Zero or NaN Values¶
Symptoms: - All sensor readings are 0 - NaN values in sensor data
Solutions:
-
Enable sensor before reading:
-
Check sensor name spelling:
-
Verify sensor exists in world file:
- Open
.wbtfile in text editor - Search for sensor definition
- Confirm
namefield matches your code
LiDAR Data Is Empty or Incorrect¶
Symptoms:
- wb_lidar_get_range_image returns empty array
- Range values are all maximum or zero
Solutions:
-
Enable point cloud if needed:
-
Check LiDAR orientation:
- Verify LiDAR is not facing a wall/obstacle too close
-
Check minimum/maximum range settings in world file
-
Get correct array dimensions:
Motor Control Issues¶
Motors Don't Respond to Commands¶
Symptoms:
- wb_motor_set_velocity has no effect
- Robot remains stationary
Solutions:
-
Set position to infinity for velocity control:
-
Check motor limits:
-
Verify motor initialization:
Motor Oscillates or Is Unstable¶
Symptoms: - Motor vibrates rapidly - Position control overshoots repeatedly
Solutions:
- Tune PID gains:
- Reduce proportional gain (P)
- Increase derivative gain (D)
-
Add small integral gain (I) for steady-state error
-
Add velocity limits:
-
Use lower control frequency:
- Increase TIME_STEP value
- Add a control rate divider
Control System Issues¶
State-Space Model Doesn't Match Simulation¶
Symptoms: - Controller designed in MATLAB doesn't work in Webots - System behaves differently than expected
Solutions:
- Verify physical parameters:
- Check mass values in world file
- Verify inertia calculations
-
Confirm friction coefficients
-
Account for unmodeled dynamics:
- Add damping terms
- Include actuator dynamics
-
Consider sensor delays
-
Linearization point:
- Ensure operating point matches design assumptions
- Check if system is near linearization point
LQR Controller Is Unstable¶
Symptoms: - System diverges instead of stabilizing - Large oscillations that grow over time
Solutions:
-
Check controllability:
-
Verify state estimation:
- Ensure all states are measured or estimated
-
Check observer gains if using state estimator
-
Increase Q weights for problematic states:
Common Error Messages¶
| Error Message | Cause | Solution |
|---|---|---|
Device not found |
Wrong device name | Check spelling and case |
Sensor not enabled |
Missing enable call | Call wb_*_enable() first |
Cannot open model |
Model file missing | Check file path and name |
License checkout failed |
MATLAB license issue | Verify Simulink license |
Simulation timeout |
Infinite loop | Add proper exit condition |
Out of memory |
Memory leak | Clear unused variables |
Getting Help¶
If you're still experiencing issues:
- Check the FAQ for common questions
- Review example code in the
examples/directory - Search existing issues on GitHub
- Open a new issue with:
- Operating system and versions (MATLAB, Webots)
- Complete error message
- Minimal code to reproduce the issue
- What you've already tried
Debug Tips¶
Enable Verbose Output¶
% Add debug prints to track execution
disp(['Step: ', num2str(step_count)]);
disp(['Sensor values: ', num2str(values)]);
Log Data for Analysis¶
% Create data log
data_log = [];
while wb_robot_step(TIME_STEP) ~= -1
sensor_data = wb_gyro_get_values(gyro);
data_log = [data_log; sensor_data'];
end
% Save for later analysis
save('simulation_log.mat', 'data_log');
Test Components Individually¶
- Test sensor reading without control
- Test motor commands without sensor feedback
- Test Simulink model in isolation
- Combine components incrementally