AGX Dynamics 2.40.0.0
Loading...
Searching...
No Matches
agxSensor::RtOutput Class Reference

Raytrace output data where RtOutput::Field defines the data available. More...

#include <RaytraceOutput.h>

+ Inheritance diagram for agxSensor::RtOutput:

Classes

struct  DataState
 

Public Types

enum  Field : int32_t {
  XYZ_VEC3_F32 = 1 , INTENSITY_F32 , INTENSITY_U8 , IS_HIT_I32 ,
  IS_GROUND_I32 , RAY_IDX_U32 , ENTITY_ID_I32 , DISTANCE_F32 ,
  AZIMUTH_F32 , ELEVATION_F32 , RING_ID_U16 , RETURN_TYPE_U8 ,
  TIME_STAMP_F64 , TIME_STAMP_U32 , ABSOLUTE_VELOCITY_VEC3_F32 , RELATIVE_VELOCITY_VEC3_F32 ,
  RADIAL_SPEED_F32 , POWER_F32 , RCS_F32 , NOISE_F32 ,
  SNR_F32 , NORMAL_VEC3_F32 , INCIDENT_ANGLE_F32 , RAY_POSE_MAT3x4_F32 ,
  NUM_FIELDS , PADDING_8 = 1024 , PADDING_16 , PADDING_32
}
 
enum  FieldElementType : uint8_t {
  EMPTY = 0 , I8 , U8 , I16 ,
  U16 , I32 , U32 , F32 ,
  F64
}
 
using FieldVector = std::vector< Field >
 
using State = agx::AtomicState< DataState::Flag >
 

Public Member Functions

 RtOutput ()
 Default constructor.
 
RtOutputadd (Field field)
 Add new field.
 
template<Field... field>
void build ()
 Add one or more fields, build a matching data structure.
 
bool contains (Field field) const
 
const BinaryOutputBuffergetData () override
 Synchronizes the data before returning if new data is available.
 
BinaryOutputBuffergetDataUnsafe ()
 Unsafe data buffer access, use only this if you know the call is being made in context of raytrace and data synchronization.
 
size_t getElementSize () const override
 "Element size" is the summed data size of the currently added fields.
 
const std::vector< Field > & getFields () const
 
size_t getOffset (Field field) const
 Offset in bytes of field in the pack of fields.
 
const BinaryOutputBuffergetSynchronizedData ()
 Synchronizes the data before returning if new data is available.
 
bool hasUnreadData (bool markAsRead=true) override
 
template<typename T >
BinaryOutputView< T > viewUnsafe () const
 Similar to view() but without data synchronization, this is the current data available.
 
- Public Member Functions inherited from agxSensor::RtSystemNode
virtual ~RtSystemNode ()=default
 
virtual bool addNotification () override
 Called when this system node has been added to a sensor environment.
 
virtual void cleanup () override
 The sensor environment is being put down, clean everything.
 
template<typename T >
RtSystemNodefindChildProxyFor () const
 
RtNodegetNode () const
 
RtNodegetOrCreateNode ()
 Called when the node is required.
 
virtual void onChildAdded (SystemNode &child) override
 Called when child has been added to this parent.
 
virtual void onChildRemoved (SystemNode &child) override
 Called when child has been removed from this parent.
 
virtual void onParentConnect (RtSystemNode &parent)
 Called when getOrCreateNode() returns nullptr when this node is being added as child to parent.
 
virtual void onParentDisconnect (RtSystemNode &parent)
 Called when getNode() returns nullptr when this node is being removed from its parent.
 
virtual void removeNotification () override
 Called when this system node is being removed from a sensor environment.
 
- Public Member Functions inherited from agxSensor::SystemNode
 SystemNode (const SystemNode &)=delete
 Disallow direct copying of nodes.
 
virtual ~SystemNode ()=default
 
bool addChild (SystemNode *child)
 Add unique child to this node.
 
virtual bool addNotification ()
 Called when this system node has been added to a sensor environment.
 
bool appendChild (SystemNode *child)
 Append child to vector of children, silently.
 
virtual void cleanup ()=0
 The sensor environment is being put down, clean everything.
 
virtual void complete ()
 Complete the execution of this system, finishing the integration forward in time.
 
bool detachChild (SystemNode *child)
 Detach/erase child from vector of children, silently.
 
virtual bool eraseAndConnect ()
 Erase this node from the tree and connect its children to the current parent of this node.
 
virtual void execute (const CallbackData &data)
 Execute this system, integrating it data.dt forward in time.
 
template<typename T >
T * findChild (bool recurse=true) const
 Find child of given type.
 
template<typename PredicateT >
SystemNodefindChild (PredicateT pred, bool recurse=true) const
 Find child given predicate pred.
 
template<typename T >
T * findParent () const
 
