Problem Schema
New problems are defined as JSON objects that map to our Mongoose Problem model.
Model Definition
| Field | Type | Description |
|---|---|---|
id | Number | Unique identifier (e.g., 101). |
title | String | User-facing title of the problem. |
difficulty | Enum | Easy, Medium, Hard, or Advanced. |
executionType | String | Defines the runner (e.g., ros2_python_node, ros2_cpp_node). |
starterCode | String | The initial code shown to the student. |
testScript | String | The Python script that validates the solution. |
validation | Object | Fallback regex/keyword matching if no testScript is provided. |
Strategy Selection (executionType)
The worker.js uses different strategies based on the executionType:
ros2_python_node: Runs a Python script as a ROS2 node.ros2_cpp_node: Compilessolution.cppusingg++(with ccache) before execution.urdf_xacro: Validates robot URDF/Xacro files.bash_script: Executes arbitrary shell commands.
Example Validation Script
A testScript should print [PASSED] if the criteria are met:
import rclpy
# ... check robot position ...
if robot_reached_goal:
print("[PASSED]")
else:
print("[FAILED] Robot did not reach the target coordinate.")