Rayrai Example: Rolling Shutter
Overview
A camera head turns about the vertical axis inside a ring of yellow and blue poles. It carries two RGB cameras with the same lens and resolution (480 x 320): one with a global shutter and one with a rolling shutter that reads the rows from top to bottom. The two images are shown side by side. In the rolling-shutter image the poles lean, because the camera turns while the rows are read.
Target
CMake target: rayrai_rolling_shutter.
Run
From the repository root, build the target and run it:
source ./raisim_env.sh
cmake --build build-examples --target rayrai_rolling_shutter --parallel 2
./build-examples/examples/rayrai_rolling_shutterSee Build examples to configure a new build directory.
On Windows, run rayrai_rolling_shutter.exe instead. This example renders in process with rayrai and does not need rayrai_tcp_viewer.
Controls
- Yaw rate (-8 to 8 rad/s, default 5 rad/s): how fast the head turns. A negative rate turns it the other way, and the poles lean the other way.
- Readout time (0 to 60 ms, default 30 ms): the time from the first row to the last. At 0 the rolling shutter matches the global shutter.
The text above the images gives the slant: a pole moves by the yaw rate times the focal length (in pixels) times the readout time between the top row and the bottom row: 350 px x 5 rad/s x 0.03 s, about 53 pixels, at the defaults.
Save the window
The capture that the rayrai examples share (see rayrai/example_common.hpp) saves the window as a PNG and exits:
RAYRAI_EXAMPLE_CAPTURE=rolling_shutter.png ./build-examples/examples/rayrai_rolling_shutterDetails
- Declares the rolling shutter in the sensor XML inside
<camera>:<shutter type="rolling" readout_time="0.03" readout_direction="top_to_bottom"/>. - Changes the readout time with
RGBCamera::setProperties()(shutter.readoutTime). - Turns the head with
ArticulatedSystem::setGeneralizedVelocity()on a continuous joint, without gravity torques on its vertical axis. - Renders both cameras with the sensor overload
RayraiWindow::renderWithExternalCamera(sensor, camera, overrides), which draws a rolling-shutter camera in bands, each with the camera and the bodies moved to the band's readout time with their current velocities.
See Rolling shutter for the timing convention and Rolling shutter for how rayrai renders it.