librealsense icon indicating copy to clipboard operation
librealsense copied to clipboard

Read device temperature

Open Panepo opened this issue 9 years ago • 24 comments

Required Info
Camera Model D410
Firmware Version 05.06.09.00
Operating System & Version Win10 (Build 16299)
Kernel Version (Linux Only)

Hi there, I am trying to read both ASIC and projector temperature by following:

import pyrealsense2 as rs
import numpy as np
import cv2

pipeline = rs.pipeline()
config = rs.config()
config.enable_stream(rs.stream.depth, 640, 480, rs.format.z16, 30)
config.enable_stream(rs.stream.color, 640, 480, rs.format.bgr8, 30)

cfg = pipeline.start(config)
dev = cfg.get_device()
depth_sensor = dev.first_depth_sensor()

try:
    while True:

        # Wait for a coherent pair of frames: depth and color
        frames = pipeline.wait_for_frames()
        depth_frame = frames.get_depth_frame()
        color_frame = frames.get_color_frame()
        
        # Convert images to numpy arrays
        depth_image = np.asanyarray(depth_frame.get_data())
        color_image = np.asanyarray(color_frame.get_data())

        # Apply colormap on depth image (image must be converted to 8-bit per pixel first)
        depth_colormap = cv2.applyColorMap(cv2.convertScaleAbs(depth_image, None, 0.5, 0), cv2.COLORMAP_JET)

        # Stack both images horizontally
        images = np.hstack((color_image, depth_colormap))
        
        # Get device temperature
        tempProj = depth_sensor.get_option(rs.option.projector_temperature)
        print("tempProj: " + str(tempProj))
        tempAsic = depth_sensor.get_option(rs.option.asic_temperature)
        print("tempAsic: " + str(tempAsic ))

        # Show images
        cv2.namedWindow('RealSense', cv2.WINDOW_AUTOSIZE)
        cv2.imshow('RealSense', images)
        cv2.waitKey(1)

finally:

    # Stop streaming
    pipeline.stop()

But the temperature outputs are the same while I streaming, the outputs only change while I restart the program. How to read the device temperature dynamically? Thanks

Panepo avatar Nov 30 '17 06:11 Panepo

Hi @Panepo You are doing everything correctly. We are able to reproduce the problem but can't quite localize what is causing it. We see that when running in a simple loop (either using pipeline or using context/sensor API) often we get temperature data that is marked invalid - ds5-options.cpp:82:

if (0 == temperature_data.*is_valid_field)
            LOG_ERROR(rs2_option_to_string(_option) << " value is not valid!");

This doesn't seem to happen in the Viewer, but we couldn't quite put the finger on what in the Viewer is making the firmware send valid temperature. As an additional data-point, the issue doesn't seem to reproduce on Linux. We will keep looking into it and update if we find anything.

dorodnic avatar Nov 30 '17 12:11 dorodnic

Is this issue still present in the latest 2.9.0 release of librealsense? We also need access to reliable temperature values for our use-case.

rafaelspring avatar Jan 05 '18 11:01 rafaelspring

Hi @xtrawurst Yes, the bug is still present unfortunately. After spending quite a long time on this issue, I can only infer that it is some kind of race-condition at the firmware level. It reproduces most of the time in all applications but the viewer, but it sometimes also reproduces in the viewer. I can safely say it has nothing to do with intrinsics / extrinsics calls, pipeline vs sensor API, other options read, or anything else I could think of. We'll try to find a work-around.

dorodnic avatar Jan 13 '18 18:01 dorodnic

Looking at some internal documentation, it seems you can read projector temperature using following commands:

rs2::pipeline p;
auto profile = p.start();
auto dev = profile.get_device();

auto dbg = dev.as<rs2::debug_protocol>();
std::vector<uint8_t> cmd = { 0x14, 0, 0xab, 0xcd, 0x2a, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 };

auto res = dbg.send_and_receive_raw_data(cmd);
int temp = res[4];
std::cout << temp << std::endl;

This method is unaffected by the mysterious is_valid bit on the temperature XU (the option bug). There are two problems with this work-around:

  1. I couldn't find similar command to read the ASIC temperature
  2. This is not official API and therefore can break in the future

