C++ SDK
Complete guide to the RoboOS C++ SDK for desktop and server applications.
C++ SDK
The RoboOS C++ SDK provides full-featured RoboOS integration for C++ applications. It's designed for desktop applications, server-side services, and high-performance robot control systems.
This SDK offers complete RoboOS capabilities including wallet management, payment channels, task marketplace, zero-knowledge verification, and reputation systems, all with native C++ performance.
Requirements
System Requirements: - C++17 or later - CMake 3.20 or later - libcurl (for HTTP requests) - jsoncpp (for JSON parsing) - Solana C++ bindings (optional, for direct blockchain interaction)
Installation on Ubuntu/Debian:
sudo apt-get update
sudo apt-get install -y build-essential cmake libcurl4-openssl-dev libjsoncpp-devInstallation on macOS:
brew install cmake curl jsoncppInstallation
Building from Source:
mkdir build
cd build
cmake ..
make
sudo make installCompiling Your Program:
g++ -std=c++17 your_program.cpp -lroboos-sdk -lcurl -ljsoncpp -o your_programUsing CMake:
find_package(roboos-sdk REQUIRED)
target_link_libraries(your_target roboos-sdk::roboos-sdk)Quick Start
Basic example:
#include <roboos/RobotSDK.h>
#include <roboos/robots/ForkliftRobot.h>
#include <iostream>
int main() {
// Initialize SDK
roboos::RobotSDK::Config config;
config.network = roboos::Network::TESTNET;
config.fprEndpoint = "https://fpr-testnet.theroboos.com";
config.marketplaceEndpoint = "https://marketplace-testnet.theroboos.com";
roboos::RobotSDK sdk(config);
// Create wallet
roboos::WalletOptions walletOpts;
walletOpts.storage = roboos::StorageType::FILE;
walletOpts.path = "./robot-wallet.json";
walletOpts.encrypted = true;
auto wallet = roboos::RobotWallet::create(walletOpts);
// Define forklift capabilities
roboos::ForkliftCapabilities capabilities;
capabilities.lifting = true;
capabilities.transport = true;
capabilities.stacking = true;
capabilities.maxWeight = 2000; // kg
capabilities.maxHeight = 5; // meters
capabilities.navigation = true;
// Create forklift robot
roboos::RobotOptions robotOpts;
robotOpts.robotId = "forklift-001";
robotOpts.wallet = wallet;
robotOpts.config = sdk.getConfig();
roboos::ForkliftRobot forklift(robotOpts, capabilities);
// Initialize and connect
forklift.initialize();
forklift.connect();
std::cout << "Forklift robot connected" << std::endl;
return 0;
}Core Features
Robot Wallet SDK - Complete Solana wallet management with x402 stealth payment integration. File-based and in-memory storage options with encryption support.
Fleet Payment Router (FPR) Client - Full payment channel support for efficient robot-to-robot transactions. Open channels, send micropayments, and manage channel lifecycle.
Task Marketplace API - Comprehensive marketplace integration. Query tasks, submit bids, accept tasks, and update task status with full type safety.
Zero-Knowledge Verification - Task completion proofs using ZK technology. Generate and verify proofs for task completion.
Reputation System - Integration with Robot Reputation Ledger (RRL). Query reputation scores and update based on task completion.
Robot Type Helpers - Pre-built classes for Forklift, AMR, Cleaning, Hospital, Drone, and Robotic Arm with type-specific capabilities and methods.
Wallet Management
Create and manage robot wallets:
// Create new wallet
roboos::WalletOptions walletOpts;
walletOpts.storage = roboos::StorageType::FILE;
walletOpts.path = "./wallet.json";
walletOpts.encrypted = true;
auto wallet = roboos::RobotWallet::create(walletOpts);
// Load existing wallet
auto loadedWallet = roboos::RobotWallet::load(walletOpts);
// Get wallet info
auto info = wallet->getInfo();
std::cout << "Public Key: " << info.publicKey << std::endl;
std::cout << "Balance: " << wallet->getBalance() << std::endl;
// Generate x402 stealth address
auto stealthAddress = wallet->generateStealthAddress();Task Marketplace
Query and bid on tasks:
auto marketplace = forklift.getMarketplace();
// Query available tasks
roboos::TaskQuery query;
query.type = "material_handling";
query.status = roboos::TaskStatus::PENDING;
auto tasks = marketplace->queryTasks(query);
std::cout << "Found " << tasks.size() << " tasks" << std::endl;
// Bid on a task
roboos::BidRequest bidRequest;
bidRequest.taskId = tasks[0].taskId;
bidRequest.bidAmount = 50;
bidRequest.estimatedDuration = 300;
auto bid = marketplace->bid(bidRequest);
// Accept and execute task
if (bid.accepted) {
marketplace->acceptTask(tasks[0].taskId);
marketplace->updateTaskStatus(tasks[0].taskId, roboos::TaskStatus::IN_PROGRESS);
forklift.executeTask(tasks[0]);
// Submit completion proof
roboos::TaskProof proof;
proof.taskId = tasks[0].taskId;
proof.proof = generateZKProof(tasks[0]);
marketplace->completeTask(tasks[0].taskId, proof);
}Payment Channels
Use FPR for efficient micropayments:
auto fpr = forklift.getFPR();
// Open payment channel
roboos::OpenChannelRequest channelRequest;
channelRequest.peerRobotId = "robot-002";
channelRequest.collateral = 1000; // ROS tokens
auto channel = fpr->openChannel(channelRequest);
// Send payment
roboos::PaymentRequest paymentRequest;
paymentRequest.channelId = channel.id;
paymentRequest.amount = 50;
paymentRequest.metadata = {{"taskId", "task-123"}};
fpr->sendPayment(paymentRequest);
// Close channel
fpr->closeChannel(channel.id);Robot Types
ForkliftRobot - Material handling and warehouse operations:
roboos::ForkliftCapabilities caps;
caps.lifting = true;
caps.maxWeight = 2000;
roboos::ForkliftRobot forklift(opts, caps);AMRRobot - Navigation and delivery tasks:
roboos::AMRCapabilities caps;
caps.navigation = true;
caps.maxPayload = 50.0;
roboos::AMRRobot amr(opts, caps);CleaningRobot - Area coverage and route optimization:
roboos::CleaningCapabilities caps;
caps.vacuum = true;
caps.mopping = true;
roboos::CleaningRobot cleaner(opts, caps);HospitalRobot - Medical transport and sterilization:
roboos::HospitalCapabilities caps;
caps.medicalTransport = true;
caps.sterilization = true;
roboos::HospitalRobot hospital(opts, caps);DroneRobot - Flight routes and surveillance:
roboos::DroneCapabilities caps;
caps.flightNavigation = true;
caps.maxAltitude = 100;
roboos::DroneRobot drone(opts, caps);RoboticArm - Assembly and manipulation:
roboos::RoboticArmCapabilities caps;
caps.precision = 0.1;
caps.maxReach = 1.5;
roboos::RoboticArm arm(opts, caps);Examples
Check out the examples directory in the SDK repository:
- Basic Robot - Basic SDK usage and initialization - Forklift Example - Forklift-specific capabilities and task handling - Bidding Example - Custom bidding strategies - Payment Channel Example - Payment channels and micropayments
All examples are available in the `examples/` directory of the SDK repository with complete CMake build configurations.
Error Handling
The SDK uses exceptions for error handling:
try {
auto wallet = roboos::RobotWallet::create(walletOpts);
forklift.connect();
} catch (const roboos::SDKException& e) {
std::cerr << "SDK Error: " << e.what() << std::endl;
} catch (const std::exception& e) {
std::cerr << "Error: " << e.what() << std::endl;
}Common exception types: - `roboos::SDKException` - General SDK errors - `roboos::WalletException` - Wallet-related errors - `roboos::NetworkException` - Network communication errors - `roboos::MarketplaceException` - Marketplace API errors