irsim.world.sensors.contact2d#

Classes#

Contact2D

Contact sensor of one object: what the contact step recorded about it

Module Contents#

class irsim.world.sensors.contact2d.Contact2D(state: numpy.ndarray | None = None, obj_id: int = 0, force_scale: float = 0.05, marker_size: float = 6.0, linewidth: float = 1.5, alpha: float = 0.9, **kwargs)[源代码]#

Contact sensor of one object: what the contact step recorded about it (collision_mode: contact only), as a contact sensor mounted on the object reports.

Every object carries one as obj.contact, written by the environment and the contact solver, so its readings are always available: obj.contact.in_contact, partners, reports, force, contact_time, air_time, started and ended. Listing it under the object's sensors as type: 'contact2d' makes that one the object's sensor and draws it: a marker at each contact point and a line along the contact normal whose length is the contact force times force_scale.

参数:
  • state (np.ndarray) -- Initial state of the object [x, y, theta], kept for the common sensor interface; the readings do not depend on it.

  • obj_id (int) -- ID of the associated object.

  • force_scale (float) -- Length of the drawn force line per newton, in meters. Default 0.05.

  • marker_size (float) -- Size of the contact point markers. Default 6.

  • linewidth (float) -- Width of the force lines. Default 1.5.

  • alpha (float) -- Transparency of the drawing. Default 0.9.

  • **kwargs -- plot sub-dict (preferred) with the visualization options above and color (default: the palette marker color), plus the name / type key of the YAML entry.

变量:
  • sensor_type (str) -- "contact2d".

  • parent (ObjectBase) -- The object the sensor is mounted on.

  • in_contact (bool) -- Whether a contact was resolved against parent in the last step.

  • partners (list) -- The objects parent touched in the last step, each once.

  • records (list[Contact]) -- The contact records of the last step, in the solver's order.

  • force (np.ndarray) -- Net world-frame contact force (2, 1) on parent in the last step, in newtons.

  • contact_time (float) -- Seconds parent has been touching something.

  • air_time (float) -- Seconds parent has been free; one of the two timers runs while the other is held at zero.

  • started (bool) -- Whether the last step began a contact.

  • ended (bool) -- Whether the last step ended one.

sensor_type = 'contact2d'#
obj_id = 0#
parent: irsim.world.object_base.ObjectBase | None = None#
force_scale#
marker_size#
linewidth#
alpha#
color#
in_contact = False#
partners: list[Any] = []#
records: list[irsim.lib.algorithm.contact.Contact] = []#
force#
contact_time = 0.0#
air_time = 0.0#
started = False#
ended = False#
property reports: list[irsim.lib.algorithm.contact.ContactReport]#

Last step's contacts seen from parent's side.

clear() → None[源代码]#

Forget last step's contacts: flag, partners, records and force.

reset() → None[源代码]#

Forget everything, the timers included, as at the start of a run.

add(contact: irsim.lib.algorithm.contact.Contact) → None[源代码]#

Record a contact the solver resolved against parent.

add_force(force_xy: numpy.ndarray) → None[源代码]#

Accumulate a world-frame force (2,) or (2, 1) on parent.

tick(step_time: float) → None[源代码]#

Advance contact_time or air_time by one step and raise started or ended for a step that switched between them.

step(state: numpy.ndarray) → None[源代码]#

Keep the sensor state; the readings are written by the contact step.

plot(ax, state: numpy.ndarray | None = None, **kwargs) → None[源代码]#

Draw the contact points and force lines on a given axis.

Nothing is drawn on a 3D axis, since contacts are planar.

step_plot() → None[源代码]#

Move the markers and force lines to the last step's contacts.

plot_clear() → None[源代码]#

Remove the drawing from the axis.