YARS is a mobile robot simulator written in C++ that was originally developed between 2004-2019. It provides physics simulation via Bullet Physics and 3D graphics rendering for robotics research and education.
✅ Major Modernization Progress Made
The codebase has been significantly modernized:
- ✅ CMake build system upgraded to 3.16+ with modern policies
- ✅ C++17 standard enforced with modern compiler settings
- ✅ Boost dependencies largely removed (boost::filesystem → std::filesystem, boost::program_options → modern CMake)
- ✅ Observer pattern removal started (core components like YarsMainControl, RuntimeControl updated)
- ✅ Namespace organization in progress (29 files now use
namespace yars) - ✅ Smart pointer migration and nullptr modernization completed
- ✅ Deprecated copy constructor warnings fixed
- ✅ Sign comparison warnings resolved
- ✅ Full build system working with compatibility maintained
Validation Status: ✅ All changes validated with braitenberg_logging.xml test showing identical simulation results
| Component | Technology | Status |
|---|---|---|
| Language | C++17 | ✅ Modernized |
| Build System | CMake 3.16+ | ✅ Modernized |
| Physics | Bullet Physics 3.x | ✅ Working |
| Graphics | Ogre3D 13.6.4 | ✅ Integrated |
| Windowing | SDL2 | ✅ Working |
| Configuration | XML (Xerces-C++) | |
| Threading | std::thread | ✅ Modernized |
| Filesystem | std::filesystem | ✅ Modernized |
| Memory | Smart pointers | ✅ Modernized |
- Main Control:
src/yars/main/YarsMainControl.cpp- Central simulation controller - Physics:
src/yars/physics/- Bullet Physics integration - Graphics:
src/yars/view/gui/- Ogre3D rendering system - Configuration:
src/yars/configuration/- XML parsing and data management - Logging:
src/yars/logging/- CSV/file output system - Utilities:
src/yars/util/- Helper classes and infrastructure
The project uses Ogre3D 13.6.4 as a git submodule with static linking:
- Location:
ext/ogre-source(git submodule) - Build: Integrated into CMake as subdirectory with minimal configuration
- Linking: Static libraries prevent external dependency issues
- Status: ✅ Fully functional with OpenGL 3.3 core renderer
The legacy Observer pattern is being systematically removed:
- Status: Core components (YarsMainControl, RuntimeControl) modernized
- Remaining: ~141 references still need updating
- Approach: Direct method calls replacing message-based communication
- Critical Files:
src/yars/util/Observable.h- Base observable class (to be removed)src/yars/util/Observer.h- Observer interface (to be removed)
Currently uses XML with Xerces-C++:
- XML Schema:
src/yars/configuration/xsd/- Complex validation system - Factory Pattern: 80+ factory classes for object creation
- Status: Working but complex, future candidate for JSON migration
Now uses modern C++ patterns:
- Smart Pointers: Raw pointers replaced with
std::unique_ptr/std::shared_ptr - RAII: Resource management through constructors/destructors
- Validation: Braitenberg test shows no functionality regression
- CMake 3.16+
- C++17 compatible compiler
- Required libraries: Bullet Physics, SDL2, Xerces-C++, FreeImage, FreeType, ZZip, zlib
# Standard build
mkdir build && cd build
cmake ..
make -j4
# Test the build
./bin/yars --iterations 1000 --xml ../xml/braitenberg_logging.xml# Basic simulation test
./bin/yars --iterations 1000 --xml xml/braitenberg_logging.xml
# Compare with reference logfile
diff braitenberg-*.csv reference_logfile.csv
# Performance test
time ./bin/yars --iterations 10000 --xml xml/falling_objects.xml
# Memory validation
valgrind --leak-check=full ./bin/yars --iterations 100 --xml xml/braitenberg.xml- CMake: Upgraded from 3.5 to 3.16+ with modern policies
- C++17: Standard enforced with
CMAKE_CXX_STANDARD_REQUIRED ON - Target-based: Modern CMake practices with proper target linking
- Dependencies: Proper Boost, Bullet, and Ogre integration
- Nullptr: All NULL replaced with nullptr
- Smart Pointers: Memory management modernized
- Namespacing: Systematic
namespace yars {}organization in progress - Compiler Warnings: Fixed deprecated constructors and sign comparison warnings
- Observer Pattern: Core components refactored to direct method calls
- Validation: All changes tested with braitenberg simulation
- Compatibility: 100% functional equivalence maintained
- Build Speed: Improved compilation times
- Memory Safety: Smart pointers eliminate manual memory management
- Robot Models: Braitenberg vehicles, hexapods, custom robots
- Physics: Accurate collision detection, rigid body dynamics
- Sensors: Proximity, light, contact, position, velocity sensors
- Actuators: Hinges, sliders, motors, muscle actuators
- Environment: Static and dynamic objects, lighting, textures
- 3D Graphics: Ogre3D with OpenGL 3.3 core renderer
- Materials: Shader-based rendering with texture support
- Camera: Multiple viewpoints, follow modes, auto-capture
- Overlays: Text rendering for debugging and information display
- XML Format: Comprehensive robot and environment definitions
- Validation: XSD schema validation for configuration correctness
- Examples: Working configurations in
xml/directory
- C++17: Use modern language features (auto, range-based for, smart pointers)
- Namespacing: All new code should use
namespace yars {} - Memory: Prefer smart pointers over raw pointers
- Naming: Follow existing camelCase convention
- Headers: Include guards and minimal dependencies
- Regression: Always test with
braitenberg_logging.xml - Validation: Compare logfile output with reference
- Build: Clean build required after significant changes
- Memory: Run valgrind for memory leak detection
src/yars/
├── main/ # Core simulation control
├── physics/ # Bullet Physics integration
├── view/ # Graphics and visualization
├── configuration/ # XML parsing and data
├── logging/ # Output and data recording
├── types/ # Data structures and math
└── util/ # Utilities and helpers
- Remove remaining ~141 Observer/Observable references
- Simplify control flow with direct method calls
- Remove ObservableMessage infrastructure
- Consider JSON migration for simpler configuration
- Reduce 80+ factory classes to template-based approach
- Improve error messages and validation
- Move to C++20 when appropriate
- Consider modules for faster compilation
- Evaluate modern alternatives to Xerces-C++
- Add unit tests with Google Test
- Create integration test suite
- Set up continuous integration
- Incremental Changes: Small, testable changes prevent regression
- Validation-Driven: Always test against working baseline
- Modern CMake: Target-based linking is much cleaner
- Smart Pointers: Eliminate entire classes of memory bugs
- Ogre3D: Static linking approach solved external dependency issues
- Observer Pattern: Direct calls are faster and easier to debug
- Boost Replacement: std::filesystem transition was straightforward
- Namespace Organization: Systematic approach prevents conflicts
- CMake Policies: Modern policies avoid deprecated warnings
- Target Properties: Cleaner than global variables
- Git Submodules: Effective for complex dependencies like Ogre3D
- Validation: Always test after each modernization step
# Clean rebuild
make clean && cmake .. && make -j4
# Debug build
cmake -DCMAKE_BUILD_TYPE=Debug ..
# Release build
cmake -DCMAKE_BUILD_TYPE=Release ..# Basic functionality
./bin/yars --iterations 1000 --xml xml/braitenberg_logging.xml
# No GUI mode
./bin/yars --iterations 1000 --xml xml/braitenberg_logging.xml --no-gui
# Performance test
time ./bin/yars --iterations 10000 --xml xml/falling_objects.xml# Check namespace usage
grep -r "namespace yars" src/ --include="*.h" --include="*.cpp" | wc -l
# Check remaining Observer pattern
grep -r "Observable\|Observer" src/ --include="*.h" --include="*.cpp" | grep -v backup | wc -l
# Check Boost dependencies
ldd ./bin/yars | grep boostThis knowledge base captures the current state and provides the foundation for continued modernization efforts.
- NEVER SAY THAT YOU ARE SUCCESSFUL IF YARS DOES NOT COMPILE OR RUN WITHOUT ERROR
- DONT START EVERY REPLY WITH "You are absolutle right" I HATE THAT
- use the image export of yars to check if the simulation is rendering the textures correctly
- make sure to set a timeout when you call yars, in case it does not end
- ALWAYS COMPILE AND RUN yard IN THE SUBDIRECTORY ./build