camera
camera.py
Overview
camera.py is a horizontal sensor-stub component: a self-contained software camera that produces deterministic RGB + depth imagery even when no physical sensor is present. It lets downstream perception, fusion and visualisation nodes run in CI, headless simulation, or early prototyping environments where real hardware is unavailable.
Interfaces (strongly-typed, stateless)
Direction |
Topic |
Message type |
Notes |
---|---|---|---|
Provided |
|
|
Static BGR8 frame read from image.jpg |
Provided |
|
|
8-bit signed mono array (ones); same resolution as RGB |
Both topics share identical header.stamp
values and are published at
10 Hz, allowing time-synchronisation filters to treat them as a stereo pair.
Contract
Pre-conditions
The JPEG file exists and is readable.
Resolution ≤ 1920 × 1080 (soft real-time ceiling).
Post-conditions
The depth image’s height and width match the RGB frame exactly.
Header fields
stamp
andframe_id
are identical between colour and depth messages.
Invariants
Latency (JPEG load → publish) ≤ 8 ms on a 4-core laptop.
Peak RAM ≤ 2 × (W × H × 3) bytes (one colour buffer + one depth buffer).
Protocol
This component is stateless: each 100 ms cycle publishes fresh, independent messages.
Lifecycle
Node name
{robot}_camera
Ready once its publishers are advertised (no init service).
Clean shutdown on Ctrl-C or
rosnode kill
.
Quality & Reusability metrics
Latency < 8 ms | Throughput = 10 Hz | Cyclomatic complexity < 10
Directory layout
camera.py
expects the JPEG at
/root/Desktop/cogar_ass1/cogar_ws/src/tiago1/scripts/image.jpg
Update the path if you move the file; no other configuration is required.
Functions
|
Bootstrap the node and stream frames until ROS shuts down. |