Clock

Clock example screenshot

An example visualizing an analog clock with hour, minute and seconds hands using Rerun Arrow3D primitives.

Used Rerun types

Boxes3D, Points3D, Arrows3D

Logging and visualizing with Rerun

The visualizations in this example were created with the following Rerun code:

The clock's frame is logged as a 3D box using Boxes3D archetype.

rr.log( "world/frame", rr.Boxes3D(half_sizes=[LENGTH_S, LENGTH_S, 1.0], centers=[0.0, 0.0, 0.0]), timeless=True, )

Then, the positions and colors of points and arrows representing the hands of a clock for seconds, minutes, and hours are logged in each simulation time. It first sets the simulation time using timelines, calculates the data for each hand, and logs it using Points3D and Arrows3D archetypes. This enables the visualization of the clock's movement over time.

for step in range(steps): rr.set_time_seconds("sim_time", t_secs) # … calculating seconds … rr.log("world/seconds_pt", rr.Points3D(positions=point_s, colors=color_s)) rr.log("world/seconds_hand", rr.Arrows3D(vectors=point_s, colors=color_s, radii=WIDTH_S)) # … calculating minutes … rr.log("world/minutes_pt", rr.Points3D(positions=point_m, colors=color_m)) rr.log("world/minutes_hand", rr.Arrows3D(vectors=point_m, colors=color_m, radii=WIDTH_M)) # … calculating hours … rr.log("world/hours_pt", rr.Points3D(positions=point_h, colors=color_h)) rr.log("world/hours_hand", rr.Arrows3D(vectors=point_h, colors=color_h, radii=WIDTH_H))

Run the code

To run this example, make sure you have the Rerun repository checked out and the latest SDK installed:

# Setup pip install --upgrade rerun-sdk # install the latest Rerun SDK git clone git@github.com:rerun-io/rerun.git # Clone the repository cd rerun git checkout latest # Check out the commit matching the latest SDK release

Install the necessary libraries specified in the requirements file:

pip install -r examples/python/clock/requirements.txt

To experiment with the provided example, simply execute the main Python script:

python examples/python/clock/main.py # run the example

If you wish to customize it, explore additional features, or save it use the CLI with the --help option for guidance:

python examples/python/clock/main.py --help