BaseRigidContactView#

Fully qualified name: isaacsim::physics::newton::tensors::BaseRigidContactView

class BaseRigidContactView : public IRigidContactView#

Base contact view implementing IRigidContactView for Newton.

Builds sensor-to-body and filter-to-body mapping tables from USD paths. Caches contact data pointers (forces, normals, shape indices, points) from the Newton contacts object, refreshing lazily when the simulation timestamp changes. Pre-allocates scratch buffers for contact counting and indexing.

Subclassed by isaacsim::physics::newton::tensors::CpuRigidContactView, isaacsim::physics::newton::tensors::GpuRigidContactView

Public Functions

BaseRigidContactView(
py::object newtonStage,
const std::vector<std::string> &sensorPaths,
const std::vector<std::vector<std::string>> &filterPaths,
uint32_t maxContactDataCount,
)#

Constructs a BaseRigidContactView.

Parameters:
  • newtonStage – [in] Newton stage object backing the view.

  • sensorPaths – [in] USD prim paths of the contact sensors.

  • filterPaths – [in] Filter paths.

  • maxContactDataCount – [in] Maximum number of contact data entries to report.

~BaseRigidContactView() override#
uint32_t getSensorCount() const override#

Gets the sensor count.

Returns:

The requested value.

uint32_t getFilterCount() const override#

Gets the filter count.

Returns:

The requested value.

uint32_t getMaxContactDataCount() const override#

Gets the maximum contact data count.

Returns:

The requested value.

bool getFrictionData(
const TensorDesc *frictionForceTensor,
const TensorDesc *contactPointTensor,
const TensorDesc *contactCountTensor,
const TensorDesc *contactStartIndicesTensor,
float dt,
) const override#

Gets the friction data.

Parameters:
  • frictionForceTensor – [out] Destination tensor that receives the friction force values.

  • contactPointTensor – [out] Destination tensor that receives the contact point values.

  • contactCountTensor – [out] Destination tensor that receives the contact count values.

  • contactStartIndicesTensor – [out] Destination tensor that receives the contact start indices values.

  • dt – [in] Time step, in seconds.

Returns:

True on success; false otherwise.

void getOtherActorPathsFromIds(
const TensorDesc *otherActorIdsTensor,
std::vector<std::string> &outPaths,
) const override#

Gets the other actor paths from ids.

Parameters:
  • otherActorIdsTensor – [in] Tensor of other-actor identifiers to resolve.

  • outPaths – [out] Receives absolute USD prim paths. Static contacts resolve to the specific contacted shape rather than a synthetic world-body path.

bool check() const override#

Checks whether the view and its backing data are still valid.

Returns:

True on success; false otherwise.

void release() override#

Releases the view and frees its associated resources.

const char *getUsdPrimPath(uint32_t sensorIdx) const override#

Gets the USD prim path.

Parameters:

sensorIdx – [in] Zero-based sensor index within the view.

Returns:

Pointer to the requested null-terminated string, or nullptr if unavailable.

const char *getUsdPrimName(uint32_t sensorIdx) const override#

Gets the USD prim name.

Parameters:

sensorIdx – [in] Zero-based sensor index within the view.

Returns:

Pointer to the requested null-terminated string, or nullptr if unavailable.

const char *getFilterUsdPrimPath(
uint32_t sensorIdx,
uint32_t filterIdx,
) const override#

Gets the filter USD prim path.

Parameters:
  • sensorIdx – [in] Zero-based sensor index within the view.

  • filterIdx – [in] Zero-based filter index within the sensor.

Returns:

Pointer to the requested null-terminated string, or nullptr if unavailable.

const char *getFilterUsdPrimName(
uint32_t sensorIdx,
uint32_t filterIdx,
) const override#

Gets the filter USD prim name.

Parameters:
  • sensorIdx – [in] Zero-based sensor index within the view.

  • filterIdx – [in] Zero-based filter index within the sensor.

Returns:

