Skip to main content

Problem Schema

New problems are defined as JSON objects that map to our Mongoose Problem model.

Model Definition

FieldTypeDescription
idNumberUnique identifier (e.g., 101).
titleStringUser-facing title of the problem.
difficultyEnumEasy, Medium, Hard, or Advanced.
executionTypeStringDefines the runner (e.g., ros2_python_node, ros2_cpp_node).
starterCodeStringThe initial code shown to the student.
testScriptStringThe Python script that validates the solution.
validationObjectFallback 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: Compiles solution.cpp using g++ (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.")