How john-trager/datadash works
Main Components
• Entry/Control: The main script (datadash.py) orchestrates the overall flow based on the system state.
• Sensors & Inputs: Include modules interfacing with the camera (lib/camera.py, lib/oakdcam.py), motion detection (lib/motiondetector.py and its mock version for testing), and IMU (the calibration script and the configuration file for offsets in config/imu_offsets.json).
• User Feedback/Output: The LCD display module (lib/lcd16x2.py) provides system status.
• Data Recording & Processing: This includes components capturing and recording video (lib/datarecorder.py) and additional data like sensor parameters (lib/params.py, lib/state.py).
• Networking/Upload: The uploader (lib/uploader.py) is responsible for transmitting the collected data to the remote server (running on a secondary Raspberry Pi hosting remote video storage).
• State Machine & Workflow: Use the documented states (“idle”, “in-motion”, “wait-for-upload”, “upload-state”, “done”) to map out how data collection is managed and transitions are triggered.
• Auxiliary Scripts: The runDataDash script in the bin directory that likely ensures the application starts on boot.
• Testing Components: Although you might not include every test in the architecture, note that there’s comprehensive test coverage, for example, test_camera.py, test_display.py, etc.
Relationships and Data Flow
• The central controller (datadash.py) triggers hardware component functions (e.g., initializing the camera, starting the motion detection).
• In the “idle” state, the system waits until a sensor (motion detector) signals activity, then transitions to “in-motion” where the camera modules actively record.
• Once data is captured, the state machine waits (in "wait-for-upload") and then triggers the uploader when wireless connectivity is available.
• Feedback loop where if the connection fails during upload, the system cycles back to “wait-for-upload” or “idle”.
Architectural Patterns and Principles
• Clearly separate concerns: hardware interfacing (sensors, camera, display) is managed by individual modules, while the state machine logic encapsulates the control flow.
• How configuration data (like IMU offsets) is isolated, enhancing maintainability.
• If applicable, mention the use of modular design which aids in testing, as evident from the multiple test files provided.
• How the system supports extensions, for example future integration of GPS data or OBD-II sensor data.
Relevant Technologies and Interactions
• Hardware components: Raspberry Pis, Logitech webcam, MPU/IMU sensor, LCD display.
• Software interactions: Python modules for each hardware aspect, networking functions for data upload, and OS-level scripts (crontab configuration and gadget mode for remote access).
• Interfaces: Highlight that the uploader interacts with remote storage/cloud, and may include authentication and error handling (transitioning to “done” or retry state).