Accessing temperature data in addition to operating states

Hello,

I’ve seen that there are operating states related to temperature control that can be retrieved. Since there is likely some form of temperature monitoring, would it also be possible to access the actual temperature data?

Thank you in advance.

Yeah it is possible to retrieve the temperature data using the rest API

Simply invoke use the following if you are using shell:

curl http://<sensor_url>/api/v1/sensor/telemetry

Or try this snippet if you prefer using python:

import requests

sensor_url = "os-xxxxxxxxxx.local"
data = requests.get(f"http://{sensor_url}/api/v1/sensor/telemetry")
print(data.content)

Hope this helps!

2 Likes

Thanks for the quick reply! It worked very well.

Would it be possible to include the live temperature telemetry in a PCAP recording of the sensor data?

Additionally, is there a way to configure which types of measurement data are stored in the PCAP? For example, similar to configuring the azimuth window, can I choose to include or omit fields such as reflectivity, near‑IR , etc. in the recorded packets?

Thanks in advance!

We don’t have currently anything that supports adding the raw temperature data as telemetry to the packet stream. The closest thing you get to that is the is the thermal shutdown status and the shot limiting reduction status.

With regard to picking and choosing which fields/measurement to be included in the packet stream you should check the UDP Lidar Profile. This facilities the ability to choose which measurement to be used based on pre-defined configuration supported by the current firmware version.

Alternatively, you can create a polling interface in python for telemetry data and save your temperature into an OSF file for later retrieval. The OSF file will include all the lidar data as well by default. I’m not sure if OSF is a useable format in your application but it will be for many customers. You can add whatever telemetry values you want into this file.

This code should work with SDK 0.16.x (simply replace the url at the top with your own):

import requests
import numpy as np
import threading
from ouster.sdk import open_source, osf, core

sensor_url = "os-xxxxxxxxxxxx.local"
osf_filename = "live_with_telemetry.osf"


def poll_telemetry_background(url, state, stop_event):
    """Runs in a separate thread, polling telemetry at 1Hz."""
    while not stop_event.is_set():
        try:
            response = requests.get(f"http://{url}/api/v1/sensor/telemetry", timeout=0.5)
            telemetry_data = response.json()
            # Update the shared state dictionary safely
            state["temp"] = float(telemetry_data.get("internal_temperature_deg_c", 0.0))
        except Exception:
            # If the network drops, just silently keep trying on the next loop
            pass

            # Sleep for 1 second, but allow immediate interruption if stop_event is set
        stop_event.wait(1.0)


def record_live_with_telemetry():
    # --- THREAD SETUP ---
    # Use a dictionary to hold state so it can be mutated by the thread
    shared_state = {"temp": 0.0}
    stop_event = threading.Event()

    # Spin up the background thread (daemon=True ensures it dies if the main script crashes)
    telemetry_thread = threading.Thread(
        target=poll_telemetry_background,
        args=(sensor_url, shared_state, stop_event),
        daemon=True
    )
    telemetry_thread.start()

    try:
        source = open_source(sensor_url)
        writer = osf.Writer(osf_filename, source.sensor_info)
        print(f"Recording live data to {osf_filename}...")

        frame_count = 0

        for (scan,) in source:
            if scan is None:
                continue

            # Instantly grab the latest temperature from the background thread
            current_temp = shared_state["temp"]
            # Add to scan and save (Using core.FieldClass)
            scan.add_field("TEMPERATURE",
                           np.array([current_temp]).view(np.recarray),
                           core.FieldClass.SCAN_FIELD)
            writer.save(0, scan)

            print(f"Saved Frame {scan.frame_id} | Temperature: {current_temp} °C")

            frame_count += 1
            if frame_count >= 50:
                break

        print("Recording complete!")

    finally:
        # --- CLEANUP ---
        # Ensure we tell the thread to stop and wait for it to close cleanly
        stop_event.set()
        telemetry_thread.join()
        writer.close()
        print("Telemetry thread cleanly shut down.")


if __name__ == "__main__":
    record_live_with_telemetry()

and here is how to retrieve data from the file:

from ouster.sdk import open_source

osf_filename = "live_with_telemetry.osf"

src = open_source(osf_filename)
print(src[0][0].field("TEMPERATURE"))

Alright, I managed to log the temperature data using a Python script with the API.
Thanks a lot for the quick replies @Samahu & @yggdrasil and the great support!

1 Like