### Run Caterpillar example Source: https://deepwiki.com/copper-project/copper-rs/5-examples Executes the Caterpillar example project with console monitoring enabled. ```bash cargo run --bin cu-caterpillar ``` -------------------------------- ### Install Essential Development Tools Source: https://deepwiki.com/copper-project/copper-rs/4-development-guide Install the required tools for project scaffolding, testing, security auditing, and task management. ```bash # Project scaffolding cargo install cargo-cunew # Test runner (used extensively in CI) cargo install cargo-nextest # Security and dependency auditing cargo install cargo-deny # Command runner for workspace tasks cargo install just ``` -------------------------------- ### Install Ubuntu System Dependencies Source: https://deepwiki.com/copper-project/copper-rs/4-development-guide Install required system libraries for vision, communication, and hardware access on Ubuntu. ```bash sudo apt-get update && sudo apt-get install -y libudev-dev pkg-config ``` -------------------------------- ### Enter Nix development shell (standard and CUDA) Source: https://deepwiki.com/copper-project/copper-rs/4.3-deployment Use these commands to enter the Nix development shell. The first command starts the standard environment, while the second starts the CUDA-enabled environment, which is only available on Linux. The shell configuration sets LIBCLANG_PATH and BINDGEN_EXTRA_CLANG_ARGS for bindgen. ```bash # Enter the standard environment nix develop # Enter the CUDA-enabled environment (Linux only) nix develop .#cuda ``` -------------------------------- ### Install cargo-cunew and generate a project Source: https://deepwiki.com/copper-project/copper-rs/4.4-project-templates Install cargo-cunew and generate a new Copper project using the project template and crates.io source. ```bash # Install the tool cargo install cargo-cunew # Generate a new robot project cargo cunew my_robot --template project --source crates.io ``` -------------------------------- ### Example Task and Connection Configuration Source: https://deepwiki.com/copper-project/copper-rs/4.2-configuration-with-ron Example configuration defining a task node 'src' of type 'tasks::MultiOutSrc' and a sink task 'int_sink' of type 'tasks::IntSink', with a connection from 'src' to 'int_sink' carrying message type 'i32'. The connection includes a 'missions' field specifying 'default'. ```plaintext tasks: [ ( id: "src", type: "tasks::MultiOutSrc", ), ( id: "int_sink", type: "tasks::IntSink", missions: ["default"], ), ], cnx: [ ( src: "src", dst: "int_sink", msg: "i32", missions: ["default"], ), ] ``` -------------------------------- ### Import cu29-export in logreader.rs Source: https://deepwiki.com/copper-project/copper-rs/4.3-deployment Example import from logreader.rs showing how to use the cu29-export library to process raw log data. The actual import path is abbreviated with '...' in the source. ```rust // In logreader.rs, using cu29-export to process raw data use cu29_export::...; ``` -------------------------------- ### Physical to Logical Directory Mapping Source: https://deepwiki.com/copper-project/copper-rs/1.2-workspace-structure A Mermaid diagram illustrating the relationship between the root directory and the various crates within the Core, Components, Examples, and Support tiers. ```mermaid graph TB Root["copper-rs/"] Root --> CoreDir["core/"] Root --> CompDir["components/"] Root --> ExDir["examples/"] Root --> SupportDir["support/"] CoreDir --> cu29["cu29
(prelude crate)"] CoreDir --> cu29_runtime["cu29_runtime
(Execution Engine)"] CoreDir --> cu29_derive["cu29_derive
(Procedural Macros)"] CoreDir --> cu29_clock["cu29_clock
(RobotClock)"] CoreDir --> cu29_unifiedlog["cu29_unifiedlog
(Binary Logging)"] CompDir --> Bridges["bridges/
(cu_crsf, cu_zenoh_bridge)"] CompDir --> Sources["sources/
(cu_v4l, cu_bmi088)"] CompDir --> Tasks["tasks/
(cu_ahrs, cu_pid)"] CompDir --> Sinks["sinks/
(cu_rp_gpio)"] CompDir --> Payloads["payloads/
(cu_sensor_payloads)"] CompDir --> Res["res/
(cu_linux_resources)"] ExDir --> Caterpillar["cu_caterpillar
(Determinism Test)"] ExDir --> FlightCtrl["cu_flight_controller
(Flight Controller)"] ExDir --> BalanceBot["cu_rp_balancebot
(Self-balancing Robot)"] SupportDir --> cargo_cunew["cargo_cunew
(Project Scaffolding)"] ``` -------------------------------- ### Resource mapping for hardware access Source: https://deepwiki.com/copper-project/copper-rs/4.2-configuration-with-ron Binds tasks to resource slots using `.` syntax. The example maps a GPIO pin to a Linux resource provider, ensuring resource exclusivity or shared access during task graph construction. ```ron resources: [ (id: "linux", provider: "CuLinuxResources"), ], tasks: [ ( id: "motor", type: "tasks::RPGpio", resources: { "pin": "linux.gpio0", }, ), ] ``` -------------------------------- ### Configure Tasks in copperconfig.ron Source: https://deepwiki.com/copper-project/copper-rs/3.2-task-components Example of defining a PID controller task within the tasks list in the copperconfig.ron configuration file. ```ron ( tasks: [ ( id: "pid_controller", type: "cu_pid::GenericPIDTask", config: { "kp": 1.5, "ki": 0.1, "kd": 0.05, "setpoint": 10.0, "cutoff": 5.0, "sampling_ms": 10, }, ), ], ) ``` -------------------------------- ### Custom Sink Boilerplate Source: https://deepwiki.com/copper-project/copper-rs/3.3-sink-components Example implementation of the CuSinkTask trait for creating a custom sink. ```rust impl CuSinkTask for MySink { type Resources<'r> = MyResources; type Input<'m> = input_msg!(MyPayload); fn new(_config: Option<&ComponentConfig>, resources: Self::Resources<'_>) -> CuResult { // Initialization logic Ok(Self { ... }) } fn process(&mut self, _ctx: &CuContext, msg: &Self::Input<'_>) -> CuResult<()> { let payload = msg.payload().unwrap(); // Actuation logic Ok(()) } } ``` -------------------------------- ### Log 3D points with Rerun in cu_pointclouds Source: https://deepwiki.com/copper-project/copper-rs/5.4-point-cloud-processing In the cu_pointclouds example, the RerunPlyViz sink task logs 3D points to a Rerun viewer. It converts payload points to Position3D and logs them as rerun::Points3D, mapping errors to CuError. ```rust // examples/cu_pointclouds/src/main.rs:44-51 let points: Vec = payload .iter() .map(|p| Position3D::new(p.x.value, p.y.value, p.z.value)) .collect(); self.rec .log("points", &rerun::Points3D::new(points)) .map_err(|e| CuError::new_with_cause("Failed to log points", e))?; ``` -------------------------------- ### Component Hierarchy Mermaid Diagram Source: https://deepwiki.com/copper-project/copper-rs/3-components A class diagram illustrating the interfaces for CuSrcTask, CuTask, CuSinkTask, and CuMonitor, along with examples for each. ```mermaid classDiagram class "CuSrcTask" { <> +new(config: Option<&ComponentConfig>) CuResult~Self~ +process(clock: &RobotClock, output: Self::Output) CuResult<()> +start() CuResult<()> +stop() CuResult<()> } class "CuTask" { <> +new(config: Option<&ComponentConfig>) CuResult~Self~ +process(clock: &RobotClock, input: Self::Input, output: Self::Output) CuResult<()> +start() CuResult<()> +stop() CuResult<()> } class "CuSinkTask" { <> +new(config: Option<&ComponentConfig>) CuResult~Self~ +process(clock: &RobotClock, input: Self::Input) CuResult<()> +start() CuResult<()> +stop() CuResult<()> } class "CuMonitor" { <> +new(config: Option<&ComponentConfig>) CuResult~Self~ +process_copperlist() CuResult<()> +process_error() CuResult<()> } class "SourceExamples" { "HesaiSource [cu_hesai]" "Bmi088Source [cu_bmi088]" "Wt901Source [cu_wt901]" "Ads7883Source [cu_ads7883]" } class "TaskExamples" { "AprilTagDetector [cu_apriltag]" "PidController [cu_pid]" } class "SinkExamples" { "RPGpio [cu_rp_gpio]" "RpSn754410 [cu_rp_sn754410]" "ZenohSink [cu_zenoh_sink]" } "CuSrcTask" <|-- "SourceExamples" "CuTask" <|-- "TaskExamples" "CuSinkTask" <|-- "SinkExamples" ``` -------------------------------- ### Feature Flag Propagation Diagram Source: https://deepwiki.com/copper-project/copper-rs/6.6-cross-platform-development Mermaid graph showing how the std feature propagates from cu29 to cu29-clock and cu29-runtime, and how firmware feature pulls in defmt and rp235x-hal for embedded targets. The cu-min-baremetal uses no-default-features to get cu29 in no_std mode. ```mermaid graph TB cu29["cu29
(prelude)"] cu29_clock["cu29-clock"] cu29_runtime["cu29-runtime"] cu29 -->|"std feature"| cu29_clock cu29 -->|"std feature"| cu29_runtime subgraph "Embedded Targets" rp2350["cu-rp2350-skeleton"] min_baremetal["cu-min-baremetal"] end rp2350 -->|"firmware feature"| defmt["defmt"] rp2350 -->|"firmware feature"| hal["rp235x-hal"] min_baremetal -->|"no-default-features"| cu29_nostd["cu29 (no_std)"] ``` -------------------------------- ### Run BalanceBot simulation Source: https://deepwiki.com/copper-project/copper-rs/5-examples Executes the BalanceBot simulation from the workspace root with the sim feature enabled. ```bash # From the workspace root cargo run --bin balancebot-sim --features sim ``` -------------------------------- ### Copper Build and Runtime Entity Mapping Source: https://deepwiki.com/copper-project/copper-rs/1-overview A Mermaid diagram illustrating the relationship between build-time configuration, runtime initialization, the execution engine, and the task lifecycle. ```mermaid graph TB subgraph "Build Time (cu29_derive)" RON["copperconfig.ron
(CuConfig Definition)"] Macro["#[copper_runtime]
(cu29_derive::lib)"] AppStruct["Application Struct
(impl CuApp)"] end subgraph "Runtime Initialization" Builder["CuRuntimeBuilder
(cu29_runtime::curuntime)"] Clock["RobotClock
(cu29_clock::lib)"] RM["ResourceManager
(cu29_runtime::resource)"] end subgraph "Execution Engine (cu29_runtime)" CuRuntime["CuRuntime
(Core Scheduler)"] CopperList["CopperList
(Message Double-Buffer)"] CuContext["CuContext
(cu29_runtime::context)"] end subgraph "Task Lifecycle (cu29_traits)" CuSrcTask["CuSrcTask::process()
(Data Ingestion)"] CuTask["CuTask::process()
(Processing)"] CuSinkTask["CuSinkTask::process()
(Actuation)"] end RON --> Macro Macro --> AppStruct AppStruct --> Builder Builder --> CuRuntime Clock --> CuContext RM --> CuRuntime CuRuntime --> CopperList CopperList --> CuSrcTask CuSrcTask --> CuTask CuTask --> CuSinkTask ``` -------------------------------- ### Include directive with parameters Source: https://deepwiki.com/copper-project/copper-rs/4.2-configuration-with-ron Shows how to include a reusable configuration file `motors.ron` with parameter substitution using `{{param_name}}` syntax. The `params` map replaces placeholders in the included RON string at load time. ```ron includes: [ ( path: "motors.ron", params: { "id": "left", "pin": 4, "direction": "forward", }, ), ] ``` -------------------------------- ### Deployment Mapping: Code to System (Mermaid) Source: https://deepwiki.com/copper-project/copper-rs/4.3-deployment Mermaid diagram mapping deployment code entities (ResourceBundle, CuSrcTask/CuSinkTask, EMMCLogger, cu29-export) to physical/OS counterparts (Platform HAL, hardware peripherals, raw SD partition, host PC). Shows relationships such as ResourceBundle wrapping the HAL and EMMCLogger streaming to the raw SD partition. ```mermaid graph TD subgraph "Code Entity Space" RB["ResourceBundle (e.g. MicoAirBundle)"] CT["CuSrcTask / CuSinkTask"] EL["EMMCLogger"] EXP["cu29-export"] end subgraph "Physical / OS Space" HAL["Platform HAL (stm32h7xx-hal / rp235x-hal)"] HW["Hardware Peripherals (UART/SPI)"] RAW["Raw SD Partition"] HOST["Host PC (Log Analysis)"] end RB -- "wraps" --> HAL HAL -- "controls" --> HW CT -- "uses" --> RB EL -- "streams to" --> RAW RAW -- "read by" --> EXP EXP -- "runs on" --> HOST ``` -------------------------------- ### Run cu29-rendercfg to visualize RON config Source: https://deepwiki.com/copper-project/copper-rs/4.2-configuration-with-ron Run the cu29-rendercfg CLI tool to visualize a RON configuration as an SVG DAG. The --config flag specifies the RON configuration file to parse. ```bash cargo run -p cu29-runtime --bin cu29-rendercfg -- --config copperconfig.ron ``` -------------------------------- ### CuBridge trait definition Source: https://deepwiki.com/copper-project/copper-rs/3.4-bridge-components Defines the required interface for all Copper bridges, including associated types for resources, Tx and Rx channel sets, and methods for initialization, starting, sending, and receiving messages. ```rust pub trait CuBridge: Freezable + Reflect { type Resources<'r>; type Tx: BridgeChannelSet; type Rx: BridgeChannelSet; fn new( config: Option<&ComponentConfig>, tx_channels: &[BridgeChannelConfig<::Id>], rx_channels: &[BridgeChannelConfig<::Id>], resources: Self::Resources<'_>, ) -> CuResult where Self: Sized; fn start(&mut self, ctx: &CuContext) -> CuResult<()>; fn send<'a, Payload>( &mut self, ctx: &CuContext, channel: &'static BridgeChannel<::Id, Payload>, msg: &CuMsg, ) -> CuResult<()> where Payload: CuMsgPayload + 'a; fn receive<'a, Payload>( &mut self, ctx: &CuContext, channel: &'static BridgeChannel<::Id, Payload>, msg: &mut CuMsg, ) -> CuResult<()> where Payload: CuMsgPayload + 'a; } ``` -------------------------------- ### Macro Expansion and Configuration Mapping Diagram Source: https://deepwiki.com/copper-project/copper-rs/7-glossary A Mermaid diagram showing the transformation process from RON configuration files to executable Rust code via procedural macros. ```mermaid graph TD subgraph "Config Space" J["copperconfig.ron"] K["CuConfig (Struct)"] end subgraph "Macro Space (cu29_derive)" L["copper_runtime macro"] M["assemble_runtime_plan()"] end subgraph "Generated Code Space" N["struct MyRobotApp"] O["CuRuntime<...>"] P["CopperListTuple"] end J --> K K --> L L --> M M --> N N --> O O --> P ``` -------------------------------- ### Visualize Task Graph with cu29-rendercfg Source: https://deepwiki.com/copper-project/copper-rs/4.5-monitoring-and-debugging A Mermaid diagram illustrating the workflow of the cu29-rendercfg tool, showing how RON configuration files and optional logstats are processed to generate an SVG task graph. ```mermaid graph TD subgraph "cu29-rendercfg (core/cu29_runtime/src/rendercfg.rs)" ConfigParser["read_configuration()"] Topology["build_render_topology()"] LayoutEngine["VisualGraph Layout (layout-rs)"] SVGRenderer["SVG Generation"] end RON["copperconfig.ron"] --> ConfigParser LogStats["logstats.json (Optional)"] --> SVGRenderer ConfigParser --> Topology Topology --> LayoutEngine LayoutEngine --> SVGRenderer SVGRenderer --> SVG["TaskGraph.svg"] ``` -------------------------------- ### SD card partitioning diagram for Copper logs Source: https://deepwiki.com/copper-project/copper-rs/4.3-deployment Mermaid diagram showing the SD/EMMC partitioning scheme. The GPT partition table contains an optional FAT32/config partition and a Copper raw log partition, which is detected by find_copper_partition() and used by EMMCLogger or EMMCSectionStorage. ```mermaid graph LR Disk["Physical SD/EMMC"] --> GPT["GPT Partition Table"] GPT --> P1["FAT32/Config (Optional)"] GPT --> P2["Copper Raw Log Partition"] P2 -- "Detected by" --> Find["find_copper_partition()"] Find --> Logger["EMMCLogger / EMMCSectionStorage"] ``` -------------------------------- ### Bridge Interface Implementation (Mermaid sequence diagram) Source: https://deepwiki.com/copper-project/copper-rs/4.4-project-templates Mermaid sequence diagram showing the interaction between CuRuntime, CuBdshotBridge, and BridgeChannelDescriptor during bridge initialization. ```mermaid sequenceDiagram participant Runtime as "CuRuntime" participant Bridge as "CuBdshotBridge" participant Channel as "BridgeChannelDescriptor" Runtime->>Bridge: "new(config, tx_configs, rx_configs, resources)" Bridge->>Channel: "from_static(STATIC_CHANNELS, ...)" Note over Bridge, Channel: Validates IDs and Routes Bridge-->>Runtime: "CuResult" ``` -------------------------------- ### Caterpillar Task Graph Source: https://deepwiki.com/copper-project/copper-rs/5-examples A Mermaid flowchart illustrating the task chain and GPIO mapping for the Caterpillar latency measurement application. ```mermaid flowchart LR subgraph "Caterpillar Logic" Src["tasks::CaterpillarSource"] -- "RPGpioPayload" --> CT0["tasks::CaterpillarTask (ct-0)"] CT0 -- "RPGpioPayload" --> CT1["tasks::CaterpillarTask (ct-1)"] CT1 -- "..." --> CTN["tasks::CaterpillarTask (ct-7)"] end subgraph "Hardware/Sink" CT0 --> GPIO0["cu_rp_gpio::RPGpio (pin 4)"] CT1 --> GPIO1["cu_rp_gpio::RPGpio (pin 17)"] CTN --> GPION["cu_rp_gpio::RPGpio (pin 26)"] end ``` -------------------------------- ### CuExecutionStep Structure Source: https://deepwiki.com/copper-project/copper-rs/2.1-task-graph-system Defines the structure for an execution step, including node identification, node data, and task classification. ```rust pub struct CuExecutionStep { pub node_id: NodeId, pub node: Node, pub task_type: CuTaskType, // ... input/output slot mapping } ``` -------------------------------- ### Custom Sink Implementation Logic Source: https://deepwiki.com/copper-project/copper-rs/3.3-sink-components A sequence diagram illustrating the lifecycle of a custom sink component within the Copper runtime. ```mermaid sequenceDiagram participant R as CuRuntime participant S as CustomSink participant HW as Hardware/Network R->>S: new(config, resources) Note over S: Extract pins/ports from resources R->>S: start(ctx) loop Every Cycle R->>S: process(ctx, input_msg) S->>S: msg.payload().unwrap() S->>HW: Write(data) end R->>S: stop(ctx) Note over S: Set hardware to safe state ``` -------------------------------- ### Build cu-blinky for RP2350 (ARM and RISC-V) Source: https://deepwiki.com/copper-project/copper-rs/4.3-deployment Build the cu-blinky application for the RP2350 embedded target. The first command targets ARM Cortex-M33, and the second targets RISC-V. Both use the firmware feature and specify the appropriate target triple. ```bash # Build for ARM Cortex-M33 (RP2350) cargo build --bin cu-blinky --features firmware --target thumbv8m.main-none-eabihf # Build for RISC-V (RP2350) cargo build --bin cu-blinky --features firmware --target riscv32imac-unknown-none-elf ``` -------------------------------- ### Constructing RobotClock for Bare-Metal Source: https://deepwiki.com/copper-project/copper-rs/2.4-clock-and-timing Initializes a RobotClock instance for no_std environments by providing a closure for the RTC and a sleep function for calibration. ```rust let clock = RobotClock::new_with_rtc( move || rtc_now_ns(), move |ns| { /* busy sleep implementation */ } ); ``` -------------------------------- ### Benchmark Entity Mapping Sequence Diagram Source: https://deepwiki.com/copper-project/copper-rs/4.1-building-and-testing A Mermaid sequence diagram illustrating the workflow for checking benchmark crates using the justfile. ```mermaid sequenceDiagram participant Dev as Developer participant Just as justfile participant Bench as benchmarks/ participant Framework as External Frameworks Dev->>Just: just check-extra-examples Just->>Bench: cargo check -p dora_caterpillar Just->>Bench: cargo check -p horus_caterpillar Note over Bench, Framework: Performance Comparison (Latency/Throughput) ``` -------------------------------- ### Payload System Architecture Diagram Source: https://deepwiki.com/copper-project/copper-rs/3.5-payload-definitions A Mermaid diagram illustrating the mapping of natural language sensor concepts to Rust structs, traits, and runtime handling within the Copper ecosystem. ```mermaid graph TD subgraph "Natural Language Concepts" IMU["IMU Sensor Data"] Cam["Camera Frames"] LiDAR["LiDAR Point Clouds"] ROS["ROS2 Interop"] end subgraph "Code Entity Space (cu-sensor-payloads)" ImuPayload["ImuPayload struct"] CuImage["CuImage<A> struct"] PointCloud["PointCloud struct"] SoA["PointCloudSoa struct"] end subgraph "Bridge Entity Space (cu-ros2-payloads)" RosAdapter["RosMsgAdapter trait"] RosImage["Image (sensor_msgs)"] RosCloud["PointCloud2 (sensor_msgs)"] end subgraph "Runtime Handling" Handle["CuHandle<A>"] Pool["CuHostMemoryPool"] end IMU --> ImuPayload Cam --> CuImage LiDAR --> PointCloud PointCloud -.->|derive SoA| SoA CuImage --> Handle Handle --> Pool CuImage --> RosAdapter RosAdapter --> RosImage SoA --> RosAdapter RosAdapter --> RosCloud ``` -------------------------------- ### Architecture Mapping Diagram Source: https://deepwiki.com/copper-project/copper-rs/5-examples A Mermaid flowchart illustrating the relationship between the Natural Language Space and the Code Entity Space within the Copper framework. ```mermaid flowchart TB subgraph "Natural Language Space" Config["RON Configuration"] App["Application Definition"] Logic["Component Logic"] Monitor["System Monitoring"] end subgraph "Code Entity Space" RON["copperconfig.ron"] Macro["#[copper_runtime]"] Traits["CuTask / CuSrcTask"] Console["CuConsoleMon"] end Config -.->|Defines| RON App -.->|Generates| Macro Logic -.->|Implements| Traits Monitor -.->|Visualizes| Console RON --> Macro Macro --> Traits Traits --> Console ``` -------------------------------- ### IceOryx2 Integration Architecture Diagram Source: https://deepwiki.com/copper-project/copper-rs/5.5-iceoryx-integration Architecture diagram showing the iceoryx2 integration pattern: a Copper producer task passes a CuHandle to a cu_iceoryx2_sink publisher, which writes to shared memory managed by RouDi; a cu_iceoryx2_src subscriber reads and passes the handle to a consumer task. The CuHostMemoryPool integrates with the sink to preserve zero-copy behavior. ```mermaid graph TB subgraph "Process_A_Copper_App" ["Process A: Copper Application"] TaskA["CuTask Producer"] IoxSink["cu_iceoryx2_sink Publisher"] CuPool["CuHostMemoryPool"] end subgraph "IceOryx2_Shared_Memory" ["IceOryx2 Shared Memory"] SHM["Shared Memory Segment"] RouDaemon["RouDi/Service Manager"] end subgraph "Process_B_Copper_App" ["Process B: Copper Application"] IoxSrc["cu_iceoryx2_src Subscriber"] TaskB["CuTask Consumer"] end TaskA -->|"CuHandle"| IoxSink IoxSink -->|"Write"| SHM SHM -->|"Read"| IoxSrc IoxSrc -->|"CuHandle"| TaskB RouDaemon -.->|"Manages"| SHM CuPool -.->|"Integrates"| IoxSink ``` -------------------------------- ### Task Graph Topology (Mermaid) Source: https://deepwiki.com/copper-project/copper-rs/5.2-caterpillar Mermaid diagram showing the task graph topology: a CaterpillarSource feeds eight CaterpillarTasks in a sequential chain, and each task sends an RPGpioPayload to a corresponding RPGpio GPIO sink. Solid arrows indicate the message propagation chain; dashed arrows show parallel GPIO actuation. ```mermaid graph TB src["CaterpillarSource
(src)"] ct0["CaterpillarTask
(ct-0)"] ct1["CaterpillarTask
(ct-1)"] ct2["CaterpillarTask
(ct-2)"] ct3["CaterpillarTask
(ct-3)"] ct4["CaterpillarTask
(ct-4)"] ct5["CaterpillarTask
(ct-5)"] ct6["CaterpillarTask
(ct-6)"] ct7["CaterpillarTask
(ct-7)"] gpio0["RPGpio
(gpio-0)
Pin 4"] gpio1["RPGpio
(gpio-1)
Pin 17"] gpio2["RPGpio
(gpio-2)
Pin 27"] gpio3["RPGpio
(gpio-3)
Pin 22"] gpio4["RPGpio
(gpio-4)
Pin 5"] gpio5["RPGpio
(gpio-5)
Pin 6"] gpio6["RPGpio
(gpio-6)
Pin 19"] gpio7["RPGpio
(gpio-7)
Pin 26"] src -->|"RPGpioPayload"| ct0 ct0 -->|"RPGpioPayload"| ct1 ct1 -->|"RPGpioPayload"| ct2 ct2 -->|"RPGpioPayload"| ct3 ct3 -->|"RPGpioPayload"| ct4 ct4 -->|"RPGpioPayload"| ct5 ct5 -->|"RPGpioPayload"| ct6 ct6 -->|"RPGpioPayload"| ct7 ct0 -.->|"RPGpioPayload"| gpio0 ct1 -.->|"RPGpioPayload"| gpio1 ct2 -.->|"RPGpioPayload"| gpio2 ct3 -.->|"RPGpioPayload"| gpio3 ct4 -.->|"RPGpioPayload"| gpio4 ct5 -.->|"RPGpioPayload"| gpio5 ct6 -.->|"RPGpioPayload"| gpio6 ct7 -.->|"RPGpioPayload"| gpio7 ``` -------------------------------- ### CI Data Flow and Entity Mapping Source: https://deepwiki.com/copper-project/copper-rs/4.1-building-and-testing A Mermaid flowchart illustrating the triggers, general CI processes, audit/security checks, and documentation generation workflows. ```mermaid flowchart TD subgraph "Triggers" Push["Push to Master"] PR["Pull Request"] Weekly["Weekly Schedule (weekly.yml)"] end subgraph "General CI (general.yml)" Setup["rust-ci-setup action"] Lints["just clippy-std"] StdTests["cargo nextest run"] EmbeddedCI["reusable-embedded.yml"] Setup --> Lints Setup --> StdTests Setup --> EmbeddedCI end subgraph "Audit & Security (weekly.yml)" Deny["cargo deny check (bans, sources, advisories)"] Beta["rust-toolchain@beta"] Deny --> Beta end subgraph "Documentation (docs.yaml)" Cov["reusable-coverage.yml"] Wiki["wiki_site.py"] APIDoc["cargo +nightly doc"] Cov --> Wiki Wiki --> APIDoc end Push --> GeneralCI PR --> GeneralCI Weekly --> Deny Push --> Cov ``` -------------------------------- ### copper_runtime macro pipeline diagram Source: https://deepwiki.com/copper-project/copper-rs/1.1-core-concepts Mermaid graph showing the flow from copperconfig.ron through the copper_runtime procedural macro, which uses read_configuration_with_features() and assemble_runtime_plan() to generate the CuRuntime struct and initialize CuRuntimeParts. ```mermaid graph TB RON["copperconfig.ron"] Macro["proc_macro copper_runtime"] Read["read_configuration_with_features()"] Plan["assemble_runtime_plan()"] GenRuntime["Generate CuRuntime Struct"] GenParts["CuRuntimeParts Initialization"] RON --> Read Read --> Macro Macro --> Plan Plan --> GenRuntime GenRuntime --> GenParts ``` -------------------------------- ### V4L Component Architecture Flowchart Source: https://deepwiki.com/copper-project/copper-rs/3.1-source-components A Mermaid flowchart illustrating the interaction between the Linux Kernel V4L2 device, the cu_v4l::CuV4LStream component, Copper memory management, and the V4l Source Task. ```mermaid flowchart TB subgraph "Linux Kernel" V4LDevice["/dev/videoN
V4L2 Device"] end subgraph "cu_v4l::CuV4LStream" ReqBufs["VIDIOC_REQBUFS
(Request Buffers)"] QueueBuf["VIDIOC_QBUF
(Queue Buffer)"] DequeueBuf["VIDIOC_DQBUF
(Dequeue Buffer)"] Arena["Arena: Vec<(Metadata, Option)>"] end subgraph "Copper Memory" HostPool["CuHostMemoryPool>"] Handle["CuHandle>"] end subgraph "V4l Source Task" Process["V4l::process()"] Output["CuMsg"] end V4LDevice --> ReqBufs HostPool --> Handle Handle --> Arena Arena --> QueueBuf QueueBuf --> V4LDevice V4LDevice --> DequeueBuf DequeueBuf --> Arena Arena --> Process Process --> Output ``` -------------------------------- ### BalanceBot Task Graph (Mermaid) Source: https://deepwiki.com/copper-project/copper-rs/5.1-balancebot Mermaid diagram showing the task graph with cascaded PID control. Tasks include balpos, railpos, balpos_pid, railpos_pid, merge_pids, and motor, with data flow between them. ```mermaid graph LR Balpos["balpos
cu_ads7883_new::ADS7883"] Railpos["railpos
cu_rp_encoder::Encoder"] BalPID["balpos_pid
tasks::BalPID"] RailPID["railpos_pid
tasks::PosPID"] Merger["merge_pids
tasks::PIDMerger"] Motor["motor
cu_rp_sn754410_new::SN754410"] Balpos -->|"ADSReadingPayload"| BalPID Railpos -->|"EncoderPayload"| RailPID BalPID -->|"PIDControlOutputPayload"| Merger RailPID -->|"PIDControlOutputPayload"| Merger Merger -->|"MotorPayload"| Motor ``` -------------------------------- ### AnyNet Entity Mapping Diagram Source: https://deepwiki.com/copper-project/copper-rs/5.6-anynet-anytime-stereo-depth Mermaid diagram mapping AnyNet logical components to code entities: TargetSrc, IncrementalPlanner, cu_anynet::model::stages, RecordingSink, and the copper_runtime macro. ```mermaid graph LR subgraph "Logic Space" ST["Stereo Input"] AN["AnyNet Model"] DS["Depth Map"] end subgraph "Code Entity Space" ST_C["TargetSrc"] AN_C["IncrementalPlanner"] AN_M["cu_anynet::model::stages"] DS_C["RecordingSink"] RT["copper_runtime macro"] end ST -.-> ST_C AN -.-> AN_C AN_C --> AN_M DS -.-> DS_C RT -- "Generates" --> AN_C ``` -------------------------------- ### Configuration Structure Diagram (Mermaid classDiagram) Source: https://deepwiki.com/copper-project/copper-rs/4.2-configuration-with-ron Mermaid class diagram showing the structure of CuConfig and related classes. Use to visualize the configuration data model. ```mermaid classDiagram class CuConfig { +tasks: Vec~Node~ +cnx: Vec~SerializedCnx~ +bridges: Vec~BridgeConfig~ +resources: Vec~ResourceBundleConfig~ +missions: Vec~MissionDef~ +includes: Vec~IncludeDirective~ } class Node { +id: String +type: Option~String~ +config: Option~ComponentConfig~ +resources: Option~HashMap~ +missions: Option~Vec~String~~ } class BridgeConfig { +id: String +type: String +channels: Vec~BridgeChannelConfigRepresentation~ } CuConfig --> "0..*" Node CuConfig --> "0..*" BridgeConfig ``` -------------------------------- ### GPU Task Processing Sequence Diagram Source: https://deepwiki.com/copper-project/copper-rs/6.5-gpu-acceleration Mermaid sequence diagram showing the typical flow of a GPU-accelerated task using CuTask, CuHostMemoryPool, and CuCudaPool. It illustrates receiving input, copying to device, executing kernel, and copying results back to host. ```mermaid sequenceDiagram participant Task as CuTask participant HostPool as CuHostMemoryPool participant DevicePool as CuCudaPool participant GPU as CUDA Device Task->>HostPool: Receive input CuHandle Task->>DevicePool: copy_from(input_handle) DevicePool-->>Task: device_handle Task->>GPU: Execute Kernel GPU-->>Task: Computation complete Task->>HostPool: acquire() HostPool-->>Task: output_handle Task->>DevicePool: copy_to_host_pool(device_handle, output_handle) ``` -------------------------------- ### BalanceBot Architecture Diagram (Mermaid) Source: https://deepwiki.com/copper-project/copper-rs/5.1-balancebot Mermaid diagram showing the BalanceBot architecture: common core components (copperconfig.ron, tasks.rs, cu_pid::PIDController) feed into three run modes (hardware, simulation, re-simulation), each with its own entry point and dependencies. ```mermaid graph TB subgraph "CommonCore" Config["copperconfig.ron
Task Graph Definition"] Tasks["src/tasks.rs
BalPID, PosPID, PIDMerger"] PIDLib["cu_pid::PIDController
Control Logic"] end subgraph "HardwareMode" HardwareMain["src/main.rs
BalanceBot struct"] RealSensors["Real Hardware
cu_ads7883_new
cu_rp_encoder"] RealMotor["Real Motor
cu_rp_sn754410_new"] end subgraph "SimulationMode" SimMain["src/sim.rs
BalanceBotSim struct"] BevyWorld["src/world/mod.rs
build_world"] SimDriver["src/sim_driver.rs
run_copper_callback"] Physics["Avian3d Physics
Cart + Rod Components"] end subgraph "ResimulationMode" ReSimMain["src/resim.rs
BalanceBotReSim struct"] LogReader["cu29_export::copperlists_reader
UnifiedLog Extraction"] ReSimCallbacks["balancebot_replay_step
SimOverride Injection"] end Config --> HardwareMain Config --> SimMain Config --> ReSimMain Tasks --> HardwareMain Tasks --> SimMain Tasks --> ReSimMain PIDLib --> Tasks HardwareMain --> RealSensors HardwareMain --> RealMotor SimMain --> SimDriver SimDriver --> Physics Physics --> BevyWorld ReSimMain --> LogReader LogReader --> ReSimCallbacks ``` -------------------------------- ### CuTask and Freezable Trait Definitions Source: https://deepwiki.com/copper-project/copper-rs/3.2-task-components A class diagram illustrating the CuTask trait interface and the Freezable trait for state persistence. ```mermaid classDiagram class CuTask { <> +type Resources +type Input +type Output +new(config: Option<&ComponentConfig>, resources: Self::Resources) -> CuResult +process(ctx: &CuContext, input: &Self::Input, output: &mut Self::Output) -> CuResult<()> +start(ctx: &CuContext) -> CuResult<()> +stop(ctx: &CuContext) -> CuResult<()> } class Freezable { <> +freeze(&self, encoder: &mut E) -> Result<(), EncodeError> +thaw(&mut self, decoder: &mut D) -> Result<(), DecodeError> } CuTask -- Freezable : "typically implements" ``` -------------------------------- ### Development Workflow Mapping Diagram Source: https://deepwiki.com/copper-project/copper-rs/4-development-guide A Mermaid diagram illustrating the relationship between entry points, automation scripts, and code entities. ```mermaid graph TD subgraph "Entry Points" NewApp["cargo cunew"] -- "Uses" --> Tmpl["templates/cu_project"] Workflow["Justfile / CI"] -- "Invokes" --> Scripts["support/ci/"] end subgraph "Automation Logic" Scripts -- "Filters" --> Excludes["support/ci/workspace_excludes.py"] Scripts -- "Validates" --> EmbCrates["support/ci/embedded_crates.py"] Scripts -- "Tests" --> CovScript["support/ci/run_coverage.sh"] end subgraph "Code Entities" Excludes -.-> RootCargo["/Cargo.toml"] EmbCrates -.-> Firmwares["examples/cu_rp2350_skeleton"] CovScript -.-> ProfData["target/llvm-cov/"] end ``` -------------------------------- ### Enable Simulation Mode in #[copper_runtime] Source: https://deepwiki.com/copper-project/copper-rs/6.3-simulation-and-re-simulation Set sim_mode to true within the #[copper_runtime] attribute to enable simulation capabilities for the application struct. ```rust #[copper_runtime(config = "copperconfig.ron", sim_mode = true)] struct MySimulatedApp {} ``` -------------------------------- ### Data Flow for Component Discovery (Mermaid flowchart) Source: https://deepwiki.com/copper-project/copper-rs/4.4-project-templates Mermaid flowchart showing how the catalog index references component crates, which implement bridges and define code entities like CuBdshotBridge and EscCommand. ```mermaid flowchart TD Catalog["Catalog Index (RON)"] -- "references" --> Crate["Component Crate (e.g., cu_bdshot)"] Crate -- "implements" --> Bridge["CuBridge Implementation"] subgraph "Code Entity Space" BridgeNode["struct CuBdshotBridge

