ContactSensor#
Fully qualified name: isaacsim::sensors::physics::ContactSensor
-
class ContactSensor : public isaacsim::sensors::physics::IsaacSensorComponentBase<PrimType>#
Component for simulating contact sensors in the physics environment.
Manages a contact sensor that can detect and measure forces between physical bodies. Inherits from IsaacBaseSensorComponent to integrate with the sensor framework.
Public Functions
- inline ContactSensor(
- omni::physx::IPhysx *physXInterface,
- ContactManager *contactManager,
Constructor for ContactSensor.
- Parameters:
physXInterface – [in] Pointer to the PhysX interface.
contactManager – [in] Pointer to the contact manager instance.
-
virtual ~ContactSensor()#
Virtual destructor.
-
void reset()#
Resets the sensor to its initial state.
-
CsRawData *getRawData(size_t &size)#
Gets the raw contact data from the sensor.
- Parameters:
size – [out] Number of contact data points.
- Returns:
Pointer to array of raw contact data.
-
CsReading getSensorReading(const bool &getLatestValue = false)#
Gets the processed sensor reading.
- Parameters:
getLatestValue – [in] If true, returns the latest simulation value instead of the last sensor reading.
- Returns:
Processed contact sensor reading.
- void processRawContacts(
- CsRawData *rawContact,
- const size_t &size,
- const size_t &index,
- const double &time,
Processes raw contact data into sensor readings.
- Parameters:
rawContact – [in] Array of raw contact data.
size – [in] Number of contact data points.
index – [in] Index indicating data recency (0 for old, 1 for new).
time – [in] Current simulation time.
-
virtual void onPhysicsStep()#
Called each physics step to update sensor state.
-
inline virtual void tick()#
Called each tick to update sensor state.
Note
onPhysicsStep is used to update the sensor state.
-
void setContactReportApi()#
Sets up the contact report API for the sensor.
-
bool findValidParent()#
Finds a valid parent body for the sensor.
- Returns:
True if a valid parent was found, false otherwise.
-
virtual void onComponentChange()#
Handles component property changes.
-
virtual void onStop()#
Called when the simulation stops.
Redraws the sensor after stopping, unlike the base class implementation.
-
void printRawData(CsRawData *data)#
Debug function to print raw contact data.
- Parameters:
data – [in] Pointer to raw contact data to print.
-
void printReadingPair()#
Debug function to print the current reading pair.
- inline virtual void initialize(
- const PrimType &prim,
- const pxr::UsdStageWeakPtr stage,
Initializes the sensor component.
Sets up the sensor component with its USD prim and stage references.
- Parameters:
prim – [in] USD prim representing the sensor.
stage – [in] USD stage containing the prim.
-
inline virtual void onStart()#
Called when the sensor starts.
Handles sensor initialization when the component is started. Triggers onComponentChange to ensure proper initial state.
-
inline virtual void preTick()#
Called before each tick to prepare sensor state.
Provides an opportunity to prepare the sensor state before the main tick update. Default implementation does nothing.
-
inline virtual void onPhysicsStep(float dt)#
Called during each physics simulation step.
Override this to implement physics-based behavior
- Parameters:
dt – [in] Time step size in seconds
-
inline pxr::UsdPrim getParentPrim()#
Gets the parent prim of the sensor.
Retrieves the USD prim that is the parent of this sensor.
- Returns:
USD prim that is the parent of this sensor.
-
inline virtual void onRenderEvent()#
Called for each rendered frame.
Override this to implement render-specific behavior or visual updates
- inline virtual void updateTimestamp(
- double timeSeconds,
- double dt,
- int64_t timeNano,
Updates the component’s internal timing information.
Maintains synchronized timing state across the component
- Parameters:
timeSeconds – [in] Current simulation time in seconds
dt – [in] Time step size in seconds
timeNano – [in] Current simulation time in nanoseconds
-
inline PrimType &getPrim()#
Retrieves the component’s USD prim.
- Returns:
Reference to the component’s USD prim
-
inline bool getEnabled()#
Checks if the component is enabled.
- Returns:
true if the component is enabled, false otherwise
-
inline uint64_t getSequenceNumber()#
Gets the component’s sequence number.
- Returns:
The component’s sequence number
Public Members
-
bool mDoStart = true#
Flag indicating whether onStart should be called.
Protected Attributes
-
pxr::UsdPrim m_parentPrim#
USD prim that is the parent of this sensor.
Stores a reference to the parent USD prim that contains this sensor.
-
PrimType m_prim#
USD prim reference storing component settings.
-
usdrt::UsdStageRefPtr m_usdrtStage = nullptr#
Runtime USD stage reference.
-
double m_timeSeconds = 0#
Current simulation time in seconds.
-
int64_t m_timeNanoSeconds = 0#
Current simulation time in nanoseconds.
-
double m_timeDelta = 0#
Time delta for current tick in seconds.
-
uint64_t m_sequenceNumber = 0#
Component sequence number for ordering/identification.
-
bool m_enabled = true#
Component enabled state flag.