RoboDSL Developer Guide
Welcome to the RoboDSL developer guide! This document provides comprehensive information about the project's architecture, code organization, and development workflow to help you understand and contribute effectively.
Table of Contents
- Project Overview
- Architecture
- Core Components
- Data Flow
- Build System Integration
- Module Reference
- CLI Module
- Parser Module
- Generator Module
- Template System
- Code Organization
- Source Code Structure
- Build System
- Testing Framework
- Development Workflow
- Environment Setup
- Building from Source
- Running Tests
- Debugging
- Extending RoboDSL
- Adding New Node Types
- Custom Code Generators
- Template Customization
- Performance Optimization
- Code Generation
- Runtime Performance
- Memory Management
Project Overview
RoboDSL is a domain-specific language designed for building GPU-accelerated robotics applications. It provides a high-level, declarative syntax for defining robot behaviors, data processing pipelines, and hardware interfaces.
Key Features
- Declarative Syntax: Define robot behaviors and data flows in a clean, readable format
- GPU Acceleration: Seamless integration with CUDA for high-performance computing
- Modular Architecture: Easily extendable with custom components and templates
- Cross-Platform: Works on Linux, Windows, and macOS with consistent behavior
- ROS2 Integration: Native support for ROS2 nodes and communication patterns
Architecture
Core Components
- Parser: Converts RoboDSL source code into an abstract syntax tree (AST)
- Generator: Transforms the AST into target code (C++, Python, etc.)
- Runtime: Provides the execution environment for generated code
- Standard Library: Collection of reusable components and utilities
Data Flow
- Source Code:
.robodsl
files containing the application definition - Parsing: Source code is parsed into an AST
- Validation: AST is validated against the language specification
- Code Generation: Target code is generated from the validated AST
- Compilation: Generated code is compiled into executable binaries
- Execution: The final application runs with the RoboDSL runtime
Module Reference
CLI Module
The Command Line Interface (CLI) module provides a user-friendly way to interact with RoboDSL. It's built using the click
library and supports various commands for building, testing, and managing RoboDSL projects.
Parser Module
The Parser module is responsible for converting RoboDSL source code into an Abstract Syntax Tree (AST). It uses a combination of regular expressions and parsing rules to validate and structure the input.
Generator Module
The Generator module takes the validated AST and produces target code in the specified output language (e.g., C++ with CUDA). It uses a template-based approach for flexibility.
Code Organization
Source Code Structure
robodsl/
├── src/ # Source code
│ ├── parser/ # Parser implementation
│ ├── generator/ # Code generators
│ ├── runtime/ # Runtime components
│ └── utils/ # Utility functions
├── templates/ # Code templates
├── tests/ # Test suite
└── docs/ # Documentation
Development Workflow
Environment Setup
-
Clone the repository:
bash git clone https://github.com/yourusername/robodsl.git cd robodsl
-
Create and activate a virtual environment:
bash python -m venv venv source venv/bin/activate # On Windows: venv\Scripts\activate
-
Install development dependencies:
bash pip install -r requirements-dev.txt
Building from Source
# Install in development mode
pip install -e .
Running Tests
# Run all tests
pytest
# Run a specific test file
pytest tests/test_parser.py
Extending RoboDSL
Adding New Node Types
- Define the node in the appropriate DSL file
- Create corresponding template files
- Register the node type in the generator
- Add tests for the new node type
Custom Code Generators
RoboDSL supports custom code generators for different target platforms. To create a new generator:
- Create a new module in
src/generator/
- Implement the required generator interface
- Register the generator in the main application
- Update the build system if needed
Performance Optimization
Code Generation
- Use efficient string operations
- Minimize template lookups
- Cache generated code when possible
Runtime Performance
- Optimize hot paths
- Use appropriate data structures
- Profile and optimize memory usage
Memory Management
- Use RAII for resource management
- Implement move semantics where appropriate
- Minimize allocations in performance-critical code