hardwareOS Development Guide
This guide covers everything you need to start developing for hardwareOS, from environment setup to testing and debugging.
Prerequisites
Section titled “Prerequisites”Before you begin, ensure you have:
- Operating System: Ubuntu 22.04+ or macOS 13+
- Hardware (for on-device testing): RS-1 development kit
- GitHub Access: Write access to the hardwareOS repository
Environment Setup
Section titled “Environment Setup”1. Install System Dependencies
Section titled “1. Install System Dependencies”import { Tabs, TabItem } from ‘@astrojs/starlight/components’;
Install cross-compiler for ARM
Section titled “Install cross-compiler for ARM”sudo apt install -y gcc-arm-linux-gnueabihf
Install Go 1.21+
Section titled “Install Go 1.21+”wget https://go.dev/dl/go1.21.0.linux-amd64.tar.gz sudo tar -C /usr/local -xzf go1.21.0.linux-amd64.tar.gz export PATH=$PATH:/usr/local/go/bin
Install Node.js 20+
Section titled “Install Node.js 20+”curl -fsSL https://deb.nodesource.com/setup_20.x | sudo -E bash - sudo apt install -y nodejs
Install Protocol Buffers
Section titled “Install Protocol Buffers”sudo apt install -y protobuf-compiler go install google.golang.org/protobuf/cmd/protoc-gen-go@latest go install google.golang.org/grpc/cmd/protoc-gen-go-grpc@latest
</TabItem><TabItem label="macOS">```bash# Install Homebrew if needed/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)"
# Install dependenciesbrew install cmake ninja go node protobuf
# Install ARM cross-compilerbrew install arm-linux-gnueabihf-binutils
# Install gRPC toolsgo install google.golang.org/protobuf/cmd/protoc-gen-go@latestgo install google.golang.org/grpc/cmd/protoc-gen-go-grpc@latest2. Clone the Repository
Section titled “2. Clone the Repository”git clone https://github.com/r-mccarty/hardwareOS.gitcd hardwareOS3. Install Project Dependencies
Section titled “3. Install Project Dependencies”# Install Go dependenciesgo mod download
# Install Node.js dependencies for UIcd uinpm installcd ..
# Initialize submodulesgit submodule update --init --recursive4. SDK Setup
Section titled “4. SDK Setup”Download and install the RV1106 SDK:
# Download SDK (requires VPN access)wget https://files.optic.works/sdk/rv1106-sdk-v1.0.tar.gz
# Extract to home directorytar -xzf rv1106-sdk-v1.0.tar.gz -C ~/
# Set environment variableexport RV1106_SDK=~/rv1106-sdkecho 'export RV1106_SDK=~/rv1106-sdk' >> ~/.bashrcBuilding the Project
Section titled “Building the Project”Native Build (for development)
Section titled “Native Build (for development)”# Build all C componentsmkdir build && cd buildcmake .. -DTARGET=native -DCMAKE_BUILD_TYPE=Debugmake -j$(nproc)Cross-Compile for RV1106
Section titled “Cross-Compile for RV1106”# Set up cross-compilation environmentsource $RV1106_SDK/envsetup.sh
# Build for targetmkdir build-rv1106 && cd build-rv1106cmake .. -DTARGET=rv1106 -DCMAKE_BUILD_TYPE=Releasemake -j$(nproc)Build Go Services
Section titled “Build Go Services”# Build for native testinggo build -o bin/hardwareos-server ./cmd/server
# Cross-compile for ARMGOOS=linux GOARCH=arm GOARM=7 go build -o bin/hardwareos-server-arm ./cmd/serverBuild UI
Section titled “Build UI”cd uinpm run buildProject Structure
Section titled “Project Structure”hardwareOS/├── cmd/│ └── server/ # Main entry point for Go server├── products/│ └── rs1/│ ├── fusion/ # Sensor fusion algorithms│ │ ├── kalman.c # Kalman filter implementation│ │ ├── hungarian.c # Data association│ │ └── transform.c # Coordinate transforms│ └── radar/│ └── ld2450.c # Radar driver├── targets/│ └── rv1106/│ └── native/ # Platform-specific code├── pkg/│ ├── grpc/ # gRPC service definitions│ ├── webrtc/ # WebRTC infrastructure│ └── config/ # Configuration management├── ui/ # React frontend├── docs/ # Technical documentation├── tests/ # Test suites└── tools/ # Build and deployment toolsDevelopment Workflow
Section titled “Development Workflow”1. Create a Feature Branch
Section titled “1. Create a Feature Branch”git checkout maingit pull origin maingit checkout -b feature/your-feature-name2. Make Changes
Section titled “2. Make Changes”Follow our Code Standards:
- C code: Use snake_case, 4-space indentation
- Go code: Follow standard Go conventions
- TypeScript: Use ESLint and Prettier configurations
3. Run Tests
Section titled “3. Run Tests”# Run C testscd buildctest --output-on-failure
# Run Go testsgo test ./...
# Run UI testscd uinpm test4. Commit and Push
Section titled “4. Commit and Push”git add .git commit -m "feat: add new feature description"git push origin feature/your-feature-name5. Create Pull Request
Section titled “5. Create Pull Request”Open a PR on GitHub targeting the main branch.
Testing
Section titled “Testing”Unit Tests
Section titled “Unit Tests”# C unit tests (uses Unity framework)cd buildmake test
# Go unit testsgo test ./... -v
# UI unit testscd ui && npm testIntegration Tests
Section titled “Integration Tests”# Run integration test suite./tests/integration/run_all.sh
# Test with simulated hardware./tools/simulator/run.sh &go test ./tests/integration/... -tags=integrationOn-Device Testing
Section titled “On-Device Testing”# Deploy to connected RS-1 device./tools/deploy.sh --device 192.168.1.100
# Run on-device testsssh root@192.168.1.100 '/opt/hardwareos/tests/run.sh'Debugging
Section titled “Debugging”Native Debugging
Section titled “Native Debugging”# Build with debug symbolscmake .. -DCMAKE_BUILD_TYPE=Debugmake
# Debug with gdbgdb ./bin/fusion_testRemote Debugging on RS-1
Section titled “Remote Debugging on RS-1”# Start gdbserver on devicessh root@192.168.1.100 'gdbserver :1234 /opt/hardwareos/bin/fusion'
# Connect from development machinearm-linux-gnueabihf-gdb ./build-rv1106/bin/fusion(gdb) target remote 192.168.1.100:1234Logging
Section titled “Logging”Set log levels via environment variable:
export HOS_LOG_LEVEL=debug # Options: trace, debug, info, warn, error./bin/hardwareos-serverCommon Tasks
Section titled “Common Tasks”Adding a New Sensor Driver
Section titled “Adding a New Sensor Driver”- Create driver file in
products/rs1/sensors/ - Implement the sensor interface:
typedef struct { int (*init)(void); int (*read)(sensor_data_t *data); int (*cleanup)(void);} sensor_driver_t;- Register in
products/rs1/sensors/registry.c - Add tests in
tests/unit/sensors/
Modifying Fusion Algorithm
Section titled “Modifying Fusion Algorithm”- Update algorithm in
products/rs1/fusion/ - Run benchmark suite:
./tools/benchmark.sh fusion- Verify latency targets are met (<50ms)
Adding gRPC Endpoint
Section titled “Adding gRPC Endpoint”- Update proto definition in
proto/ - Regenerate code:
./tools/generate_proto.sh- Implement handler in
pkg/grpc/
Resources
Section titled “Resources”| Resource | Location |
|---|---|
| API Documentation | docs/api/ |
| Architecture Diagrams | docs/architecture/ |
| Hardware Schematics | docs/hardware/ (restricted access) |
| Debugging Guide | docs/debugging.md |
Getting Help
Section titled “Getting Help”- Slack:
#hardware-engineering - GitHub Issues: For bug reports and feature requests
- Office Hours: Wednesdays 2-3pm PT with Hardware Team