template<typename PredicateT >
SystemNodefindParent (PredicateT pred) const
 Find parent given predicate.
 
template<typename T >
T * getChild () const
 Searches children for a node of given type.
 
SystemNodegetChild (size_t index) const
 
bool getEnable () const
 
EnvironmentgetEnvironment () const
 
const agx::NamegetName () const
 
size_t getNumChildren () const
 
SystemNodegetParent () const
 
SystemNodegetRoot () const
 
bool hasChild (const SystemNode *child, bool recurse=true) const
 
virtual bool insertParent (SystemNode &parent)
 Inserts new parent to this node.
 
virtual bool onAdd (agx::Referenced &instance)
 Called when an object has been added to the sensor environment.
 
virtual void onChildAdded (SystemNode &child)
 Called when child has been added to this parent.
 
virtual void onChildRemoved (SystemNode &child)
 Called when child has been removed from this parent.
 
virtual bool onRemove (agx::Referenced &instance)
 Called when an object has been removed from the sensor environment.
 
bool removeChild (SystemNode *child)
 Remove child from this node.
 
virtual void removeNotification ()
 Called when this system node is being removed from a sensor environment.
 
virtual void result (const CallbackData &data)
 If necessary assemble, and fetch results related to this system node after a step by data.dt has been completed.
 
void setEnable (bool enable)
 Enable/disable this node.
 
void setName (const agx::Name &name)
 Assign name to this node.
 
virtual void synchronize (const CallbackData &data)
 Synchronization from the main thread.
 
template<typename VisitorT >
SystemNodevisitBf (VisitorT visitor) const
 Visit the tree from, including, this node until callback returns true - using breadth first traversal.
 
template<typename VisitorT >
void visitChildren (VisitorT visitor, bool recurse=true) const
 Visit all children with func as void( const SystemNode& child ).
 
template<typename VisitorT >
SystemNodevisitChildrenBf (VisitorT visitor) const
 Visit the tree from the children of this node until callback returns true - using breadth first traversal.
 
template<typename VisitorT >
SystemNodevisitChildrenDf (VisitorT visitor) const
 Visit the tree from the children of this node until callback returns true - using depth first traversal.
 
template<typename T , typename VisitorT >
void visitChildrenOfType (VisitorT visitor, bool recurse=true) const
 Visit all children with func as void( const T& child ).
 
template<typename VisitorT >
SystemNodevisitDf (VisitorT visitor) const
 Visit the tree from, including, this node until callback returns true - using depth first traversal.
 
- Public Member Functions inherited from agx::Referenced
 Referenced ()
 Default constructor.
 
 Referenced (const Referenced &)
 
template<typename T >
T * as ()
 Subclass casting.
 
template<typename T >
const T * as () const
 
template<typename T >
T * asSafe ()
 Safe subclass casting, return nullptr if template type does not match.
 
template<typename T >
const T * asSafe () const
 
int getReferenceCount () const
 
template<typename T >
bool is () const
 Subclass test.
 
Referencedoperator= (const Referenced &)
 Assignment operator. Will increment the number of references to the referenced object.
 
void reference (void *ptr=nullptr) const
 Explicitly increment the reference count by one, indicating that this object has another pointer which is referencing it.
 
void unreference (void *ptr=nullptr) const
 Decrement the reference count by one, indicating that a pointer to this object is referencing it.
 
void unreference_nodelete () const
 Decrement the reference count by one, indicating that a pointer to this object is referencing it.
 
- Public Member Functions inherited from agxStream::Serializable
virtual ~Serializable ()
 Destructor for normal C++ use but hidden from SWIG bindings.
 
virtual const char * getClassName () const
 
bool getEnableSerialization () const
 
bool getEnableUuidGeneration ()
 
agx::UInt32 getIndex () const
 This index is given at creation of this object.
 
virtual StorageAgent * getStorageAgent () const =0
 
agx::Uuid getUuid () const
 
bool isFinished () const
 
void setEnableSerialization (bool flag)
 Set to false to disable serialization of this object.
 
void setFinished ()
 Tells this class that it is restored correctly and should not be deleted during destruction of an Archive.
 
void setUuid (const agx::Uuid &uuid)
 Explicitly set a Uuid on a serializable object.
 
- Public Member Functions inherited from agxSensor::ISensorOutput
 ISensorOutput ()=default
 Default constructor.
 
virtual const BinaryOutputBuffergetData ()=0
 Returns access to the sensor output data.
 
virtual size_t getElementSize () const =0
 "Element size" is the summed data size of the currently added sensor output fields.
 
virtual bool hasUnreadData (bool markAsRead=true)=0
 
template<typename T >
BinaryOutputView< T > view ()
 View over data.
 

Static Public Member Functions

static int getFieldElementCount (Field field)
 
