pybullet_planning.interfaces.robots.get_collision_fn

pybullet_planning.interfaces.robots.get_collision_fn(body, joints, obstacles=[], attachments=[], self_collisions=True, disabled_collisions={}, extra_disabled_collisions={}, custom_limits={}, body_name_from_id=None, **kwargs)[source]

get collision checking function collision_fn(joint_values) -> bool. The collision is checked among:

  1. robot self-collision (if self_collisions=True), ignored robot link pairs can be specified in disabled_collisions

  2. between (robot links) and (attached objects)

  3. between (robot links, attached objects) and obstacles

Ignored collisions for (2) and (3) can be specified in extra_disabled_collisions.

Note that:
  • collisions among attached objects are not checked

  • Note: This function might be one of the most heavily used function in this suite and

is very important for planning applications. Backward compatibility (for Caelan’s pybullet-planning (called ss-pybullet before)) is definitely on top priority.

Parameters
  • body (int) – the main moving body (usually the robot). We refer to this body as ‘the main body’ in this function’s docstring.

  • joints (list of int) – moving joint indices for body

  • obstacles (list of int) – body indices for collision objects, by default []

  • attachments (list of Attachment, optional) – list of attachment, by default []

  • self_collisions (bool, optional) – checking self collisions between links of the body or not, by default True

  • disabled_collisions (set of tuples, optional) – list of tuples of two integers, representing the main body’s link indices pair that is ignored in collision checking, by default {}

  • extra_disabled_collisions (set of tuples, optional) –

    list of tuples for specifying disabled collisions, the tuple must be of the following format:

    ((int, int), (int, int)) : (body index, link index), (body index, link index)

    If the body considered is a single-link (floating) body, assign the link index to BASE_LINK. reversing the order of the tuples above is also acceptable, by default {}

  • custom_limits (dict, optional) – customized joint range, example: {joint index (int) : (-np.pi/2, np.pi/2)}, by default {}

Returns

function handle – collision_fn: (conf, diagnosis) -> False if no collision found, True otherwise. if need diagnosis information for the collision, set diagnosis to True will help you visualize which link is colliding to which.