Getting Started
Getting Started
Section titled “Getting Started”This guide will help you set up and start using the Roboscope 2 platform.
Prerequisites
Section titled “Prerequisites”For API Development
Section titled “For API Development”- PostgreSQL 14 or later
- Redis 7 or later
- Rust 1.70+ (for API server)
- Git
For iOS Development
Section titled “For iOS Development”- macOS 13+ (Ventura or later)
- Xcode 15+
- iOS Device with LiDAR (iPhone 12 Pro+, iPad Pro 2020+)
- iOS 17+
- Swift 5.9+
Quick Start (API)
Section titled “Quick Start (API)”1. Clone the Repository
Section titled “1. Clone the Repository”git clone https://github.com/your-org/roboscope_2.gitcd roboscope_2/roboscope_2_api2. Set Up Database
Section titled “2. Set Up Database”# Install PostgreSQL (macOS)brew install postgresql@14brew services start postgresql@14
# Create databasecreatedb roboscope_dev
# Install PostGIS extensionpsql roboscope_dev -c "CREATE EXTENSION IF NOT EXISTS postgis;"3. Set Up Redis
Section titled “3. Set Up Redis”# Install Redis (macOS)brew install redisbrew services start redis4. Configure Environment
Section titled “4. Configure Environment”# Copy example environment filecp .env.example .env
# Edit .env with your settingsDATABASE_URL=postgresql://localhost/roboscope_devREDIS_URL=redis://localhost:6379PORT=8080RUST_LOG=info5. Run Migrations
Section titled “5. Run Migrations”# Install sqlx-clicargo install sqlx-cli --no-default-features --features postgres
# Run migrationssqlx migrate run6. Start the Server
Section titled “6. Start the Server”# Development mode (with auto-reload)cargo watch -x run
# Or standard runcargo runThe API will be available at http://localhost:8080
7. Verify Installation
Section titled “7. Verify Installation”# Health checkcurl http://localhost:8080/health
# Expected response:# {"status":"healthy","database":"connected","redis":"connected"}8. Seed Test Data (Optional)
Section titled “8. Seed Test Data (Optional)”./scripts/seed-dev.shQuick Start (iOS)
Section titled “Quick Start (iOS)”1. Open Xcode Project
Section titled “1. Open Xcode Project”cd roboscope_2/roboscope_2_iosopen roboscope2.xcodeproj2. Install Dependencies
Section titled “2. Install Dependencies”The project uses Swift Package Manager. Dependencies should resolve automatically in Xcode.
If needed, manually resolve:
File → Packages → Resolve Package Versions3. Configure API Endpoint
Section titled “3. Configure API Endpoint”Edit roboscope2/Services/Network/APIConfiguration.swift:
struct APIConfiguration { static var shared = APIConfiguration()
// Change to your API server URL var baseURL: String { switch environment { case .development: return "http://localhost:8080/api/v1" // Local dev case .production: return "https://api.roboscope.example.com/api/v1" } }
var environment: Environment = .development}4. Configure Signing
Section titled “4. Configure Signing”- Select the project in Xcode navigator
- Select
roboscope2target - Go to Signing & Capabilities
- Select your Team
- Xcode will automatically manage provisioning
5. Build and Run
Section titled “5. Build and Run”- Connect your LiDAR-enabled iOS device
- Select device in Xcode
- Press Cmd+R to build and run
6. Grant Permissions
Section titled “6. Grant Permissions”On first launch, grant:
- Camera access (required for AR)
- Local Network access (required for API communication)
Your First Work Session
Section titled “Your First Work Session”1. Create a Space
Section titled “1. Create a Space”curl -X POST http://localhost:8080/api/v1/spaces \ -H "Content-Type: application/json" \ -d '{ "key": "my-room", "name": "My First Room", "calibration_vector": [0, 0, 0] }'Response will include the space id. Save it for next steps.
2. Create a Work Session
Section titled “2. Create a Work Session”curl -X POST http://localhost:8080/api/v1/work-sessions \ -H "Content-Type: application/json" \ -d '{ "space_id": "YOUR_SPACE_ID", "session_type": "inspection", "status": "active", "started_at": "2025-01-16T10:00:00Z" }'Response will include the session id.
3. Create a Marker
Section titled “3. Create a Marker”curl -X POST http://localhost:8080/api/v1/markers \ -H "Content-Type: application/json" \ -d '{ "work_session_id": "YOUR_SESSION_ID", "label": "Test Marker", "p1": [0.0, 0.0, 0.0], "p2": [0.1, 0.0, 0.0], "p3": [0.1, 0.1, 0.0], "p4": [0.0, 0.1, 0.0], "color": "#FF0000", "custom_props": { "severity": "medium", "type": "test" } }'4. Calculate Marker Details
Section titled “4. Calculate Marker Details”curl -X POST http://localhost:8080/api/v1/markers/YOUR_MARKER_ID/details/calculate5. List All Markers
Section titled “5. List All Markers”curl "http://localhost:8080/api/v1/markers?work_session_id=YOUR_SESSION_ID"Using the iOS App
Section titled “Using the iOS App”1. Create a Space
Section titled “1. Create a Space”- Tap Spaces tab
- Tap + button
- Enter space name and details
- Tap Save
2. Start a Work Session
Section titled “2. Start a Work Session”- Select your space
- Tap Sessions tab
- Tap New Session
- Choose session type
- Tap Start
3. Place Markers in AR
Section titled “3. Place Markers in AR”- In active session, tap AR View
- Point device at target surface
- Tap and drag to define marker corners
- Release to create marker
- Add label and properties
4. View Marker Details
Section titled “4. View Marker Details”- Tap on a marker in the list
- View calculated metrics:
- Center location
- Dimensions
- Distances
- Edit custom properties
Portal (Web Interface)
Section titled “Portal (Web Interface)”1. Navigate to Portal
Section titled “1. Navigate to Portal”cd roboscope_2/roboscope_2_portal2. Install Dependencies
Section titled “2. Install Dependencies”npm install# orpnpm install3. Configure API URL
Section titled “3. Configure API URL”Edit .env.local:
NEXT_PUBLIC_API_URL=http://localhost:8080/api/v14. Start Development Server
Section titled “4. Start Development Server”npm run dev# orpnpm devOpen http://localhost:3000 in your browser.
5. Explore Features
Section titled “5. Explore Features”- Browse spaces and sessions
- View markers with 3D visualization
- Export/import sessions
- Real-time presence tracking
- Marker analytics and reports
Common Tasks
Section titled “Common Tasks”Reset Database
Section titled “Reset Database”# Drop all tablessqlx database dropsqlx database createsqlx migrate runView Logs
Section titled “View Logs”# API logscargo run # Logs to stdout
# iOS logs# In Xcode: View → Debug Area → Show Debug AreaRun Tests
Section titled “Run Tests”# API testscargo test
# iOS tests (in Xcode)# Product → Test (Cmd+U)Clean Build
Section titled “Clean Build”# APIcargo clean
# iOS (in Xcode)# Product → Clean Build Folder (Cmd+Shift+K)Development Workflow
Section titled “Development Workflow”1. Backend Development
Section titled “1. Backend Development”# Watch mode (auto-reload on changes)cargo watch -x run
# Run specific testcargo test test_name
# Check codecargo clippy
# Format codecargo fmt2. iOS Development
Section titled “2. iOS Development”# BuildCmd+B
# Run on deviceCmd+R
# Run testsCmd+U
# Clean build folderCmd+Shift+K3. Database Changes
Section titled “3. Database Changes”# Create new migrationsqlx migrate add migration_name
# Run migrationssqlx migrate run
# Revert last migrationsqlx migrate revertTroubleshooting
Section titled “Troubleshooting”Database Connection Issues
Section titled “Database Connection Issues”# Check PostgreSQL is runningbrew services list | grep postgresql
# Test connectionpsql roboscope_dev -c "SELECT 1"Redis Connection Issues
Section titled “Redis Connection Issues”# Check Redis is runningbrew services list | grep redis
# Test connectionredis-cli ping# Expected: PONGiOS Build Errors
Section titled “iOS Build Errors”- Clean build folder: Cmd+Shift+K
- Delete Derived Data: Xcode → Preferences → Locations → Derived Data → Delete
- Reset Package Cache: File → Packages → Reset Package Caches
API Not Reachable from iOS
Section titled “API Not Reachable from iOS”- Check API is running:
curl http://localhost:8080/health - Use correct IP address (not localhost) in iOS
- Ensure both devices on same network
- Check firewall settings
LiDAR Not Working
Section titled “LiDAR Not Working”- Verify device has LiDAR (iPhone 12 Pro+, iPad Pro 2020+)
- Check camera permissions granted
- Ensure good lighting
- Update to latest iOS version
Next Steps
Section titled “Next Steps”- Understand the Data Model
- Explore API Endpoints
- iOS Integration Guide
- Learn about Marker Details
- View Workflow Examples
Resources
Section titled “Resources”Support
Section titled “Support”For questions or issues:
- Open an issue on GitHub
- Check existing documentation
- Review code examples in
/specs/examples/