"] ChannelSet["trait BridgeChannelSet"] MsgNode["struct EscCommand"] ConfigNode["struct BridgeChannelConfig"] end Bridge -.-> BridgeNode BridgeNode -- "defines" --> ChannelSet BridgeNode -- "processes" --> MsgNode BridgeNode -- "configured by" --> ConfigNode ``` -------------------------------- ### CuMsg class diagram (CuStampedData, CuMsgMetadata, Tov) Source: https://deepwiki.com/copper-project/copper-rs/1.1-core-concepts Mermaid class diagram showing the structure of CuStampedData (aliased as CuMsg) with payload, time-of-validity (Tov), and metadata. Includes CuMsgMetadata with process_time, status_txt, and origin, and the Tov enumeration with None, Time, and TimeRange variants. ```mermaid classDiagram class CuStampedData~T, M~ { payload: Option~T~ tov: Tov metadata: M } class CuMsgMetadata { process_time: PartialCuTimeRange status_txt: CuCompactString origin: Option~CuMsgOrigin~ } class Tov { <> None Time(CuTime) TimeRange(CuTimeRange) } CuStampedData --> CuMsgMetadata : Metadata = M CuStampedData --> Tov ``` -------------------------------- ### Flight Controller Mapping Source: https://deepwiki.com/copper-project/copper-rs/5-examples A Mermaid flowchart showing the hardware and code entity relationships for the Flight Controller application on STM32H7 hardware. ```mermaid flowchart TD subgraph "Hardware Entities" MCU["STM32H7 (MicoAirH743)"] DWT["DWT Cycle Counter"] end subgraph "Code Entities" Entry["#[entry] main()"] Clock["build_clock()"] AppStruct["#[copper_runtime] FlightControllerApp"] Resources["FlightControllerApp::prepare_resources()"] end MCU --- Entry DWT --- Clock Entry --> Resources Resources --> AppStruct AppStruct --> Run["CuApplication::run()"] ``` -------------------------------- ### Platform Abstraction Layer Mermaid Diagram Source: https://deepwiki.com/copper-project/copper-rs/6-advanced-topics A visual representation of the interaction between the high-level Copper Runtime and platform-specific code entities like RobotClock and ResourceManager. ```mermaid graph TD subgraph "Natural Language Space" Runtime["Copper Runtime"] Clock["System Clock"] HAL["Hardware Abstraction"] end subgraph "Code Entity Space" CU_RUNTIME["CuRuntime"] ROBOT_CLOCK["RobotClock"] RES_MANAGER["ResourceManager"] SOFT_RATATUI["soft_ratatui"] end CU_RUNTIME -- "Queries" --> ROBOT_CLOCK CU_RUNTIME -- "Requests HAL" --> RES_MANAGER RES_MANAGER -- "Renders TUI" --> SOFT_RATATUI ``` -------------------------------- ### Task Execution Data Flow Diagram Source: https://deepwiki.com/copper-project/copper-rs/7-glossary A Mermaid diagram illustrating the mapping between natural language task execution concepts and the corresponding CuRuntime code entities. ```mermaid graph LR subgraph "Natural Language Space" A["Task Execution"] B["Message Passing"] C["Logging"] end subgraph "Code Entity Space" A --> D["CuTask::process()"] D --> E["InputMsg<'a, P>"] D --> F["OutputMsg<'a, P>"] E --> G["CopperList"] F --> G G --> H["UnifiedLogWrite"] H --> I["MmapUnifiedLogger"] end ``` -------------------------------- ### Re-simulation Data Flow Diagram Source: https://deepwiki.com/copper-project/copper-rs/6-advanced-topics Mermaid diagram showing how CuDebugSession interacts with recorded logs and application logic, including UnifiedLogRead, CuApp, and SimOverride components. ```mermaid graph TD subgraph "Natural Language Space" Log["Recorded Log File"] Session["Debug Session"] App["Robot Application"] end subgraph "Code Entity Space" UNIFIED_LOG["UnifiedLogRead"] DEBUG_SESSION["CuDebugSession"] CU_APP["CuApp"] SIM_OVERRIDE["SimOverride"] end UNIFIED_LOG -- "Provides Data" --> DEBUG_SESSION DEBUG_SESSION -- "Drives" --> CU_APP CU_APP -- "Uses" --> SIM_OVERRIDE SIM_OVERRIDE -- "Injects Inputs" --> DEBUG_SESSION ``` -------------------------------- ### Clock Calibration Sequence Diagram Source: https://deepwiki.com/copper-project/copper-rs/2.4-clock-and-timing A sequence diagram illustrating the calibration process between the RobotClock, the calibration function, the hardware counter, and the reference clock. ```mermaid sequenceDiagram participant C as RobotClock participant Cal as calibration::calibrate participant HW as Hardware Counter participant RTC as Reference Clock (RTC) C->>Cal: calibrate(read_raw_counter, read_rtc_ns, sleep_ns) Cal->>HW: read_raw_counter (Start) Cal->>RTC: read_rtc_ns (Start) Cal->>Cal: sleep_ns(10ms) Cal->>HW: read_raw_counter (End) Cal->>RTC: read_rtc_ns (End) Note over Cal: freq = (delta_counter * 1e9) / delta_rtc_ns Cal->>Cal: Store calibration constants ``` -------------------------------- ### Cargo.toml profile.release and hot-path overrides Source: https://deepwiki.com/copper-project/copper-rs/6.1-performance-optimization Defines release optimizations with debug info and overrides for hot-path packages (candle-core and rayon) to always compile with opt-level 3. ```toml [profile.release] debug = 2 # Application hot-path overrides [profile.dev.package.candle-core] opt-level = 3 [profile.dev.package.rayon] opt-level = 3 ```