# Confusion/issues related to voxl-camera-server...

Source: https://forum.modalai.com/topic/1489/confusion-issues-related-to-voxl-camera-server
Category: Flight Core and Legacy VOXL (https://forum.modalai.com/category/9/flight-core-and-legacy-voxl)
Tags: flight-deck
Posted: 2022-10-27 19:40:31 UTC by Ed Sutter
Replies: 5 · Views: 1730

## Ed Sutter · 2022-10-27 19:40:31 UTC

I need to be able to change gain/exposure settings for the hires camera.  Referring to [the voxl-camera-server page](https://docs.modalai.com/voxl-camera-server/#exposure) I ran **voxl-send-command hires set_exp_gain 200 150**.  The response comes back as if successful (which really only indicates that it was successfully sent), but when I look at the output of the voxl-camera-server service  using **journalctl -u voxl-camera-server** it says: 
```
Invalid Control Pipe Exposure: 200.000000,
Should be between 0.020000 and 0.000000
```  
So I rerun the command to use a setting within those limits (**voxl-send-command hires set_exp_gain .015 150**), but I still get the same error.

Digging into this a bit more, I click on the link for the voxl-camera-server source code and it is redirected to apq8096-camera-server under voxl-sdk/services.  

I see from [this post](https://forum.modalai.com/topic/1287/voxl-send-command-not-working-to-manually-set-exposure-gain-on-hires-on-flight-deck) that this voxl-camera-server code is/was recently changing.  What code should I be looking at to understand what the problem is here?

## Reply by Ed Sutter · 2022-10-27 19:52:19 UTC

I now see that the code under [voxl-camera-server](https://gitlab.com/voxl-public/voxl-sdk/services/voxl-camera-server) has the error message "Invalid Control Pipe Exposure:..." commented out, so I must be running (and should be looking at) [apq8096-camera-server](https://gitlab.com/voxl-public/voxl-sdk/services/apq8096-camera-server) code.  If I rebuild and install on my flight deck, I'll assume that I should just change the name to voxl-camera-server.
Please clarify!

## Reply by Ed Sutter · 2022-10-27 23:42:02 UTC (in reply to Ed Sutter)

Looking at the file [hal3_camera_mgr.cpp](https://gitlab.com/voxl-public/voxl-sdk/services/apq8096-camera-server/-/blob/master/src/api_interface/hal3/hal3_camera_mgr.cpp), I believe line 56...
```
#define MAX_EXP 33
```
should be changed to
```
#define MAX_EXP 33.0
```
That will at least fix the error message.

## Reply by Ed Sutter · 2022-10-28 01:09:02 UTC (in reply to Ed Sutter)

@Alex-Gardner one other thing that may improve efficiency in [hal3_camera_mgr.cpp](https://gitlab.com/voxl-public/voxl-sdk/services/apq8096-camera-server/-/blob/master/src/api_interface/hal3/hal3_camera_mgr.cpp)...

It appears that the code around 694-702...
```
            m_currentExposure = m_nextExposure;
            m_currentGain     = m_nextGain;
            m_nextExposure    = -1;
            m_nextGain        = -1;

            uint8_t aeMode = 0; // Auto exposure is off i.e. the underlying driver does not control exposure/gain
            m_requestMetadata.update(ANDROID_CONTROL_AE_MODE, &aeMode, 1);
            m_requestMetadata.update(ANDROID_SENSOR_EXPOSURE_TIME, &(m_currentExposure), 1);
            m_requestMetadata.update(ANDROID_SENSOR_SENSITIVITY, &(m_currentGain), 1);

```
 is called even when there's no change to exposure and gain.  Those lines could probably be wrapped with a test for the change...

```
            if ((m_currentExposure  != m_nextExposure) || (m_currentGain  != m_nextGain)) 
            {
            m_currentExposure = m_nextExposure;
            m_currentGain     = m_nextGain;
            m_nextExposure    = -1;
            m_nextGain        = -1;

            uint8_t aeMode = 0; // Auto exposure is off i.e. the underlying driver does not control exposure/gain
            m_requestMetadata.update(ANDROID_CONTROL_AE_MODE, &aeMode, 1);
            m_requestMetadata.update(ANDROID_SENSOR_EXPOSURE_TIME, &(m_currentExposure), 1);
            m_requestMetadata.update(ANDROID_SENSOR_SENSITIVITY, &(m_currentGain), 1);
            }
```

## Reply by Guest · 2022-10-28 16:41:44 UTC

Hi,

Thanks for digging into this a bit, in short: camera server went through a major overhaul to make it much cleaner and more robust when we released our qrb5165-based platforms. The release that we're currently testing and plan to release soon for all platforms has this updated camera server backported to voxl1(apq8096) as well.

This rewrite was mostly cleaning up 3-4 year old code while maintaining the same behavior, but there were a few proper improvements, including redoing the state machine for the AE stuff. There's a known bug in the old camera server where the set commands will not work if the selected AE algorithm in the config file is to use the ISP's (default for the hires cam) since the module will ignore those set values. Additionally, in the new camera server we've included proper values for min/max exp/gain for each different sensor, not just the generic definitions of the old one. 

At this point we're not planning to make any additions to the apq-specific camera server since all the known issues have been ironed out of the cross-platform one and it'll take longer to test and release backports of the old camera server than it will for us to finish pushing out a full release for APQ with the new camera server (we're targeting the next week and a half or so).

## Reply by Ed Sutter · 2022-10-28 19:14:45 UTC (in reply to Guest)

@Alex-Gardner Will we be notified when the new version is available?
