Time-of-Flight-SDK
depth_sensor_interface.h
1 /*
2  * BSD 3-Clause License
3  *
4  * Copyright (c) 2019, Analog Devices, Inc.
5  * All rights reserved.
6  *
7  * Redistribution and use in source and binary forms, with or without
8  * modification, are permitted provided that the following conditions are met:
9  *
10  * 1. Redistributions of source code must retain the above copyright notice, this
11  * list of conditions and the following disclaimer.
12  *
13  * 2. Redistributions in binary form must reproduce the above copyright notice,
14  * this list of conditions and the following disclaimer in the documentation
15  * and/or other materials provided with the distribution.
16  *
17  * 3. Neither the name of the copyright holder nor the names of its
18  * contributors may be used to endorse or promote products derived from
19  * this software without specific prior written permission.
20  *
21  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
22  * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
23  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
24  * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
25  * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
26  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
27  * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
28  * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
29  * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
30  * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
31  */
32 #ifndef DEPTH_SENSOR_INTERFACE_H
33 #define DEPTH_SENSOR_INTERFACE_H
34 
35 #include <aditof/frame_definitions.h>
36 #include <aditof/sensor_definitions.h>
37 #include <aditof/status_definitions.h>
38 
39 #include <cstddef>
40 #include <functional>
41 #include <map>
42 #include <string>
43 #include <vector>
44 
45 namespace aditof {
46 
50 typedef std::function<void(Adsd3500Status)> SensorInterruptCallback;
51 
58  public:
62  virtual ~DepthSensorInterface() = default;
63 
68  virtual aditof::Status open() = 0;
69 
74  virtual aditof::Status start() = 0;
75 
80  virtual aditof::Status stop() = 0;
81 
88  std::vector<aditof::DepthSensorFrameType> &types) = 0;
89 
95  virtual aditof::Status
97 
104  virtual aditof::Status program(const uint8_t *firmware, size_t size) = 0;
105 
113  virtual aditof::Status getFrame(uint16_t *buffer) = 0;
114 
126  virtual aditof::Status readRegisters(const uint16_t *address,
127  uint16_t *data, size_t length,
128  bool burst = true) = 0;
129 
140  virtual aditof::Status writeRegisters(const uint16_t *address,
141  const uint16_t *data, size_t length,
142  bool burst = true) = 0;
143 
152  virtual aditof::Status adsd3500_read_cmd(uint16_t cmd, uint16_t *data,
153  unsigned int usDelay = 0) = 0;
154 
161  virtual aditof::Status adsd3500_write_cmd(uint16_t cmd, uint16_t data) = 0;
162 
171  virtual aditof::Status adsd3500_read_payload_cmd(uint32_t cmd,
172  uint8_t *readback_data,
173  uint16_t payload_len) = 0;
174 
182  virtual aditof::Status adsd3500_read_payload(uint8_t *payload,
183  uint16_t payload_len) = 0;
184 
193  virtual aditof::Status adsd3500_write_payload_cmd(uint32_t cmd,
194  uint8_t *payload,
195  uint16_t payload_len) = 0;
196 
204  virtual aditof::Status adsd3500_write_payload(uint8_t *payload,
205  uint16_t payload_len) = 0;
206 
211  virtual aditof::Status adsd3500_reset() = 0;
212 
218  virtual aditof::Status
220 
226  virtual aditof::Status
228 
235  virtual aditof::Status adsd3500_get_status(int &chipStatus,
236  int &imagerStatus) = 0;
237 
243  virtual Status
244  getAvailableControls(std::vector<std::string> &controls) const = 0;
245 
252  virtual Status setControl(const std::string &control,
253  const std::string &value) = 0;
254 
261  virtual Status getControl(const std::string &control,
262  std::string &value) const = 0;
263 
271  virtual aditof::Status getDetails(aditof::SensorDetails &details) const = 0;
272 
280  virtual aditof::Status getHandle(void **handle) = 0;
281 
287  virtual aditof::Status getName(std::string &name) const = 0;
288 
294  virtual aditof::Status
295  setHostConnectionType(std::string &connectionType) = 0;
296 
305  virtual aditof::Status initTargetDepthCompute(uint8_t *iniFile,
306  uint16_t iniFileLength,
307  uint8_t *calData,
308  uint16_t calDataLength) = 0;
309 
315  virtual aditof::Status
316  getIniParams(std::map<std::string, float> &params) = 0;
317 
323  virtual aditof::Status
324  setIniParams(const std::map<std::string, float> &params) = 0;
325 };
326 
327 } // namespace aditof
328 
329 #endif // DEPTH_SENSOR_INTERFACE_H
virtual aditof::Status adsd3500_reset()=0
Reset adsd3500 chip.
virtual aditof::Status writeRegisters(const uint16_t *address, const uint16_t *data, size_t length, bool burst=true)=0
Write to multiple AFE registers.
Namespace aditof.
Definition: frame.h:44
virtual aditof::Status adsd3500_read_cmd(uint16_t cmd, uint16_t *data, unsigned int usDelay=0)=0
Send a read command to adsd3500.
virtual ~DepthSensorInterface()=default
Destructor.
virtual aditof::Status stop()=0
Stop the sensor data stream.
virtual aditof::Status adsd3500_read_payload(uint8_t *payload, uint16_t payload_len)=0
Reads a chunk of data from adsd3500. This will perform a burst read making it useful for reading chun...
virtual aditof::Status getName(std::string &name) const =0
Get the name of the sensor.
virtual aditof::Status adsd3500_write_payload_cmd(uint32_t cmd, uint8_t *payload, uint16_t payload_len)=0
Send a write command to adsd3500. This will perform a burst write making it useful for writing chunks...
Adsd3500Status
Status of the ADSD3500 sensor.
virtual aditof::Status adsd3500_write_cmd(uint16_t cmd, uint16_t data)=0
Send a write command to adsd3500.
virtual aditof::Status start()=0
Start the streaming of data from the sensor.
virtual aditof::Status getHandle(void **handle)=0
Gets a handle to be used by other devices such as Storage, Temperature, etc. This handle will allow t...
virtual aditof::Status initTargetDepthCompute(uint8_t *iniFile, uint16_t iniFileLength, uint8_t *calData, uint16_t calDataLength)=0
Get the name of the sensor.
Provides details about the device.
virtual aditof::Status getIniParams(std::map< std::string, float > &params)=0
Get ini parameters for Depth Compute library.
virtual aditof::Status adsd3500_unregister_interrupt_callback(SensorInterruptCallback &cb)=0
Unregister a function registered with adsd3500_register_interrupt_callback.
Provides access to the low level functionality of the camera sensor. This includes sensor configurati...
virtual aditof::Status adsd3500_get_status(int &chipStatus, int &imagerStatus)=0
Returns the chip status.
virtual aditof::Status setHostConnectionType(std::string &connectionType)=0
Set the host connection type for target sdk.
virtual aditof::Status getFrame(uint16_t *buffer)=0
Request a frame from the sensor.
virtual aditof::Status getDetails(aditof::SensorDetails &details) const =0
Get a structure that contains information about the instance of the sensor.
virtual aditof::Status setFrameType(const aditof::DepthSensorFrameType &type)=0
Set the sensor frame type to the given type.
Describes the type of entire frame that a depth sensor can capture and transmit.
virtual Status setControl(const std::string &control, const std::string &value)=0
Sets a specific sensor control.
virtual aditof::Status setIniParams(const std::map< std::string, float > &params)=0
Set ini parameters for Depth Compute library.
virtual aditof::Status adsd3500_read_payload_cmd(uint32_t cmd, uint8_t *readback_data, uint16_t payload_len)=0
Send a read command to adsd3500. This will perform a burst read making it useful for reading chunks o...
virtual aditof::Status program(const uint8_t *firmware, size_t size)=0
Program the sensor with the given firmware.
Status
Status of any operation that the TOF sdk performs.
virtual aditof::Status adsd3500_write_payload(uint8_t *payload, uint16_t payload_len)=0
Send a chunk of data (payload) to adsd3500. This will perform a burst write making it useful for writ...
virtual Status getAvailableControls(std::vector< std::string > &controls) const =0
Gets the sensors's list of controls.
virtual aditof::Status readRegisters(const uint16_t *address, uint16_t *data, size_t length, bool burst=true)=0
Read multiple registers from AFE.
std::function< void(Adsd3500Status)> SensorInterruptCallback
Callback for sensor interrupts.
virtual aditof::Status adsd3500_register_interrupt_callback(SensorInterruptCallback &cb)=0
Register a function to be called when a ADSD3500 interrupt occurs.
virtual Status getControl(const std::string &control, std::string &value) const =0
Gets the value of a specific sensor control.
virtual aditof::Status open()=0
Open the communication channels with the hardware.
virtual aditof::Status getAvailableFrameTypes(std::vector< aditof::DepthSensorFrameType > &types)=0
Return all frame types that are supported by the sensor.