Skip to content

Image Echo — C++ Example ​

Source: rbq_sdk/cpp/example/src/rbq_image_echo.cpp

A minimal, read-only diagnostic that subscribes to a compressed camera topic and prints the receive rate, last frame size, and image format once per second. Use it to confirm a camera stream is actually being published and is reachable from your SDK host.

How it works ​

The program:

  1. Reads the topic name from argv[1] (default rt/rbq/vision/sensor_4/rgb/compressed) and the network interface from argv[2] (default lo).
  2. Initializes the DDS ChannelFactory on that interface and creates a Subscriber<CompressedImage_>.
  3. On every received sample, updates a counter plus the last byte size and image format.
  4. Once per second, prints elapsed time, total samples, the 1-second rate, last frame size, and format.
  5. Exits cleanly on Ctrl+C (SIGINT/SIGTERM), printing the total sample count.

It never publishes, so it is safe to run alongside a live robot or the simulator.

Prerequisites ​

  • RBQ SDK built and installed — see C++ SDK Overview.
  • A publisher of the compressed image topic running — the robot's vision stack, or the MuJoCo simulator with vision (bash scripts/sim.bash --vision).

Build ​

From rbq_sdk/cpp/example/:

bash
bash scripts/setup.bash
bash scripts/build.bash

Binary: bin/rbq_image_echo

Run ​

Both arguments are optional:

bash
./bin/rbq_image_echo [topic] [interface]
ArgMeaningDefault
topicCompressed image topic to subscribe tort/rbq/vision/sensor_4/rgb/compressed
interfaceCycloneDDS interfacelo

In the MuJoCo simulator ​

The simulator publishes on lo — the same default this example uses — so no arguments are needed:

bash
bash scripts/sim.bash --vision     # one terminal
./bin/rbq_image_echo               # another terminal

Cameras use numeric ids on both the robot and the sim. sensor_4 is the front camera and sensor_5 is the rear camera; sensor_0–sensor_3 publish only depth and ir:

bash
./bin/rbq_image_echo rt/rbq/vision/sensor_4/rgb/compressed   # front camera
./bin/rbq_image_echo rt/rbq/vision/sensor_5/rgb/compressed   # rear camera

On a real robot, from another host ​

Pass the interface that reaches the robot as the second argument:

bash
./bin/rbq_image_echo rt/rbq/vision/sensor_4/rgb/compressed enp3s0

The robot-side vision stack has to run on an interface your PC can reach — start it on the robot with bash scripts/RBQ.bash -i <nic>. Both sides must use the same interface, otherwise you will see rate=0 Hz.

CycloneDDS logs selected interface "lo" is not multicast-capable: disabling multicast when running on lo. This is expected and harmless: discovery still works between processes on the same host, which is exactly the simulator case. Only cross-host setups need a real NIC.

Example output ​

Against the MuJoCo simulator (sim.bash --vision), subscribing to sensor_4 (front camera):

[rbq_image_echo] subscribed to 'rt/rbq/vision/sensor_4/rgb/compressed' on interface 'lo'
[rbq_image_echo] waiting for samples (Ctrl+C to exit)...
[rbq_image_echo] 1.0s  total=15  rate=15 Hz  last=13053 bytes  fmt='jpeg'
[rbq_image_echo] 2.0s  total=29  rate=14 Hz  last=13080 bytes  fmt='jpeg'
[rbq_image_echo] 3.0s  total=44  rate=15 Hz  last=13067 bytes  fmt='jpeg'
[rbq_image_echo] exiting, total samples = 44

A steady rate with non-zero byte sizes and fmt='jpeg' confirms the stream is live. rate=0 Hz means no publisher was found on that topic/interface — check the topic name and the DDS interface.

This user manual is intended for RBQ users.