dorodnic avatar Jan 13 '18 19:01 dorodnic

[Realsense Customer Engineering Team Comment] Hi @xtrawurst,

would like to know if you still need help with this issue?

Regards

@RealSense-Customer-Engineering I'd like to know whether the issue persists. The workaround outlined by @dorodnic has got some problems too (as described).

rafaelspring avatar Feb 27 '18 10:02 rafaelspring

[Realsense Customer Engineering Team Comment] hi @xtrawurst,

we are still fixing this, will update you once we finished.

@RealSense-Customer-Engineering we are running into this problem too and would like to know if you found a better fix than the workaround specified above. We need both Asic and Projector temperature logs and the current fix is introducing significant conflicts.

Required Info  
Camera Model D435
Firmware Version 05.08.15.00
Operating System & Version Ubuntu 16.04
Kernel Version (Linux Only)  4.4.38

marinerain avatar Jun 27 '18 02:06 marinerain

This seems to be a somewhat tricky bug. We revisited it several times since it was originally reported, but with no luck so far, unfortunately. We were planning to revisit it again this sprint and update on any findings.

dorodnic avatar Jul 02 '18 16:07 dorodnic

Hi @dorodnic, @RealSense-Customer-Engineering , Any updates on this issue?

Thank you.

rupak-d avatar Oct 04 '18 15:10 rupak-d

[Realsense Customer Engineering Team Comment] Hi @rupak-d,

You can use the workaround code from @dorodnic first to read the projector temperature. @dordnic, do you have more info about the fix?

Still under investigation at firmware level

dorodnic avatar Oct 07 '18 13:10 dorodnic

[Realsense Customer Engineering Team Comment] Please try the firmware 5.10.13.0 to see if the error still can be reproduced.

Hi Sergey,

Thank you for the update. I transmitted that to our team and we will test it after Christmas break.

Regards

On Mon, Dec 17, 2018 at 6:24 AM RealSense Customer Engineering < [email protected]> wrote:

[Realsense Customer Engineering Team Comment] Please try the firmware 5.10.13.0 to see if the error still can be reproduced.

— You are receiving this because you commented. Reply to this email directly, view it on GitHub https://github.com/IntelRealSense/librealsense/issues/866#issuecomment-447863105, or mute the thread https://github.com/notifications/unsubscribe-auth/Amu-zUU3VZo1ruRb9aYgd8gGMDHpP-BTks5u56kFgaJpZM4QwETM .

-- Marine Dunoguier

Director of Embedded Systems

Alcatraz AI, Palo Alto, CA

www.alcatraz.ai https://alcatraz.ai/

marinerain avatar Dec 18 '18 02:12 marinerain

[Realsense Customer Engineering Team Comment] Hello @marinerain,

any test update?

Hopefully resolved now, @marinerain update this issue or feel free to open a new one, if the problem reproduces

dorodnic avatar Jan 22 '19 19:01 dorodnic

This issue still persists in the newest firmware 05.11.06.250

Kaju-Bubanja avatar Aug 30 '19 07:08 Kaju-Bubanja

I can second this. Running librealsense 2.26.0 and FW 05.11.06.250 on a D435.

Interestingly, the ASIC and projector temperature options appear in the list of supported options (sensor.get_supported_options()), but if I query them individually (sensor.supports(..)) it returns false (not supported). Actually trying to retrieve the value fails with an exception (not supported option).

We need this feature as well to monitor temperatures during operation. I will try the debug protocol in the meantime but this should really get fixed.

Just tested with FW 05.11.11.100, same issue.

andre-ryll avatar Sep 03 '19 11:09 andre-ryll

@andre-ryll I confirm I still see this bug. Any luck with your debug ?

The workaround we found is just to detect when the temperature report drops to zero (connection lost) than we just restart the USB connection with the Realsense.

marinerain avatar Sep 12 '19 22:09 marinerain

I am just using the debug protocol snippet @dorodnic posted above to read the projector temperature now. I am still hoping for librealsense team to fix the issue with reading the option values.

andre-ryll avatar Sep 18 '19 13:09 andre-ryll