Omniverse Common Extension#
Introduction#
The Common extension is the one extension that every sensor extension depends on. It provides a set of common functionalities/headers that are used by other extensions.
GenericModelOutput#
The GenericModelOutput is a common data structure that is used by all sensor extensions to represent the output of the sensor. The output is defined according to ISO855 sensor frame, which means the following:
Angles are in degrees from [-180, 180] for azimuth and [-90, 90] for elevation in a right-handed coordinate system.
Front is +x, left is +y, up is +z.
Structure Members#
magicNumberuint32_tA unique identifier for the output. Should reflect
MAGIC_NUMBER_GMO, which is the ASCII for “NGMO”.
majorVersionuint32_tThe major version number of the model output.
minorVersionuint32_tThe minor version number of the model output.
patchVersionuint32_tThe patch version number of the model output.
numElementsuint32_tThe number of elements in the array members of the model output.
frameOfReferenceFrameOfReferenceThe frame of reference for the model output. The default value is
FrameOfReference::SENSOR.
frameIduint64_tThe model (simulation) frame ID of the model output.
timestampNsuint64_tThe timestamp of the model output in nanoseconds.
coordsTypeCoordsTypeThe type of coordinates used in the model output. The default value is
CoordsType::SPHERICAL.
outputTypeOutputTypeThe type of output. The default value is
OutputType::POINTCLOUD.
modelToAppTransformfloat[16]A transformation matrix that transforms from the model’s coordinate system to the application’s coordinate system.
frameStartFrameAtTimeThe start frame of the model output. It transforms from the model’s coordinate system to the global coordinate system at frame start time.
frameEndFrameAtTimeThe end frame of the model output. It transforms from the model’s coordinate system to the global coordinate system at frame end time. See below for more information.
auxTypeAuxTypeThe modality specific type of auxiliary data. The default value is
AuxType::NONE. See below for more information.
paddinguint8_t[4]Padding to align the structure to a multiple of 8 bytes.
elementsBasicElementsThe basic elements of the model output. See below for more information.
auxiliaryDatavoid*A pointer to the auxiliary data. This may not be filled. See below for more information.
BasicElements#
Represents the basic elements of the model output.
timeOffsetNsint32_t*Time offset from the start of the point cloud.
xfloat*Azimuth in degree [-180,180] or cartesian x in m.
yfloat*Elevation in degree or cartesian y in m.
zfloat*Distance in m or cartesian z in m.
scalarfloat*Sensor specific scalar.
flagsuint8_t*Sensor specific flags representing ElementFlags enum values. For instance, for probing if the element is valid.
FrameAtTime#
Represents a frame at a specific time.
timestampNsuint64_tThe timestamp of the frame in nanoseconds. The default value is
0UL.
orientationfloat4The orientation of the frame.
posMfloat3The position of the frame.
paddinguint8_t[4]Padding to align the structure to a multiple of 8 bytes.
FrameOfReference#
Represents the frame of reference for the model output.
SENSORPARENTGLOBALSENSOR_MOTION_COMPENSATEDPARENT_MOTION_COMPENSATED
CoordsType#
Represents the type of coordinates used in the model output.
CARTESIANSPHERICAL: x,y,z of BasicPoints contains: azimuth, elevation, distanceUNDEFINED: Pixels?
ElementFlags#
Represents flags for elements.
FLAG_1FLAG_2FLAG_3FLAG_4FLAG_5FLAG_5FLAG_6FLAG_7VALID
OutputType#
Represents the type of output.
POINTCLOUD
AuxType#
Represents the type of auxiliary data.
NONELIDARRADARUSSIDS
AuxiliaryData#
Every modality has its specific auxiliary data. See AuxType enum for a list of available auxiliary data types. Below are the structures for the supported modalities:
LidarAuxiliaryData#
The LidarAuxiliaryData structure contains auxiliary data for a Lidar sensor.
uint32_t scanCompleteWhether the scan is complete.
float azimuthOffsetThe offset to +x in radians for specific sensors.
LidarAuxHas filledAuxMembersWhich auxiliary data is filled.
uint32_t* emitterIdThe emitter ID.
uint32_t* channelIdThe channel ID.
uint8_t* echoIdThe echo ID.
uint32_t* matIdThe material ID.
uint32_t* objIdThe object ID.
uint32_t* tickIdThe tick ID.
uint8_t* tickStatesThe tick states.
float* hitNormalsThe hit normals.
float* velocitiesThe velocities.
The LidarAuxHas enum class is used to specify which auxiliary data is filled for a Lidar sensor.
NONENo auxiliary data is filled.
EMITTER_IDThe emitter ID is filled.
CHANNEL_IDThe channel ID is filled.
ECHO_IDThe echo ID is filled.
MAT_IDThe material ID is filled.
OBJ_IDThe object ID is filled.
TICK_IDThe tick ID is filled.
TICK_STATESThe tick states are filled.
HIT_NORMALSThe hit normals are filled.
VELOCITIESThe velocities are filled.
USSAuxiliaryData#
The USSAuxiliaryData structure contains auxiliary data for an USS sensor.
uint32_t numSgwsThe number of SGWs.
uint32_t numSamplesPerSgwThe number of samples per SGW.
RadarAuxiliaryData#
The RadarAuxiliaryData structure contains auxiliary data for a Radar sensor.
uint8_t sensorIDThe ID of the sensor that generated the scan.
uint8_t scanIdxThe scan index for sensors with multi-scan support.
uint64_t timeStampNSThe scan timestamp in nanoseconds.
uint64_t cycleCntThe scan cycle count (unique per scan index).
float maxRangeMThe maximum unambiguous range for the scan.
float minVelMpsThe minimum unambiguous velocity for the scan.
float maxVelMpsThe maximum unambiguous velocity for the scan.
float minAzRadThe minimum unambiguous azimuth for the scan.
float maxAzRadThe maximum unambiguous azimuth for the scan.
float minElRadThe minimum unambiguous elevation for the scan.
float maxElRadThe maximum unambiguous elevation for the scan.
uint32_t numDetectionsThe number of detections.
RadarAuxHas filledAuxMembersWhich auxiliary data is filled.
float* rv_msThe radial velocity (m/s), always filled.
uint32_t* semIdThe SEM ID, optional.
uint32_t* matIdThe material ID, optional.
uint32_t* objIdThe object ID, optional.
The RadarAuxHas enum class is used to specify which auxiliary data is filled for a Radar sensor.
NONENo auxiliary data is filled.
SEM_IDThe semantic ID is filled.
MAT_IDThe material ID is filled.
OBJ_IDThe object ID is filled.
IDSAuxiliaryData#
The IDSAuxiliaryData structure contains auxiliary data for an IDS (Idealized Depth Sensor) sensor.
uint32_t numRowsThe number of rows in the sensor’s field of view.
uint32_t numColsThe number of columns in the sensor’s field of view.
float minColUnitThe minimum column unit of the specified field of view.
float maxColUnitThe maximum column unit of the specified field of view.
float minRowUnitThe minimum row unit of the specified field of view.
float maxRowUnitThe maximum row unit of the specified field of view.
float emitterCfgOriginXThe x-coordinate of the origin of the emitter configuration.
float emitterCfgOriginYThe y-coordinate of the origin of the emitter configuration.
float emitterCfgOriginZThe z-coordinate of the origin of the emitter configuration.
int emitterGenTypeThe type of the emitter generation.
float elementSizeThe maximum size of the spatial element to generate.
float radiusThe radius at which the element size is defined.
float* originXThe x-coordinates of the origins.
float* originYThe y-coordinates of the origins.
float* originZThe z-coordinates of the origins.
uint32_t* objectIdThe object IDs.
Utility functions#
Additionally, the GenericModelOutput provides utility functions, e.g, for building the structure out of a contiguous memory block, or for copying the structure. Below, is a list of the most important utility functions:
sizeInBytes#
The sizeInBytes function is a part of the omni::sensors namespace. It calculates the total size of the GenericModelOutput structure and its elements.
Function Signature
NV_HOSTDEVICE
inline size_t sizeInBytes(const GenericModelOutput& output)
Parameters
outputconst GenericModelOutput&The
GenericModelOutputstructure for which to calculate the size.
Returns
size_tThe total size of the
GenericModelOutputstructure and its elements.
Description
This function calculates the total size of the GenericModelOutput structure and its elements.
getModelOutputPtrFromBuffer#
The getModelOutputPtrFromBuffer function is a part of the omni::sensors namespace. It retrieves a pointer to a GenericModelOutput structure from a buffer.
Function Signature
NV_HOSTDEVICE
inline GenericModelOutput* getModelOutputPtrFromBuffer(void* inData)
Parameters
inDatavoid*The input data buffer from which to retrieve the
GenericModelOutputstructure.
Returns
GenericModelOutput*A pointer to the
GenericModelOutputstructure retrieved from the buffer.
Description
This function first checks if the magic number of the GenericModelOutput structure is correct. If it is, the function then checks if the version of the GenericModelOutput structure is supported. If the version is supported, the function sets the basic elements and auxiliary data of the GenericModelOutput structure. If the magic number or version is not correct, the function prints an error message.
cpyGMOToBuffer#
The cpyGMOToBuffer function is a part of the omni::sensors namespace. It copies a GenericModelOutput structure to a buffer.
Function Signature
inline void cpyGMOToBuffer(uint8_t* buffer,
const omni::sensors::GenericModelOutput* gpc,
const bool bufferOnHost = true, // not needed for cpu only
const bool pointerOnHost = true, // not needed for cpu only
const int32_t cudaDevice = -1, // not needed for cpu only
const cudaStream_t stream = 0) // not needed for cpu only
Parameters
bufferuint8_t*The buffer to which to copy the
GenericModelOutputstructure.
gpcconst omni::sensors::GenericModelOutput*The
GenericModelOutputstructure to copy.
bufferOnHostboolWhether the buffer is on the host. Default is
true.
pointerOnHostboolWhether the pointer is on the host. Default is
true.
cudaDeviceint32_tThe CUDA device to use. Default is
-1.
streamcudaStream_tThe CUDA stream to use. Default is
0.
Description
This function first checks if the magic number of the GenericModelOutput structure is correct. If it is, the function then checks if the version of the GenericModelOutput structure is supported. If the version is supported, the function sets the copy kind based on whether the buffer and pointer are on the host or device. If the magic number or version is not correct, the function prints an error message.
The function then copies the GenericModelOutput structure to the buffer using the appropriate copy kind.
Plugins#
IGenericModelOutputIO#
The IGenericModelOutputIO class is an interface for generic model output I/O operations. It writes and reas into a hdf5 file.
Methods#
void init(const GMOIOConfig& cfg)Initializes the
IGenericModelOutputIOinterface with the given configuration.
void writeModelOutput(const GenericModelOutput& modelOutput)Writes the given model output.
GenericModelOutput readModelOutput(const omni::string& sensorName = "", const int frameId = -1)Reads a model output. If a sensor name is given, it reads the model output for that sensor. If a frame ID is given, it reads the specific frame. If no arguments are given, it reads frames in order.
void addPacket(void* packet, const size_t packetSize)Adds a packet with the given size.
Initialization#
To get an object of the IGenericModelOutputIO interface, you need to call the carb::getFramework()->acquireInterface<omni::sensors::IGenericModelOutputIOFactory>()->createInstance() function.
To initialize the IGenericModelOutputIO interface, you need to create a GMOIOConfig structure and call the init method.
GMOIOConfig#
The GMOIOConfig structure is used to configure the IGenericModelOutputIO interface.
AccessType accessTypeThe access type for the
IGenericModelOutputIOinterface. Default isAccessType::RECORD_FULL.
bool onlyValidWhether to only consider valid data. Default is
false.
bool loopWhether to loop the data. Default is
false. Only needed forAccessType::READ.
uint32_t maxPointsThe maximum number of points. Default is
0. Only needed forAccessType::READ.
omni::string fileNameThe name of the file. Default is an empty string.
omni::string sensorNameThe name of the sensor. Default is an empty string.
IProfileReader#
The IProfileReader reads the parameter of the modality specific profile from a JSON file. The interface is defined in (include/omni/sensors/IProfileReader.h).
Users can create objects that implement this interface by acquiring the IProfileReaderFactory (include/omni/sensors/IProfileReader.h) carbonite interface and using the createInstance() method.
Instantiation#
To instantiate the IProfileReader the user needs to acquire the carbonite IProfileReaderFactory interface, and use the create instance method:
auto profileReader = carb::getFramework()->acquireInterface<omni::sensors::IProfileReaderFactory>()->createInstance();
Initialization#
The user has to initialize the profile reader with the JSON string:
const auto json = profileReader->getProfileJsonAtPaths(profileName.c_str(), ProfileType::LIDAR);
profileReader->init(json.c_str(),ProfileType::LIDAR); // Currently, supprted: LIDAR, RADAR, USS, IDS (and variants)
Filling a Profile object#
The user can get the data size object of the profile (for data dependent sizes, e.g, for LIDAR) and has to allocate the memory for the profile objectId before the profile reader can fill the profile object:
auto dataSize = profileReader->dataSizeProfile();
// can be done with std::vector or cudaMalloc etc, depending on the need of the user
void* profile{nullptr};
profile = malloc(dataSize);
profileReader->update(profile);
//
Pythong Bindings#
The common extension provides a multitude of python bindings, e.g., for the GenericModelOutput structure, the IGenericModelOutputIO and the IProfileReader interface.