A Human-Robot Collaboration Framework for Learning from Demonstrations
Author: Oleh Borys
Institution: Czech Technical University in Prague, FEL, Cybernetics and Robotics
Email: olehboures@gmail.com
Date: May 2025
This project was developed for a Bachelor's thesis at CTU FEL in Prague.
Note: The project does not have the commit history because it was transferred from CIIRC GitLab, where it was initially developed. For more details and granted access, please contact the author.
REBCAT (REactive Behavior Constraint-Aware Tree learning) is a framework for human-robot collaboration that learns task knowledge from demonstrations. The system uses constraint-aware Behavior Trees to represent and execute tasks, enabling reactive adaptation to changing environments.
The framework supports:
- Learning target positions for objects based on their properties
- Extracting action ordering constraints from multi-step demonstrations
- Generating reactive Behavior Trees for task execution
- Improving performance through human feedback
The system consists of five main components:
- Perception Manager: Detects objects and their properties using camera input
- Task Planning Manager: Classifies objects and determines action ordering constraints
- Execution Manager: Generates and executes Behavior Trees for robot control
- Feedback Manager: Collects human feedback to improve system performance
- Model Manager: Handles training and retraining of classification models
Camera and robot image sources: Intel RealSense D455 camera and RoboGroove (Maguire et al., 2022).
- Clone the repository
- Install dependencies:
pip install -r requirements.txt
The main configuration parameters are located in config.py
. Key parameters to adjust:
WITH_ROS
: Set toTrue
to use ROS for robot controlCAMERA_TOPIC
: Set the ROS topic for camera inputPOSITION_TOLERANCE
: Adjust tolerance for object position verificationTICK_SLEEP_TIME
: Sleep time between BT ticks (seconds)OBJECT_NOT_VISIBLE_TIMEOUT
: Time before declaring an object missingDETECTION_VALIDITY_TIMEOUT
: Timeout for image validityIMAGE_TIMEOUT
: Maximum time to wait for camera image
DATASETS_PATH
: Path to store generated datasetsRANDOM_SEED
: Set for reproducible resultsNUMBER_OF_INITIAL_DEMOS
: Number of demonstrations to start withEXPERIMENT_NAME
: Name of the current experimentNUMBER_OF_MOCK_OBJECTS
: Number of mock objects to generate
EVALUATION_MODE
: Choose between "compare_models_accuracy", "compare_simple_clever_feedback"MODEL_TYPES
: Select models to evaluate ("decision_tree", "catboost_native", etc.)NUM_SPLITS
,NUM_REPETITIONS
: Configure cross-validation parametersWITH_RETRAINING
: Whether to retrain models at each evaluation stepWITH_FEEDBACK
: Whether to use feedback for trainingTARGET_CLASS_BALANCED
: Sample examples with equal probability per classTARGET_ACCURACY
: Target accuracy threshold for evaluation (default: 0.99)TRACK_RULE_CURVES
: Whether to track rule learning curvesOUTPUT_FREQUENCY
: Export trees and results every N stepsMAX_DEMOS
: Maximum number of demonstrations to useNUMBER_OF_INITIAL_DEMOS
: Number of demonstrations to start withRULES_FILE
: Path to ground truth rules for evaluation
MAIN_MODEL_TYPE
: Model used in BT for classificationDECISION_TREE_MAX_DEPTH
: Maximum depth of decision treesDECISION_TREE_CRITERION
: Criterion for decision tree splitsCATBOOST_ITERATIONS
: Number of iterations for CatBoost modelsCATBOOST_DEPTH
: Maximum depth of CatBoost treesCATBOOST_LEARNING_RATE
: Learning rate for CatBoost model
To start the system with a physical robot:
python main.py
The program will:
- Initialize all components and load training data
- Train the initial classification model
- Present task type selection (single-step or multi-step)
- Detect objects and classify them
- Generate a Behavior Tree for task execution
- Execute the task
- Collect feedback and improve the model
To generate a new feature space dataset:
python -m tools.generate_feature_space
Configure dataset parameters in tools/generate_feature_space.py
:
- Adjust object properties (class names, color values, etc.)
- Configure value distributions (uniform, midpoint, or cluster)
- Set ranges for continuous properties (size, weight)
For full dataset preparation including folds and rules:
python -m tools.run_data_preparation
To evaluate classifier performance:
python -m tools.classifier_evaluation.evaluate_classifier
This will:
- Run evaluations for all configured model types
- Generate learning curves comparing model performance
- Save results to the configured output directory
- The human prepares the environment with objects
- The system detects objects and plans a task
- The robot executes the task using the generated Behavior Tree
- The human provides feedback on execution
- The system learns from feedback to improve future performance
The system supports multiple classification models:
- Decision Tree: Highly interpretable with hierarchical decision structure
- CatBoost: Gradient boosting approach with superior performance on small datasets
For multi-step tasks, the system extracts ordering constraints using a Preconditions Extraction Algorithm that:
- Analyzes demonstrations to find must-precede relationships
- Identifies flexible ordering between actions
- Removes transitive edges to create a minimal precedence graph
The system generates a hierarchical BT with four main components:
HumanHelpBranch
: Handles human intervention when neededObjectDetector
: Monitors object positionsTaskBranch
: Contains action sequences for executionReturnHome
: Returns the robot to home position