static const std::vector< std::string > & getFieldElementNames (Field field)
 
static FieldElementType getFieldElementType (Field field)
 
static const char * getFieldName (Field field)
 
template<typename T >
static size_t getTypeHash ()
 
template<typename T >
static const char * getTypeName ()
 
static size_t sizeOf (Field field)
 
- Static Public Member Functions inherited from agx::Referenced
template<typename T >
static bool ValidateCast (const Referenced *object)
 
- Static Public Member Functions inherited from agxStream::Serializable
static void setEnableUuidGeneration (bool flag)
 Specify if there should be UUID:s generated for each new Serializable object. By default it is enabled.
 
- Static Public Member Functions inherited from agxSensor::ISensorOutput
template<typename T >
static bool verifySize (size_t elementSize)
 Checks whether sizeof(T) == elementSize and issues a warning if it is not.
 

Additional Inherited Members

- Protected Member Functions inherited from agx::Referenced
virtual ~Referenced ()
 Destructor.
 
void allocateObserverVector () const
 
void deleteUsingDeleteHandler () const
 
- Protected Member Functions inherited from agxStream::Serializable
 Serializable ()
 Default constructor.
 
 Serializable (const Serializable &other)
 Copy constructor.
 
void generateUuid ()
 
- Static Protected Member Functions inherited from agx::Referenced
static DeleteHandlergetDeleteHandler ()
 
static void setDeleteHandler (DeleteHandler *handler)
 Internal: Set a DeleteHandler to which deletion of all referenced counted objects will be delegated to.
 
- Protected Attributes inherited from agxSensor::RtSystemNode
RtNodem_node { nullptr }
 
- Protected Attributes inherited from agx::Referenced
Mutex m_mutex
 
ObserverContainer m_observers
 
AtomicValue m_refCount
 

Detailed Description

Raytrace output data where RtOutput::Field defines the data available.

It's possible to pack data into a custom type, e.g.,

struct RayPointAndDistance : agx::Vec4f { agx::Vec3f getPosition() const { First three elements is the point. return { (*this)[ 0 ], (*this)[ 1 ], (*this)[ 2 ] }; }

float getDistance() const { Fourth element is the distance. return (*this)[ 3 ]; } };

RtOutputRef pointAndDistanceOutput = new RtOutput(); pointAndDistanceOutput->build<RtOutput::XYZ_VEC3_F32, RtOutput::DISTANCE_F32>();

Equivalent but using the output handler in a lidar. Using the output handler verifies the size of your struct vs fields.

auto pointAndDistanceOutput = lidar->getOutputHandler()->add<RayPointAndDistance,
                                                             RtOutput::XYZ_VEC3_F32,
                                                             RtOutput::DISTANCE_F32>();

perform raytrace auto view = pointAndDistanceOutput->view<RayPointAndDistance>(); for ( const auto& pointAndDistance : view ) ...

Definition at line 64 of file RaytraceOutput.h.

Member Typedef Documentation

◆ FieldVector

Definition at line 144 of file RaytraceOutput.h.

◆ State

using agxSensor::RtOutput::State = agx::AtomicState<DataState::Flag>

Definition at line 156 of file RaytraceOutput.h.

Member Enumeration Documentation

◆ Field

Enumerator
XYZ_VEC3_F32 

3x 32-bit floating point position of the hit.

INTENSITY_F32 

1x 32-bit floating point intensity of the hit.

INTENSITY_U8 

Placeholder - not calculated.


IS_HIT_I32 

1x 32-bit flag (0 or 1) indicating if the hit is a hit or miss.

IS_GROUND_I32 

Placeholder - not calculated.


RAY_IDX_U32 

1x 32-bit uint index of the ray.

ENTITY_ID_I32 

1x 32-bit int index of the entity being hit.

DISTANCE_F32 

1x 32-bit floating point distance of hit from emission origin.

AZIMUTH_F32 

Placeholder - not calculated.


ELEVATION_F32 

Placeholder - not calculated.


RING_ID_U16 

Placeholder - not calculated.


RETURN_TYPE_U8 

Placeholder - not calculated.


TIME_STAMP_F64 

1x 64-bit floating point timestamp of the raytracing scene.

TIME_STAMP_U32 

Placeholder - not calculated.


ABSOLUTE_VELOCITY_VEC3_F32 

Placeholder - not calculated.


RELATIVE_VELOCITY_VEC3_F32 

Placeholder - not calculated.


RADIAL_SPEED_F32 

Placeholder - not calculated.


POWER_F32 

Placeholder - not calculated.


RCS_F32 

Placeholder - not calculated.


NOISE_F32 

Placeholder - not calculated.


SNR_F32 

Placeholder - not calculated.


NORMAL_VEC3_F32 

