How to check the status of the sensor through the SDK

Hello,

I wonder how to check the status of the Astro sensor through the SDK (I mean, just simply check if there is an available sensor). I tried the initialize function and checked the stream status and they are always valid even no sensor is connected.

Thanks in advance!

Guohui

Hi Guohui,

At the moment, there is no way to tell whether a sensor is connected. We are planning a device discovery API but it is not in the SDK yet.

To give you some background on the is_valid() methods:

The is_valid() methods primarily indicate whether a class was constructed in a valid way. Another way to put it, if the class could potentially deliver data in the future, it is valid. One of the design decisions we chose for the Astra API is that the developer should not be required to be aware of or manage the state of the sensor hardware. (We were unhappy with the bookkeeping required by certain other SDKs.) An app should be able to just run, and whenever the hardware is ready (or if it is interrupted and returns) that is mostly transparent. No need to re-create new streamreaders or streamsets. In most cases, checking is_valid() on a frame is all that is necessary.

We have a little more work to do to improve this (partially complete in the develop branch on github), but is_valid() is also useful if one has a stream_reader as a class field, but it isn’t initialized (from streamSet.create_reader()) in the class constructor. In that case, the stream_reader would use the default constructor and would be is_valid()==false until it is created from a valid streamSet. The same goes for stream_set and a few other classes. When this is all done, it will be unnecessary to use unique_ptr for wrapping stream_reader, stream_set, etc. in classes.

1 Like