Pointer to the requested null-terminated string, or nullptr if unavailable.

Protected Functions

void _cacheStaticPointers()#

Caches shape_body pointer (static across simulation lifetime).

void _rebuildBodyMaps()#

Rebuilds sensor/filter body index maps from the current Newton model body labels.

void _refreshContactPointers() const#

Re-reads contact data pointers from Newton if the simulation timestamp has advanced.

The view is bound to the Newton model it was created against; once the stage holds a different (or no) model the view is invalidated for good and has to be recreated.

bool _hasContactForces() const#

Return whether contact-force output was enabled before creating the contacts object.

float _getPhysicsDtScale(float userDt) const#

Gets the physics dt scale.

Parameters:

userDt – [in] User-provided time step, in seconds.

Returns:

The requested value.

Protected Attributes

py::object m_newtonStage#

Newton stage object backing the view.

mutable py::object m_model#

Newton model object the view is bound to; released once invalidated.

mutable bool m_valid = true#

False once the Newton stage rebuilt or released its model.

bool m_contactForcesEnabled = true#

Whether optional contact-force output was requested.

uint32_t m_sensorCount#

Sensor count.

uint32_t m_filterCount#

Filter count.

uint32_t m_maxContactDataCount#

Maximum contact data count.

int m_rigidContactMax#

Rigid contact maximum.

int m_worldBodyIndex#

World body index.

int m_bodyCount#

Body count.

std::vector<std::string> m_sensorPaths#

Sensor paths.

std::vector<std::string> m_sensorNames#

Sensor names.

std::vector<std::vector<std::string>> m_filterPaths#

Filter paths.

std::vector<std::vector<std::string>> m_filterNames#

Filter names.

mutable std::vector<int> m_hostBodySensorMap#

[numBodies] → sensor index, -1 if not a sensor.

mutable std::vector<int> m_hostBodyFilterMap#

[sensorCount * numBodies] → filter index per sensor, -1 if no match.

std::vector<std::string> m_shapeLabels#

Shape labels from the Newton model.

std::vector<int> m_shapeBodyArr#

Shape-to-body index mapping from the Newton model.

mutable int *m_cachedContactCount = nullptr#

Cached pointer to the contact count data.

mutable int *m_cachedShape0 = nullptr#

Cached pointer to the shape 0 data.

mutable int *m_cachedShape1 = nullptr#

Cached pointer to the shape 1 data.

mutable float *m_cachedContactNormal = nullptr#

Cached pointer to the contact normal data.

mutable float *m_cachedContactForce = nullptr#

Cached pointer to the contact force data.

mutable float *m_cachedContactPoint0 = nullptr#

Cached pointer to the contact point 0 data.

mutable float *m_cachedContactPoint1 = nullptr#

Cached pointer to the contact point 1 data.

mutable float *m_cachedThickness0 = nullptr#

Cached pointer to the thickness 0 data.

mutable float *m_cachedThickness1 = nullptr#

Cached pointer to the thickness 1 data.

int *m_cachedShapeBody = nullptr#

Cached pointer to the shape body data.

mutable float *m_cachedBodyQ = nullptr#

Cached pointer to the body q data.

mutable float *m_cachedSpatialForce = nullptr#

Cached pointer to the spatial force data.

mutable bool m_hasSpatialForce = false#

Has spatial force.

std::vector<std::string> m_bodyLabels#

Body labels.

mutable uint64_t m_lastRefreshedGeneration = UINT64_MAX#

Last-seen simulation_timestamp.

float m_physicsDt = 0.0f#

Physics dt from SimulationManager for force-to-impulse scaling.

mutable bool m_contactPointsInWorldSpace = false#

True when contact points are MuJoCo world-space positions.

mutable std::vector<uint32_t> m_scratchCounts#

Scratch counts.

mutable std::vector<uint32_t> m_scratchStartIndices#

Scratch start indices.

mutable std::vector<uint32_t> m_scratchFillCounts#

Scratch fill counts.