3x 32-bit float normal vector of the entity surface where the hit-point is located.

INCIDENT_ANGLE_F32 

1x 32-bit float incident angle of the ray hitting entity surface in radians.

In range [0, PI/2) rad, where 0 means the ray hit the surface perpendicularly.

RAY_POSE_MAT3x4_F32 

12x 32-bit float row major 3x4 matrix describing pose of the ray in the world coordinate system.

NUM_FIELDS 

(Number of fields indicator)

PADDING_8 

8-bit padding

PADDING_16 

16-bit padding

PADDING_32 

32-bit padding

Definition at line 81 of file RaytraceOutput.h.

◆ FieldElementType

Enumerator
EMPTY 
I8 
U8 
I16 
U16 
I32 
U32 
F32 
F64 

Definition at line 68 of file RaytraceOutput.h.

Constructor & Destructor Documentation

◆ RtOutput()

agxSensor::RtOutput::RtOutput ( )

Default constructor.

Member Function Documentation

◆ add()

RtOutput & agxSensor::RtOutput::add ( Field  field)

Add new field.

Parameters
field- field to add
Returns
this

◆ build()

template<RtOutput::Field... field>
void agxSensor::RtOutput::build

Add one or more fields, build a matching data structure.

Definition at line 322 of file RaytraceOutput.h.

◆ contains()

bool agxSensor::RtOutput::contains ( Field  field) const
Returns
true if this output contains the given field.

◆ getData()

const BinaryOutputBuffer & agxSensor::RtOutput::getData ( )
overridevirtual

Synchronizes the data before returning if new data is available.

Returns
the binary data buffer in the current state

Implements agxSensor::ISensorOutput.

◆ getDataUnsafe()

BinaryOutputBuffer & agxSensor::RtOutput::getDataUnsafe ( )

Unsafe data buffer access, use only this if you know the call is being made in context of raytrace and data synchronization.

Use view or getSynchronizedData instead.

◆ getElementSize()

size_t agxSensor::RtOutput::getElementSize ( ) const
overridevirtual

"Element size" is the summed data size of the currently added fields.

Returns
the current, summed, data size of the added fields

Implements agxSensor::ISensorOutput.

◆ getFieldElementCount()

static int agxSensor::RtOutput::getFieldElementCount ( Field  field)
static
Parameters
field- data field
Returns
amount of elements in the field

◆ getFieldElementNames()

static const std::vector< std::string > & agxSensor::RtOutput::getFieldElementNames ( Field  field)
static
Parameters
field- data field
Returns
names of individual elements in field (e.g. "x", "y", and "z" for position)

◆ getFieldElementType()

static FieldElementType agxSensor::RtOutput::getFieldElementType ( Field  field)
static
Parameters
field- data field
Returns
type of elements in the field

◆ getFieldName()

static const char * agxSensor::RtOutput::getFieldName ( Field  field)
static
Parameters
field- data field
Returns
name of the given field

◆ getFields()

const std::vector< Field > & agxSensor::RtOutput::getFields ( ) const
Returns
A const reference to the internal vector containg the fields of the output.

◆ getOffset()

size_t agxSensor::RtOutput::getOffset ( Field  field) const

Offset in bytes of field in the pack of fields.

Note that the total size of this output will be returned if field is not part of this output.

Parameters
field- field to get offset to
Returns
offset in bytes to the given field

◆ getSynchronizedData()

const BinaryOutputBuffer & agxSensor::RtOutput::getSynchronizedData ( )

Synchronizes the data before returning if new data is available.

Returns
the binary data buffer in the current state

◆ getTypeHash()

template<typename T >
size_t agxSensor::RtOutput::getTypeHash
static
Returns
unique hash of the given type T

Definition at line 308 of file RaytraceOutput.h.

◆ getTypeName()

template<typename T >
const char * agxSensor::RtOutput::getTypeName
static
Returns
type name of the given type T

Definition at line 315 of file RaytraceOutput.h.

◆ hasUnreadData()

bool agxSensor::RtOutput::hasUnreadData ( bool  markAsRead = true)
overridevirtual
Parameters
markAsRead- true to reset unread state, resulting in hasUnreadData returning false until new data is available. False to not mark the current data as read.
Returns
true when the data has been updated but not read/used/fetched by the user, false if the data has been read

Implements agxSensor::ISensorOutput.

◆ sizeOf()

static size_t agxSensor::RtOutput::sizeOf ( Field  field)
static
Parameters
field- data field
Returns
data size of the field

◆ viewUnsafe()

template<typename T >
BinaryOutputView< T > agxSensor::RtOutput::viewUnsafe

Similar to view() but without data synchronization, this is the current data available.

Returns
view of data as type T

Definition at line 330 of file RaytraceOutput.h.


The documentation for this class was generated from the following file: