Contact Sensor Extension [omni.isaac.contact_sensor]¶
The Contact Sensor Extension provides a set of utilities to read Contact data, and set up simulated load sensors.
Basic Usage¶
Setting Up a Sensor¶
First, aquire the sensor interface:
1 2 | from omni.isaac.contact_sensor import _contact_sensor
_cs = _contact_sensor.acquire_contact_sensor_interface()
|
Then, Create a SensorProperties
object, and set the values according to the sensor specifications:
1 2 3 4 5 6 | props = _contact_sensor.SensorProperties()
props.radius = 12 # cover the body tip
props.minThreshold = 0
props.maxThreshold = 1000000000000
props.sensorPeriod = 1 / 100.0
props.position = carb.Float3(40, 0, 0) # Offset sensor 40cm in X direction from rigid body center
|
Finally, add it to the desired rigid body using its prim path:
1 | sensor_handle = _cs.add_sensor_on_body("/path/to/rigid_body", props)
|
To collect the readings, call the interface get_sensor_sim_reading. the result will be the accumulated readings since last time the sensor was read. Each reading is timestamped, and contains a boolean flag to tell if the sensor is triggered.
1 | readings = _cs.get_sensor_readings(sensor_handle)
|
Acquiring Extension Interface¶
-
_contact_sensor.
acquire_contact_sensor_interface
(plugin_name: str = None, library_path: str = None) → omni::isaac::contact_sensor::ContactSensorInterface¶ Acquire Contact Sensor interface. This is the base object that all of the Contact Sensor functions are defined on
-
_contact_sensor.
release_contact_sensor_interface
(arg0: omni::isaac::contact_sensor::ContactSensorInterface) → None¶ Release Contact Sensor interface. Generally this does not need to be called, the Contact Sensor interface is released on extension shutdown
Contact Sensor API¶
Input Types¶
-
class
SensorProperties
¶ Sensor Properties
-
property
maxThreshold
¶ Maximum force that the sensor can register. Forces above this value will be clamped. (
float
)
-
property
minThreshold
¶ Minimum force that the sensor can read. Forces below this value will not trigger a reading. (
float
)
-
property
position
¶ Position relative to the parent body where the sensor is placed. (
carb.Float3
)
-
property
radius
¶ Sensor radius. Negative values indicate it’s a full body sensor. (
float
)
-
property
sensorPeriod
¶ Sensor reading period in seconds. zero means sync with simulation timestep (
float
)
-
property
Output Types¶
-
class
SensorReading
¶ Sensor Reading
-
property
inContact
¶ boolean that flags if the sensor registers a contact. (
bool
)
-
property
time
¶ timestamp of the reading, in seconds . (
float
)
-
property
value
¶ sensor force reading value. (
float
)
-
property
-
class
CsRawData
¶ Contact Raw Data
-
property
body0
¶ Body 0 name handle, (
int
)
-
property
body1
¶ Body 1 name handle, (
int
)
-
property
dt
¶ timestep during this contact report, (
float
)
-
property
impulse
¶ impulse, global coordinates , (
carb.Float3
)
-
property
normal
¶ normal, global coordinates , (
carb.Float3
)
-
property
position
¶ position, global coordinates, (
carb.Float3
)
-
property
time
¶ simulation timestamp, (
float
)
-
property
Interface Methods¶
-
class
ContactSensorInterface
¶ -
add_sensor_on_body
(self: omni.isaac.contact_sensor._contact_sensor.ContactSensorInterface, arg0: str, arg1: omni.isaac.contact_sensor._contact_sensor.SensorProperties) → int¶ - Parameters
arg0 (
SensorProperties
) – the sensor properties- Returns
The sensor handle
- Return type
int
-
decode_body_name
(self: omni.isaac.contact_sensor._contact_sensor.ContactSensorInterface, arg0: int) → str¶ Decodes the body name pointers from the contact raw data into a string :param arg0: body name handle :type arg0:
int
- Returns
The body name.
- Return type
str
-
get_body_contact_raw_data
(self: omni.isaac.contact_sensor._contact_sensor.ContactSensorInterface, arg0: str) → object¶ - Parameters
arg0 (
str
) – USD Path to body as string- Returns
The list of contact raw data that contains the specified body.
- Return type
numpy.array
-
get_num_sensors_on_body
(self: omni.isaac.contact_sensor._contact_sensor.ContactSensorInterface, arg0: str) → int¶ Gets the number of sensors that were attached to the given body. :param arg0: USD Path to body as string :type arg0:
str
- Returns
The number of sensors attached to body.
- Return type
int
-
get_sensor_readings
(self: omni.isaac.contact_sensor._contact_sensor.ContactSensorInterface, arg0: int) → object¶ Gets the list of sensor readings for the given sensor. Clears the reading buffer once values are acquired. :param arg0: the sensor handle :type arg0:
int
- Returns
The list of readings for the sensor ready on the buffer.
- Return type
numpy.array
-
get_sensor_readings_size
(self: omni.isaac.contact_sensor._contact_sensor.ContactSensorInterface, arg0: int) → int¶ Gets the number of readings ready on the buffer :param arg0: the sensor handle :type arg0:
int
- Returns
Number of readings ready on the buffer.
- Return type
int
-
get_sensor_sim_reading
(self: omni.isaac.contact_sensor._contact_sensor.ContactSensorInterface, arg0: int) → omni.isaac.contact_sensor._contact_sensor.SensorReading¶ - Parameters
arg0 (
int
) – the sensor handle- Returns
The reading for the current simulation time.
- Return type
numpy.array
-
get_sensors_on_body
(self: omni.isaac.contact_sensor._contact_sensor.ContactSensorInterface, arg0: str) → object¶ Gets the list of sensor handles attached to a given body. :param arg0: USD Path to body as string :type arg0:
str
- Returns
The list of sensor handles on a body.
- Return type
numpy.array
-
remove_sensor
(self: omni.isaac.contact_sensor._contact_sensor.ContactSensorInterface, arg0: int) → bool¶ - Parameters
arg0 (
int
) – the sensor handle- Returns
True if succesful, False otherwise.
- Return type
boolean
-