Find and fix issues in your OPAL Plans using built-in debugging tools.
Pro Tip
Add
log()statements liberally during development - they're your best friend for understanding plan behavior. You can always remove them or change tolog_debug()for production use.
OctoMY™ provides several debugging features:
| Tool | Purpose |
|---|---|
| Log Output | View plan messages |
| Variable Watch | Monitor variable values |
| Breakpoints | Pause at specific lines |
| Step Execution | Run line by line |
| Sensor Monitor | Live sensor values |
plan DebugExample {
loop {
var distance = sensors.distance.front
log("Distance reading: " + distance + "cm")
if distance < 30 {
log("WARNING: Obstacle detected!")
log("Taking evasive action")
avoid_obstacle()
}
delay(100)
}
}
Open the log panel while plan is running:
log("Normal message") # INFO level
log_debug("Debug details") # DEBUG level (verbose)
log_warn("Warning message") # WARNING level
log_error("Error occurred!") # ERROR level
Filter logs by level in the UI dropdown.
Monitor variable values in real-time:
Watch calculated values:
Pause execution at specific lines:
Click the line number in the editor:
When paused at a breakpoint:
| Button | Action |
|---|---|
| Continue | Resume until next breakpoint |
| Step | Execute one line, enter functions |
| Step Over | Execute one line, skip function internals |
| Stop | End execution |
Run your plan line by line:
View live sensor data while debugging:
Error at line 5: Unexpected token '}'
Solution: Check for missing brackets, parentheses, or semicolons.
# Wrong
if distance < 30
avoid_obstacle()
}
# Correct
if distance < 30 {
avoid_obstacle()
}
Error at line 7: Variable 'distanc' is not defined
Solution: Check variable spelling.
# Wrong
var distance = 50
if distanc < 30 { # Typo!
# Correct
var distance = 50
if distance < 30 {
Error at line 4: Cannot compare string to number
Solution: Ensure types match in comparisons.
# Wrong
var state = "running"
if state < 30 { # String vs number!
# Correct
var state = "running"
if state == "running" {
Error: Sensor 'distance.rear' not found
Solution: Verify sensor name and that hardware is configured.
# Check available sensors first
log(sensors.list())
Cause: Loop running too fast without delay.
# Bad - uses 100% CPU
loop {
check_sensors()
# No delay!
}
# Good - runs at 20Hz
loop {
check_sensors()
delay(50) # 50ms between iterations
}
Cause: Creating objects in loop without cleanup.
# Bad - memory grows forever
loop {
var data = read_all_sensors() # New object each loop
}
# Good - reuse variable
var data = {}
loop {
data = read_all_sensors() # Replaces old value
}
For complex plans with states:
plan StateMachine {
var state = "idle"
var prev_state = ""
loop {
if state != prev_state {
log("State change: " + prev_state + " -> " + state)
prev_state = state
}
if state == "idle" {
# ...
} else if state == "searching" {
# ...
} else if state == "avoiding" {
# ...
}
delay(50)
}
}
Enable state logging:
Debug plans from a connected Remote: