Koalby MQP Documentation

website·Indexed 29 days ago

https://verdant-moxie-980963.netlify.app

Documentation hub for the WPI Humanoid Robot MQP project. Includes a Python Development Guide covering PEP 8, virtual environments, and testing, a documentation tutorial for Markdown and Git CLI, and technical sections for the Vision System, Locomotion, and Speech Recognition.

Tokens
7.2K
Snippets
57
Records
69
Agent score
75%

What's inside Koalby MQP

  1. Overview of Koalby MQP project documentation

    The Koalby MQP project documentation is organized into the following functional areas:

    • Documentation Tutorial: Instructions for contributing via Markdown/Git or the CMS.
    • Python Development Guide: Coding standards, testing practices, and environment setup.
    • Project Components: Technical documentation for Vision (image processing), Speech Recognition (NLP), Locomotion (robot movement/control), and various project Tools.
    • Repository Structure: The main repository contains current documentation and website code, while historical code is stored in the archive/ directory (specifically archive/website/ and archive/github/).
  2. Overview of WPI Humanoid Robot MQP Subsystems

    The WPI Humanoid Robot MQP is composed of several integrated systems:

    • Speech Recognition: Handles real-time voice commands and interaction using Python, OpenRouter, OpenAI Whisper, and Google Speech-to-Text.
    • Vision System: Provides real-time object detection and tracking using Python, DepthAI, and Oak-D-Lite hardware.
    • Locomotion: Manages robot movements, balancing, and object manipulation, implemented in C++ and Python.
    • Tools: A suite for monitoring performance, analyzing sensor data, and rapid prototyping using Grafana, Prometheus, and Docker.
  3. Best practices for managing Python repositories

    To maintain efficient and clean Python repositories, follow these core principles:

    • Source File Tracking: Commit only the source files required to generate or execute the code.
    • Ignore Generated Files: Use a .gitignore file to prevent compiled files (such as *.pyc and __pycache__/) from being tracked in version control to reduce commit noise.
    • Dependency Isolation: Use virtual environments to keep project dependencies isolated from the global Python installation.
    • Code Quality: Adhere to PEP8 guidelines and implement consistent code formatting.
    • Continuous Integration: Integrate automated testing and CI pipelines to ensure ongoing code quality and stability.
  4. Stash and apply temporary changes

    Use the stash to temporarily shelf uncommitted changes, allowing you to switch branches without committing incomplete work.
    # Stash current changes
    git stash
    
    # List all stashes
    git stash list
    
    # Apply most recent stash
    git stash apply
    
    # Apply a specific stash by index
    git stash apply stash@{2}
    
    # Apply and remove the stash from the list
    git stash pop
  5. Manage test dependencies with pytest fixtures

    Fixtures provide a fixed baseline for tests. Define them in conftest.py to make them available across multiple test files. Use yield to handle setup and teardown (cleanup) logic.
    # conftest.py
    import pytest
    from database import Database
    
    @pytest.fixture
    def db():
        """Provide a database connection for tests.""
        db = Database()
        db.connect()
        yield db
        db.disconnect()
    
    # test_database.py
    def test_save_user(db):
        user = {"name": "John"}
        assert db.save_user(user) is True
  6. Troubleshoot local installation and port conflicts

    Common issues during local setup include dependency installation failures and port 3000 being occupied by another process.
    # Fix Installation Problems: Clear cache and reinstall
    npm cache clean --force
    rm -rf node_modules
    npm install
    
    # Fix Port Conflicts (Port 3000 in use)
    # Windows: Find and kill process
    netstat -ano | findstr :3000
    taskkill /PID <PID> /F
    
    # Mac/Linux: Find and kill process
    lsof -i :3000
    kill -9 <PID>
    
    # Alternative: Start on a different port
    # Windows
    set PORT=3001 && npm start
    # Mac/Linux
    PORT=3001 npm start
  7. Manage the basic Git change workflow

    Perform the standard cycle of checking status, staging changes, and committing them to the local history.
    # View status of working directory
    git status
    
    # Stage specific files or all changes
    git add filename.md
    git add .
    
    # Remove staged changes
    git restore --staged filename.md
    
    # Commit with a message
    git commit -m "Add documentation for feature X"
    
    # Amend the last commit
    git commit --amend
  8. Set up Python tests in GitLab CI

    Configure a .gitlab-ci.yml file to run pytest and report coverage using a regex pattern.
    # .gitlab-ci.yml
    image: python:3.9
    
    stages:
      - test
      - deploy
    
    before_script:
      - pip install -r requirements.txt
    
    test:
      stage: test
      script:
        - pip install pytest pytest-cov
        - pytest --cov=./ --cov-report=term-missing
      coverage: '/TOTAL.+ ([0-9]{1,3}%)/'
  9. Preview documentation changes before deployment

    To ensure formatting is correct before pushing to production:

    • VS Code Preview: Open the .md file and press Ctrl+Shift+V (Windows/Linux) or Cmd+Shift+V (Mac).
    • Local Server: Use the Local Testing Guide to view changes in real-time on a development server.
  10. Apply PEP 8 indentation and line length rules

    Follow these PEP 8 standards for layout to ensure code readability:

    • Use 4 spaces per indentation level (do not use tabs).
    • Limit code lines to 79 characters (or 88 characters if using the Black formatter).
    • Limit docstrings and comments to 72 characters.
    # Good indentation
    def calculate_total(items):
        total = 0
        for item in items:
            total += item.price
        return total