DriveWorks SDK Reference
5.10.90 Release
For Test and Development only

Sensors.h
Go to the documentation of this file.
1
2//
3// Notice
4// ALL NVIDIA DESIGN SPECIFICATIONS AND CODE ("MATERIALS") ARE PROVIDED "AS IS" NVIDIA MAKES
5// NO REPRESENTATIONS, WARRANTIES, EXPRESSED, IMPLIED, STATUTORY, OR OTHERWISE WITH RESPECT TO
6// THE MATERIALS, AND EXPRESSLY DISCLAIMS ANY IMPLIED WARRANTIES OF NONINFRINGEMENT,
7// MERCHANTABILITY, OR FITNESS FOR A PARTICULAR PURPOSE.
8//
9// NVIDIA CORPORATION & AFFILIATES assumes no responsibility for the consequences of use of such
10// information or for any infringement of patents or other rights of third parties that may
11// result from its use. No license is granted by implication or otherwise under any patent
12// or patent rights of NVIDIA CORPORATION & AFFILIATES. No third party distribution is allowed unless
13// expressly authorized by NVIDIA. Details are subject to change without notice.
14// This code supersedes and replaces all information previously supplied.
15// NVIDIA CORPORATION & AFFILIATES products are not authorized for use as critical
16// components in life support devices or systems without express written approval of
17// NVIDIA CORPORATION & AFFILIATES.
18//
19// SPDX-FileCopyrightText: Copyright (c) 2016-2022 NVIDIA CORPORATION & AFFILIATES. All rights reserved.
20// SPDX-License-Identifier: LicenseRef-NvidiaProprietary
21//
22// NVIDIA CORPORATION, its affiliates and licensors retain all intellectual
23// property and proprietary rights in and to this material, related
24// documentation and any modifications thereto. Any use, reproduction,
25// disclosure or distribution of this material and related documentation
26// without an express license agreement from NVIDIA CORPORATION or
27// its affiliates is strictly prohibited.
28//
30
54#ifndef DW_SENSORS_SENSORS_H_
55#define DW_SENSORS_SENSORS_H_
56
58#include <dw/core/base/Types.h>
62
63#ifdef __cplusplus
64extern "C" {
65#endif
66
68typedef enum dwPlatformOS {
71
74
77
81
83typedef struct dwSALObject* dwSALHandle_t;
84
86typedef struct dwSensorObject* dwSensorHandle_t;
87
89#define DW_SENSOR_MAX_PROTOCOL_NAME_LENGTH 32
91#define DW_SENSOR_MAX_PARAMETER_STRING_LENGTH 512
92
94typedef struct dwSensorParams
95{
99 const char8_t* protocol;
100
106 const char8_t* parameters;
107
113 const void* auxiliarydata;
114
116
121
124
127
130
134
136typedef struct dwSensorStats
137{
139 uint64_t events;
140
142 uint64_t errors;
143
145 uint64_t drops;
146
150
154
158
162
166
170
174
178
182
187
189typedef enum dwSensorType {
211
214{
217
219 uint64_t event;
220
222 uint64_t offset;
223
225 uint64_t size;
226
228
230typedef struct dwSensorTsAndID
231{
233 uint64_t sensorId;
236 // Timestamp when the processed sensor data has been published by the sensor node in [us]
239
251
256{
257 struct
258 {
263
266
269
272
276
278#define DW_SENSOR_ERROR_ID_OFFSET_BIT 24U
280#define DW_SENSOR_ERROR_ID_OFFSET (1U << DW_SENSOR_ERROR_ID_OFFSET_BIT)
281
286typedef enum dwSensorErrorID {
292
305
317
331
349
366
380
393
406dwStatus dwSAL_getPlatformInfo(char8_t const** const osName, dwPlatformOS const os, dwSALHandle_t const sal);
407
423dwStatus dwSAL_getNumSensors(uint32_t* const num, dwPlatformOS const os, dwSALHandle_t const sal);
424
438dwStatus dwSAL_getSensorProtocol(const char** const name, uint32_t const idx, dwPlatformOS const os, dwSALHandle_t const sal);
439
455dwStatus dwSAL_getSensorParameterString(const char** const parameters, uint32_t const idx,
456 dwPlatformOS const os, dwSALHandle_t const sal);
457
471
493
506
519
542dwStatus dwSensor_readRawData(const uint8_t** const data, size_t* const size,
543 dwTime_t const timeoutUs,
544 dwSensorHandle_t const sensor);
545
560dwStatus dwSensor_returnRawData(const uint8_t* const data, dwSensorHandle_t const sensor);
561
578dwStatus dwSensor_getSeekRange(size_t* const eventCount,
579 dwTime_t* const startTimestampUs, dwTime_t* const endTimestampUs,
580 dwSensorHandle_t const sensor);
581
597
598/*
599 * Returns a pointer to the shared buffer with the contents of the sensor header and bufferSize
600 * will contain the number of valid bytes in the buffer.
601 *
602 * @param[out] - buffer A pointer to the buffer owned by sensor which holds the header information.
603 * @param[out] - bufferSize A pointer to variable indicating number of valid bytes in the buffer
604 * @param[in] - sensor Handle to the sensor to which the header info is requested
605 *
606 * @return DW_INVALID_HANDLE - if given sensor handle is invalid
607 * DW_INVALID_ARGUMENTS - if given arguments are invalid
608 * DW_SUCCESS - if call is successful.
609 */
610dwStatus dwSensor_getHeader(uint8_t const** const buffer, size_t* bufferSize, dwSensorHandle_t const sensor);
611
628dwStatus dwSensor_seekToTime(dwTime_t const timestampUs, dwSensorHandle_t const sensor);
629
645dwStatus dwSensor_seekToEvent(size_t const event, dwSensorHandle_t const sensor);
646
665
679
694dwStatus dwSensor_getSeekTableEntries(dwSensorSeekTableEntry* const entries, size_t const numEntries, dwSensorHandle_t const sensor);
695
719dwStatus dwSensor_saveSeekTable(const char* const fileName, dwSensorHandle_t const sensor);
720
741dwStatus dwSensor_setThreadPriority(int32_t const priority, dwSensorHandle_t const sensor);
742
763dwStatus dwSensor_setThreadAffinity(uint32_t const affinityMask, dwSensorHandle_t const sensor);
764
778
779#ifdef __cplusplus
780}
781#endif
782
784#endif // DW_SENSORS_SENSORS_H_
NVIDIA DriveWorks API: Core Methods
NVIDIA DriveWorks API: Health Signal Methods
DriveWorks API: Signal Status Library
NVIDIA DriveWorks API: Core Types
NVIDIA DriveWorks API: Core Exports
float float32_t
Specifies POD types.
Definition: BasicTypes.h:57
int64_t dwTime_t
Specifies a timestamp unit, in microseconds.
Definition: BasicTypes.h:63
double float64_t
Definition: BasicTypes.h:58
struct dwContextObject * dwContextHandle_t
Context handle.
Definition: Context.h:83
#define DW_API_PUBLIC
Definition: Exports.h:54
uint8_t dwSignalValidity
The type of the encoded status field.
Definition: SignalStatus.h:57
dwStatus
Status definition.
Definition: Status.h:173
dwTime_t timeDeltaMax
Maximum observed host timestamp difference between two consecutive packets.
Definition: Sensors.h:157
float64_t standardDeviationDelta[DW_SENSOR_STATE_SENSOR_STAT_COUNT]
Array of Variance of all the deltas between consecutive timestamps as per the dwSensorStatTimeDiffere...
Definition: Sensors.h:181
uint64_t event
counter of this event
Definition: Sensors.h:219
uint64_t offset
offset into a file of this event
Definition: Sensors.h:222
const void * auxiliarydata
Additional data to pass to sensor creation function.
Definition: Sensors.h:113
dwTime_t minDelta[DW_SENSOR_STATE_SENSOR_STAT_COUNT]
Array of Minimum observed time difference between two consecutive packets as per the dwSensorStatTime...
Definition: Sensors.h:173
struct dwSensorVehicleState::@2 validityInfo
uint64_t sensorId
Sensor id.
Definition: Sensors.h:233
uint64_t errors
Number of encountered errors.
Definition: Sensors.h:142
uint64_t drops
Number of events dropped.
Definition: Sensors.h:145
uint64_t events
Number of normal events (excluding errors and drops).
Definition: Sensors.h:139
float64_t meanDelta[DW_SENSOR_STATE_SENSOR_STAT_COUNT]
Array of Mean of all the deltas between consecutive timestamps as per the dwSensorStatTimeDifference.
Definition: Sensors.h:185
dwTime_t timestamp_us
Timestamp for the current message.
Definition: Sensors.h:265
dwTime_t timeDeltaMin
Minimum observed host timestamp difference between two consecutive packets.
Definition: Sensors.h:153
float64_t timeDeltaStandardDeviation
Variance of all the deltas between consecutive host timestamps.
Definition: Sensors.h:161
dwTime_t currentDelta[DW_SENSOR_STATE_SENSOR_STAT_COUNT]
Array of Current time difference between two consecutive packets as per the dwSensorStatTimeDifferenc...
Definition: Sensors.h:169
dwSensorDrivingDirection direction
driving direction
Definition: Sensors.h:274
float32_t speed
vehicle velocity (m/s)
Definition: Sensors.h:268
dwTime_t maxDelta[DW_SENSOR_STATE_SENSOR_STAT_COUNT]
Array of Maximum observed time difference between two consecutive packets as per the dwSensorStatTime...
Definition: Sensors.h:177
dwTime_t publishedTimestamp
Definition: Sensors.h:237
float64_t timeDeltaMean
Mean of all the deltas between consecutive host timestamps.
Definition: Sensors.h:165
const char8_t * parameters
Array of additional parameters provided to sensor creation.
Definition: Sensors.h:106
dwTime_t timeDeltaCur
Current host timestamp difference between two consecutive packets.
Definition: Sensors.h:149
dwTime_t timestamp
Timestamp of the sensor.
Definition: Sensors.h:235
uint64_t size
size of the event present in the virtual data file, in bytes
Definition: Sensors.h:225
const char8_t * protocol
Name of the protocol.
Definition: Sensors.h:99
dwTime_t timestamp
timestamp of this entry [us]
Definition: Sensors.h:216
float32_t temperature
ambient temperature (C)
Definition: Sensors.h:271
DW_API_PUBLIC dwStatus dwSensor_getNumSeekTableEntries(size_t *const size, dwSensorHandle_t const hsensor)
Get the number of entries in the seek Table.
DW_API_PUBLIC dwStatus dwSensor_createSeekTable(dwSensorHandle_t const sensor)
Forces recreation of the seek table, for sensors that support seeking.
DW_API_PUBLIC dwStatus dwSensor_getStats(dwSensorStats *const stats, dwSensorHandle_t const sensor)
Gets sensor statistics (if available).
dwSensorStatTimeDifference
Defines the various delta used in statistics.
Definition: Sensors.h:118
DW_API_PUBLIC dwStatus dwSensor_reset(dwSensorHandle_t const sensor)
Resets the sensor.
DW_API_PUBLIC dwStatus dwSAL_getPlatform(dwPlatformOS *const os, dwSALHandle_t sal)
Gets current platform the SDK is running on.
DW_API_PUBLIC dwStatus dwSensor_setThreadPriority(int32_t const priority, dwSensorHandle_t const sensor)
Sets the priority of the internal thread, for sensors that use an internal thread to communicate to t...
DW_API_PUBLIC dwStatus dwSensor_saveSeekTable(const char *const fileName, dwSensorHandle_t const sensor)
Saves the seek table for the sensor to a file, for sensors that support seek tables.
DW_API_PUBLIC dwStatus dwSAL_setVehicleState(dwSensorVehicleState *const vehicleState, dwSALHandle_t const sal)
Pass vehicle state to all sensors.
dwStatus dwSensor_getHeader(uint8_t const **const buffer, size_t *bufferSize, dwSensorHandle_t const sensor)
DW_API_PUBLIC dwStatus dwSAL_createSensor(dwSensorHandle_t *const sensor, dwSensorParams const params, dwSALHandle_t const sal)
Creates a new sensor managed by the SAL module with the given parameters.
DW_API_PUBLIC dwStatus dwSensor_start(dwSensorHandle_t const sensor)
Starts the sensor previously successfully created with 'dwSAL_createSensor()'.
DW_API_PUBLIC dwStatus dwSAL_start(dwSALHandle_t const sal)
Bootstraps all sensors managed by the SAL module.
struct dwSALObject * dwSALHandle_t
Handle representing the Sensor Abstraction Layer interface.
Definition: Sensors.h:83
DW_API_PUBLIC dwStatus dwSensor_getSeekRange(size_t *const eventCount, dwTime_t *const startTimestampUs, dwTime_t *const endTimestampUs, dwSensorHandle_t const sensor)
Retrieves the valid range of seek parameters, for sensors that support seeking.
DW_API_PUBLIC dwStatus dwSAL_release(dwSALHandle_t const sal)
Releases the SAL (sensor abstraction layer) module.
DW_API_PUBLIC dwStatus dwSensor_seekToEvent(size_t const event, dwSensorHandle_t const sensor)
Seeks the sensor to an event, for sensors that support seeking.
DW_API_PUBLIC dwStatus dwSAL_getNumSensors(uint32_t *const num, dwPlatformOS const os, dwSALHandle_t const sal)
Gets number of available sensors for a platform.
DW_API_PUBLIC dwStatus dwSensor_stop(dwSensorHandle_t const sensor)
Stops the sensor.
DW_API_PUBLIC dwStatus dwSAL_initialize(dwSALHandle_t *const sal, dwContextHandle_t const context)
Creates and initializes a SAL (sensor abstraction layer) module.
dwSensorDrivingDirection
Driving Direction options.
Definition: Sensors.h:243
DW_API_PUBLIC dwStatus dwSensor_readRawData(const uint8_t **const data, size_t *const size, dwTime_t const timeoutUs, dwSensorHandle_t const sensor)
Reads RAW data from sensor as byte array at a given time (TimeoutUs).
DW_API_PUBLIC dwStatus dwSensor_returnRawData(const uint8_t *const data, dwSensorHandle_t const sensor)
Returns RAW data to sensor as a byte array.
DW_API_PUBLIC dwStatus dwSAL_getPlatformInfo(char8_t const **const osName, dwPlatformOS const os, dwSALHandle_t const sal)
Gets detailed information about the running hardware platform and operating system.
DW_API_PUBLIC dwStatus dwSAL_getSensorProtocol(const char **const name, uint32_t const idx, dwPlatformOS const os, dwSALHandle_t const sal)
Gets protocol name of a sensor for a given index, e.g., 'camera.gmsl' or 'can.file'.
DW_API_PUBLIC dwStatus dwSAL_releaseSensor(dwSensorHandle_t const sensor)
Releases a sensor managed by the SAL module.
dwSensorType
Defines the type of sensors that are available in DriveWorks.
Definition: Sensors.h:189
dwPlatformOS
Defines the operating system in use.
Definition: Sensors.h:68
DW_API_PUBLIC dwStatus dwSensor_setThreadAffinity(uint32_t const affinityMask, dwSensorHandle_t const sensor)
Sets the affinity of the internal thread, for sensors that use an internal thread to communicate to t...
DW_API_PUBLIC dwStatus dwSAL_getSensorParameterString(const char **const parameters, uint32_t const idx, dwPlatformOS const os, dwSALHandle_t const sal)
Gets the parameter string acceptable by a sensor whose type is determined by the index.
DW_API_PUBLIC dwStatus dwSensor_getSeekTableEntries(dwSensorSeekTableEntry *const entries, size_t const numEntries, dwSensorHandle_t const sensor)
Fill in the pre-allocated dwSensorSeekTableEntry array.
dwSensorErrorID
Sensor Error ID to be used in, e.g., dwErrorSignal.errorID[31:24] when DW_SENSOR_ERROR_CODE_OFFSET_BI...
Definition: Sensors.h:286
struct dwSensorObject * dwSensorHandle_t
Handle representing a sensor.
Definition: Sensors.h:86
DW_API_PUBLIC dwStatus dwSensor_getCurrentSeekPosition(size_t *const event, dwSensorHandle_t const sensor)
Gets the current seek position of the sensor.
DW_API_PUBLIC dwStatus dwSensor_seekToTime(dwTime_t const timestampUs, dwSensorHandle_t const sensor)
Seeks the sensor to a specific timestamp, for sensors that support seeking.
DW_API_PUBLIC dwStatus dwSAL_reset(dwSALHandle_t const sal)
Resets the SAL (sensor abstraction layer) module.
@ DW_SENSOR_STATE_DELTA_HOST_AND_SENSOR_TIME
Difference between host timestamp and sensor timestamp.
Definition: Sensors.h:126
@ DW_SENSOR_STATE_DELTA_HOST_AND_HOST_TIME
Difference between two consecutive host timestamp.
Definition: Sensors.h:120
@ DW_SENSOR_STATE_SENSOR_STAT_COUNT
Count which the type value is less than.
Definition: Sensors.h:132
@ DW_SENSOR_STATE_DELTA_SENSOR_AND_SENSOR_TIME
Difference between two consecutive sensor timestamp.
Definition: Sensors.h:123
@ DW_SENSOR_STATE_DELTA_CURRENT_AND_HOST_TIME
Difference between current time and the last host timestamp when sensor data was received.
Definition: Sensors.h:129
@ DW_SENSOR_DRIVING_DIRECTION_UNKNOWN
Driving direction is unknown or no moving.
Definition: Sensors.h:245
@ DW_SENSOR_DRIVING_DIRECTION_FORWARD
Driving direction is fowarding.
Definition: Sensors.h:247
@ DW_SENSOR_DRIVING_DIRECTION_BACKWARD
Driving direction is backwarding.
Definition: Sensors.h:249
@ DW_SENSOR_LIDAR
Lidar.
Definition: Sensors.h:193
@ DW_SENSOR_ULTRASONIC
Ultrasonic.
Definition: Sensors.h:207
@ DW_SENSOR_COUNT
Sensor count which the sensor type value is less than.
Definition: Sensors.h:209
@ DW_SENSOR_CAN
CAN.
Definition: Sensors.h:199
@ DW_SENSOR_IMU
IMU.
Definition: Sensors.h:197
@ DW_SENSOR_RADAR
RADAR.
Definition: Sensors.h:201
@ DW_SENSOR_CAMERA
CAMERA.
Definition: Sensors.h:191
@ DW_SENSOR_GPS
GPS.
Definition: Sensors.h:195
@ DW_SENSOR_TIME
TIME.
Definition: Sensors.h:203
@ DW_SENSOR_DATA
DATA.
Definition: Sensors.h:205
@ DW_PLATFORM_OS_V5Q
aarch64 based Drive 5 QNX.
Definition: Sensors.h:76
@ DW_PLATFORM_OS_V5L
aarch64 based Drive 5 Linux.
Definition: Sensors.h:73
@ DW_PLATFORM_OS_LINUX
Default Linux based platform.
Definition: Sensors.h:70
@ DW_PLATFORM_NUM
Number of available platforms.
Definition: Sensors.h:79
@ DW_SENSOR_ERROR_CODE_NO_NEW_DATA
no new data received
Definition: Sensors.h:290
@ DW_SENSOR_ERROR_CODE_INVALID
sensor ok
Definition: Sensors.h:288
Holds sets of parameters for sensor creation.
Definition: Sensors.h:95
A seek structure is made of memory offset, eventcount and timestamp.
Definition: Sensors.h:214
Holds the available statistics for a sensor.
Definition: Sensors.h:137
Hold the timestamp and ID of the sensor.
Definition: Sensors.h:231
Vehicle State inputs.
Definition: Sensors.h:256