Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

rs_error was raised when calling rs2_get_option "failed to set power state" #13093

Open
garretthilyer opened this issue Jun 26, 2024 · 2 comments

Comments

@garretthilyer
Copy link

  • Before opening a new issue, we wanted to provide you with some useful suggestions (Click "Preview" above for a better view):

  • All users are welcomed to report bugs, ask questions, suggest or request enhancements and generally feel free to open new issue, even if they haven't followed any of the suggestions above :)


Required Info
Camera Model { D455 }
Firmware Version (Open RealSense Viewer -->2.55)
Operating System & Version Ubuntu 24.04, Arm64
Kernel Version (Linux Only) 6.8.0-1005-raspi
Platform Raspberry Pi 4
SDK Version { legacy / 2.. }
Language {C}
Segment {others}

Issue Description

I used this code to build realsense.
My code was working completely fine, I could capture frames for long periods of time.
I started messing around with sensors and trying to adjust exposure, contrast, white balance, etc.

Everytime I would use either:
rs2_get_option(sensor, RS2_OPTION_CONTRAST, &e) or rs2_set_option(sensor, RS2_OPTION_CONTRAST, 50.0, &e)

I would get this error:
rs_error was raised when calling rs2_get_option(options:0xaaaada8ea640, option_id:2): failed to set power state

I tried all the different types of options and the option_id tag would update depending on the parameter I wanted to change. Assume I am setting up the ctx, config, pipeline, device correctly...

This is the code I added for the sensor setting:

// Request the entire list of sensors
    rs2_sensor_list* sensor_list = rs2_query_sensors(dev, &e);
    check_error(e);

    // Request access to the total number of sensors
    int num_sensor = rs2_get_sensors_count(sensor_list, &e);
    check_error(e);

    for (int i = 0; i < num_sensor; i++) {
        // iterate through all sensors
        rs2_sensor* sensor = rs2_create_sensor(sensor_list, i, &e);
        check_error(e);
        // until you find color sensor
        if (rs2_is_sensor_extendable_to(sensor, RS2_EXTENSION_COLOR_SENSOR, &e) && !e) {
            
            // get color params
            printf("exposure default: %f \n", rs2_get_option(sensor, RS2_OPTION_CONTRAST, &e));
            check_error(e);

            // potential set of other params here as well ....

        }
        // free sensor
        rs2_delete_sensor(sensor);
    }
    // free sensor list
    rs2_delete_sensor_list(sensor_list);

I tried increasing the USB power output, sleeping for a couple of seconds before I reach this code, and even capturing a couple of data frames before running this. None of that has worked.

I am open to all possible solutions. Thanks in advanced!

@garretthilyer
Copy link
Author

Solution!

I was trying to manipulate the sensors after I created the pipeline/enable_stream(). I moved the sensor setting code to directly below the device initialization and it worked completely fine.

@MartyG-RealSense
Copy link
Collaborator

Hi @garretthilyer It's excellent to hear that you achieved a solution. Thanks very much for the update!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants