IntelRealSense / librealsense

Intel® RealSense™ SDK
https://www.intelrealsense.com/
Apache License 2.0
7.53k stars 4.81k forks source link

Read device temperature #866

Closed Panepo closed 5 years ago

Panepo commented 6 years ago
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

dorodnic commented 6 years ago

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.

rafaelspring commented 6 years ago

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.

dorodnic commented 6 years ago

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 commented 6 years ago

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
RealSense-Customer-Engineering commented 6 years ago

[Realsense Customer Engineering Team Comment] Hi @xtrawurst,

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

Regards

rafaelspring commented 6 years ago

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

RealSense-Customer-Engineering commented 6 years ago

[Realsense Customer Engineering Team Comment] hi @xtrawurst,

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

marinerain commented 6 years ago

@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
dorodnic commented 6 years ago

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.

rupak-d commented 5 years ago

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

Thank you.

RealSense-Customer-Engineering commented 5 years ago

[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?

dorodnic commented 5 years ago

Still under investigation at firmware level

RealSense-Customer-Engineering commented 5 years ago

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

marinerain commented 5 years ago

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 < notifications@github.com> 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/

RealSense-Customer-Engineering commented 5 years ago

[Realsense Customer Engineering Team Comment] Hello @marinerain,

any test update?

dorodnic commented 5 years ago

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

Kaju-Bubanja commented 5 years ago

This issue still persists in the newest firmware 05.11.06.250

andre-ryll commented 5 years ago

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.

marinerain commented 5 years ago

@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.

andre-ryll commented 5 years ago

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.

nawara72 commented 4 years ago

Hi Any updates on the temperature fix

jrecasens commented 1 year ago

Hello,

Has this issue been resolved?

Im using a realsense D457 (HW Firmware: 5.15.0.2 and pyrealsense2 : 2.54.1.5217) and I cant read asic_temperature or projector_temperature.

sensor.supports(rs.option.asic_temperature)
sensor.supports(rs.option.projector_temperature)

All return False

diplodocuslongus commented 1 year ago

@jrecasens are you streaming frames when you read the temperature? If not you will not get anything. Try the code from @Panepo at the very top. I can read both projector and asic temperature with his code on a D455 (which, if I'm correct, has the same internal HW as the D457).

jrecasens commented 1 year ago

Thanks, it works when the devices are enabled and streaming!