102 #ifndef _LAE_VL6180_H 103 #define _LAE_VL6180_H 105 #include <inttypes.h> 112 #include "rnr/rnrconfig.h" 124 #define VL6180X_ADDR 0x29 129 #define VL6180X_IR_LAMBDA 8.5e-07 130 #define VL6180X_RANGE_MIN 0.0
131 #define VL6180X_RANGE_MAX 0.2
132 #define VL6180X_RANGE_FOV 40.0
133 #define VL6180X_RANGE_NO_OBJ 1000000.0
136 #define VL6180X_RANGE_OFFSET_MIN -128 137 #define VL6180X_RANGE_OFFSET_MAX 127
140 #define VL6180X_RANGE_XTALK_MIN 0 141 #define VL6180X_RANGE_XTALK_MAX 0xffff
146 #define VL6180X_AMBIENT_RES 0xffff 147 #define VL6180X_AMBIENT_MIN 0.0
148 #define VL6180X_AMBIENT_MAX 1000000.0
151 #define VL6180X_AMBIENT_GAIN_MIN 1.0 152 #define VL6180X_AMBIENT_GAIN_MAX 40.0
153 #define VL6180X_AMBIENT_GAIN_MASK 0x07
156 #define VL6180X_AMBIENT_INT_T_MIN 1 157 #define VL6180X_AMBIENT_INT_T_MAX 512
158 #define VL6180X_AMBIENT_INT_T_REC 100
159 #define VL6180X_AMBIENT_INT_T_MASK 0x1ff
164 #define VL6180X_ERR_MEAS -1.0 169 #define VL6180X_T_AUTO 0xffff 170 #define VL6180X_FACTORY_DFT -100000
175 #define VL6180x_FAILURE_RESET -1 177 #define VL6180X_IDENTIFICATION_MODEL_ID 0x0000 178 #define VL6180X_IDENTIFICATION_MODEL_REV_MAJOR 0x0001 179 #define VL6180X_IDENTIFICATION_MODEL_REV_MINOR 0x0002 180 #define VL6180X_IDENTIFICATION_MODULE_REV_MAJOR 0x0003 181 #define VL6180X_IDENTIFICATION_MODULE_REV_MINOR 0x0004 182 #define VL6180X_IDENTIFICATION_DATE 0x0006 //16bit value 183 #define VL6180X_IDENTIFICATION_TIME 0x0008 //16bit value 185 #define VL6180X_SYSTEM_MODE_GPIO0 0x0010 186 #define VL6180X_SYSTEM_MODE_GPIO1 0x0011 187 #define VL6180X_SYSTEM_HISTORY_CTRL 0x0012 188 #define VL6180X_SYSTEM_INTERRUPT_CONFIG_GPIO 0x0014 189 #define VL6180X_SYSTEM_INTERRUPT_CLEAR 0x0015 190 #define VL6180X_SYSTEM_FRESH_OUT_OF_RESET 0x0016 191 #define VL6180X_SYSTEM_GROUPED_PARAMETER_HOLD 0x0017 193 #define VL6180X_SYSRANGE_START 0x0018 194 #define VL6180X_SYSRANGE_THRESH_HIGH 0x0019 195 #define VL6180X_SYSRANGE_THRESH_LOW 0x001A 196 #define VL6180X_SYSRANGE_INTERMEASUREMENT_PERIOD 0x001B 197 #define VL6180X_SYSRANGE_MAX_CONVERGENCE_TIME 0x001C 198 #define VL6180X_SYSRANGE_CROSSTALK_COMPENSATION_RATE 0x001E 199 #define VL6180X_SYSRANGE_CROSSTALK_VALID_HEIGHT 0x0021 200 #define VL6180X_SYSRANGE_EARLY_CONVERGENCE_ESTIMATE 0x0022 201 #define VL6180X_SYSRANGE_PART_TO_PART_RANGE_OFFSET 0x0024 202 #define VL6180X_SYSRANGE_RANGE_IGNORE_VALID_HEIGHT 0x0025 203 #define VL6180X_SYSRANGE_RANGE_IGNORE_THRESHOLD 0x0026 204 #define VL6180X_SYSRANGE_MAX_AMBIENT_LEVEL_MULT 0x002C 205 #define VL6180X_SYSRANGE_RANGE_CHECK_ENABLES 0x002D 206 #define VL6180X_SYSRANGE_VHV_RECALIBRATE 0x002E 207 #define VL6180X_SYSRANGE_VHV_REPEAT_RATE 0x0031 209 #define VL6180X_SYSALS_START 0x0038 210 #define VL6180X_SYSALS_THRESH_HIGH 0x003A 211 #define VL6180X_SYSALS_THRESH_LOW 0x003C 212 #define VL6180X_SYSALS_INTERMEASUREMENT_PERIOD 0x003E 213 #define VL6180X_SYSALS_ANALOGUE_GAIN 0x003F 214 #define VL6180X_SYSALS_INTEGRATION_PERIOD 0x0040 216 #define VL6180X_RESULT_RANGE_STATUS 0x004D 217 #define VL6180X_RESULT_ALS_STATUS 0x004E 218 #define VL6180X_RESULT_INTERRUPT_STATUS_GPIO 0x004F 219 #define VL6180X_RESULT_ALS_VAL 0x0050 220 #define VL6180X_RESULT_HISTORY_BUFFER 0x0052 221 #define VL6180X_RESULT_RANGE_VAL 0x0062 222 #define VL6180X_RESULT_RANGE_RAW 0x0064 223 #define VL6180X_RESULT_RANGE_RETURN_RATE 0x0066 224 #define VL6180X_RESULT_RANGE_REFERENCE_RATE 0x0068 225 #define VL6180X_RESULT_RANGE_RETURN_SIGNAL_COUNT 0x006C 226 #define VL6180X_RESULT_RANGE_REFERENCE_SIGNAL_COUNT 0x0070 227 #define VL6180X_RESULT_RANGE_RETURN_AMB_COUNT 0x0074 228 #define VL6180X_RESULT_RANGE_REFERENCE_AMB_COUNT 0x0078 229 #define VL6180X_RESULT_RANGE_RETURN_CONV_TIME 0x007C 230 #define VL6180X_RESULT_RANGE_REFERENCE_CONV_TIME 0x0080 232 #define VL6180X_READOUT_AVERAGING_SAMPLE_PERIOD 0x010A 233 #define VL6180X_FIRMWARE_BOOTUP 0x0119 234 #define VL6180X_FIRMWARE_RESULT_SCALER 0x0120 235 #define VL6180X_I2C_SLAVE_DEVICE_ADDRESS 0x0212 236 #define VL6180X_INTERLEAVED_MODE_ENABLE 0x02A3 263 uint8_t idModelRevMajor;
264 uint8_t idModelRevMinor;
265 uint8_t idModuleRevMajor;
266 uint8_t idModuleRevMinor;
308 const std::string &strDesc);
344 void getProps(
int &nIndex,
346 std::string &strRadiationType,
352 std::string &strDesc);
376 static const int NSenseErrorsThreshold = 10;
392 const std::string &strNameId=
"VL6180",
393 const std::string &strDesc=
"Time-of-Flight range sensor");
417 int initSensor(
bool bForce =
false);
432 void readShadowRegs();
443 void readShadowRegs(byte_t ®RangeOffset,
444 u16_t ®RangeCrossTalk,
446 u16_t ®AlsIntPeriod);
460 int tune(uint_t uRangeOffset, uint_t uRangeCrossTalk,
461 double fAlsGain, uint_t uAlsIntPeriod);
517 fAmbientLight = m_fAmbientLight;
600 int calibOffset(
int &nOffsetPre,
618 int calibCrossTalk(
int &nCrossTalk);
628 int readReg8(u16_t reg, byte_t &val);
638 int readReg16(u16_t reg, u16_t &val);
648 int writeReg8(u16_t reg, byte_t val);
658 int writeReg16(u16_t reg, u16_t val);
720 pthread_mutex_lock(&m_mutex);
731 pthread_mutex_unlock(&m_mutex);
741 int outOfResetInit();
754 u32_t waitForSensorReady(u16_t regStatus, u32_t msecWait);
767 u32_t waitForSensorMeasurement(u32_t msecWait, byte_t bitDone);
881 virtual int getRange(
const std::string &strKey,
double &fRange)
895 virtual int getRange(std::vector<std::string> &vecNames,
896 std::vector<double> &vecRanges)
925 std::vector<double> &vecAmbient)
943 std::string &strRadiationType,
979 uint_t &uRangeOffset,
980 uint_t &uRangeCrossTalk,
982 uint_t &uAlsIntPeriod)
1008 static const int AlsFreq = 4;
1036 virtual int getInterfaceVersion(uint_t &uVerMajor,
1043 virtual void clearSensedData();
1078 virtual void exec();
1090 virtual int getRange(
const std::string &strKey,
double &fRange);
1103 virtual int getRange(std::vector<std::string> &vecNames,
1104 std::vector<double> &vecRanges);
1116 virtual int getAmbientLight(
const std::string &strKey,
double &fAmbient);
1129 virtual int getAmbientLight(std::vector<std::string> &vecNames,
1130 std::vector<double> &vecAmbient);
1144 virtual int getSensorProps(
const std::string &strKey,
1145 std::string &strRadiationType,
1159 virtual int readSensorIdentity(
const std::string &strKey,
1174 virtual int readSensorTunes(
const std::string &strKey,
1175 uint_t &uRangeOffset,
1176 uint_t &uRangeCrossTalk,
1178 uint_t &uAlsIntPeriod);
1193 int keyIndex(
const std::string &strKey);
1250 virtual int getInterfaceVersion(uint_t &uVerMajor,
1257 virtual void clearSensedData();
1292 virtual void exec();
1301 virtual int getRange(
const std::string &strKey,
double &fRange);
1312 virtual int getRange(std::vector<std::string> &vecNames,
1313 std::vector<double> &vecRanges);
1323 virtual int getAmbientLight(
const std::string &strKey,
double &fAmbient);
1334 virtual int getAmbientLight(std::vector<std::string> &vecNames,
1335 std::vector<double> &vecAmbient);
1349 virtual int getSensorProps(
const std::string &strKey,
1350 std::string &strRadiationType,
1363 virtual int readSensorIdentity(
const std::string &strKey,
1378 virtual int readSensorTunes(
const std::string &strKey,
1379 uint_t &uRangeOffset,
1380 uint_t &uRangeCrossTalk,
1382 uint_t &uAlsIntPeriod);
1410 pthread_mutex_lock(&m_mutex);
1421 pthread_mutex_unlock(&m_mutex);
1436 virtual int cmdGetFwVersion(uint_t &uVerNum);
1458 int cmdGetTunes(
const std::string &strKey,
1459 uint_t &uRangeOffset,
1460 uint_t &uRangeCrossTalk,
1462 uint_t &uAlsIntPeriod);
1471 int cmdGetRanges(std::vector<double> &vecRanges);
1480 int cmdGetAmbientLight(std::vector<double> &vecLux);
1492 int cmdTuneToFSensor(
const std::string &strKey,
1493 uint_t uRangeOffset,
1494 uint_t uRangeCrossTalk);
1504 int cmdTuneAls(
const std::string &strKey,
1506 uint_t uAlsIntPeriod);
1521 int cmdGetAmbientLight();
1553 virtual void blacklist();
1558 virtual void whitelist();
1567 return m_bBlackListed;
1575 int setInterface(uint_t uProdHwVer);
1580 void clearSensedData();
1591 virtual int getInterfaceVersion(uint_t &uVerMajor,
1634 virtual int getSensorProps(
const std::string &strKey,
1635 std::string &strRadiationType,
1649 virtual int readSensorIdentity(
const std::string &strKey,
1664 virtual int readSensorTunes(
const std::string &strKey,
1665 uint_t &uRangeOffset,
1666 uint_t &uRangeCrossTalk,
1668 uint_t &uAlsIntPeriod);
1680 virtual int getRange(
const std::string &strKey,
double &fRange);
1693 virtual int getRange(std::vector<std::string> &vecNames,
1694 std::vector<double> &vecRanges);
1706 virtual int getAmbientLight(
const std::string &strKey,
double &fAmbient);
1719 virtual int getAmbientLight(std::vector<std::string> &vecNames,
1720 std::vector<double> &vecAmbient);
1728 virtual void exec();
1741 #endif // _LAE_VL6180_H uint_t m_uAlsIntPeriod
ALS integration period (msec)
pthread_mutex_t m_mutex
mutex
#define VL6180X_RANGE_MAX
maximum range (m)
Multiplexed range sensors class.
virtual int configure(const laelaps::LaeTunes &tunes)
Configure sensor array from tuning parameters.
void lock()
Lock the share resource.
vl6180x_als_gain
Ambient Light Sensor gain value enumeration.
virtual void exec()
Execute task in one cycle to take measurements.
Laelaps tuning data class.
std::string getRadiationType()
Get radiation type.
virtual ~LaeRangeInterface()
Destructor.
number of gain enum values
virtual int getInterfaceVersion(uint_t &uVerMajor, uint_t &uVerMinor, uint_t &uFwVer)
Get interface version.
Laelaps robotic mobile platform full description class.
void getMinMax(double &fMin, double &fMax)
Get sensor's minimum and maximum range.
LaeRangeInterface * m_interface
the interface
double degToRad(double d)
Convert degrees to radians.
static long TStd
standard wait time between write_read (usec)
int m_nAlsCounter
when zero, make measurement
u16_t m_regAlsIntPeriod
ALS itegration period register.
virtual int readSensorIdentity(const std::string &strKey, VL6180xIdentification &ident)
Read sensor's identification.
laelaps::LaeI2CMux & m_mux
I2C multiplexor.
int m_nAlsIndex
ambient light sensor index
double m_fAmbientLight
ambient light (lux)
laelaps::LaeI2C & m_i2cBus
bound I2C bus instance
void getMeasurements(double &fRange, double &fAmbientLight)
Get last sensed measurements.
double m_fDeadzone
sensor deadzone (m)
virtual int getSensorProps(const std::string &strKey, std::string &strRadiationType, double &fFoV, double &fBeamDir, double &fMin, double &fMax)
Get range sensor properties.
std::string m_strNameId
name identifier of sensor
Container class to hold VL6180 time-of-flight sensor static information.
Laelaps PCA9548A I2C multiplexer switch interface.
double getBeamDir()
Get sensor direction of the center of emitter IR beam.
int m_nChan
multiplexed channel number
VL6180 Time of Flight Class.
virtual int reload(const laelaps::LaeTunes &tunes)
Reload configuration tuning parameters.
byte_t m_regAlsGain
ambient light sensor gain register
std::vector< double > m_vecRanges
measured distances (meters)
pthread_mutex_t m_mutex
mutex
int m_nErrorCnt
consecutive error count
void unlock()
Unlock the shared resource.
double m_fBeamDir
center of beam direction(radians)
std::string m_strDesc
short description
Range sensors interface base class.
std::map< std::string, LaeVL6180SensorInfo > SensorInfoMap
Sensor information map type.
Laelaps robotic base mobile platform description class interface.
VecToFSensors m_vecToF
time of flight sensors
std::string getDesc()
Get sensor short description.
Laelaps common utilities.
std::string getNameId()
Get sensor assigned name id.
virtual void clearSensedData()
Clear sensed data.
#define VL6180X_T_AUTO
auto-determine wait time
void lock()
Lock the share resource.
void unlock()
Unlock the shared resource.
Laelaps built-in Time-of-Flight Multiplexer Arduino sub-processor interface.
double m_fBeamDir
center of beam direction(radians)
double m_fDeadzone
sensor deadzone (m)
int m_nChan
multiplexed channel number
static const int LAE_ECODE_NO_RSRC
no resource available error
LaeRangeInterface(laelaps::LaeI2C &i2cBus)
Initialization constructor.
double m_fAlsGain
ambient light sensor analog gain
uint_t m_uFwVer
firmware version number
bool m_bBlackListed
sensor group [not] black listed.
double getFoV()
Get sensor field of view.
bool m_bBlackListed
sensor is [not] black listed
virtual int readSensorTunes(const std::string &strKey, uint_t &uRangeOffset, uint_t &uRangeCrossTalk, double &fAlsGain, uint_t &uAlsIntPeriod)
Read sensor's current tuning parameters.
virtual int configure(const laelaps::LaeDesc &desc)
Configure sensor array from product description.
const byte_t LaeI2CAddrToFMux
arduino I2C 7-bit slave address
std::vector< sensor::vl6180::LaeVL6180Mux * > VecToFSensors
time-of-flight sensor vector type
laelaps::LaeI2CMux m_mux
I2C multiplexor.
u16_t m_regRangeCrossTalk
range cross-talk register
virtual bool isBlackListed()
Test if range sensor group is black listed.
SensorInfoMap m_mapInfo
map of sensor properties by key
virtual int getRange(const std::string &strKey, double &fRange)
Get a range measurement.
laelaps::LaeI2C & m_i2cBus
bound I2C bus instance
uint_t m_addrSubProc
I2C sub-processor address.
#define VL6180X_RANGE_MIN
minimum range (m)
virtual int getRange(std::vector< std::string > &vecNames, std::vector< double > &vecRanges)
Get all sensor range measurements.
std::vector< double > m_vecLux
measured ambient light (lux)
virtual int getAmbientLight(const std::string &strKey, double &fAmbient)
Get an ambient light illuminance measurement.
virtual int getAmbientLight(std::vector< std::string > &vecNames, std::vector< double > &vecAmbient)
Get all sensor ambient light illuminance measurements.
#define VL6180X_RANGE_FOV
field of view (degrees)
std::string m_strDesc
short description
Range sensor group class.
VL6180 Time of Flight Array Class.
byte_t m_regRangeOffset
range part-to-part offset register
Top-level package include file.