Distance calculation

CoppeliaSim can measure the minimum distance between two measurable entities in a very flexible way. The calculation is an exact minimum distance calculation. The distance calculation module will only measure distances; it does however not directly react to them. Following figure illustrates the distance calculation functionality:

[(1) Minimum distance calculation between two manipulators, (2) Minimum distance calculation between a robot and an obstacle]

The distance calculation module allows registering distance objects which are measurable entity-pairs. During simulation, the minimum distance segment of each registered distance object can then be visualized, or recorded in a graph object. Refer to graphs and graph data stream types for more information about how to record distance objects. Registered distance objects are automatically duplicated (copied) if their two composing entities are duplicated simultaneously in a copy-paste operation.

The distance calculation routines used in the minimum distance calculation module are also available as stand-alone routines via the Coppelia geometric routines.

The distance calculation dialog is part of the calculation module properties dialog, which is located at [Menu bar --> Tools --> Calculation module properties]. You can also open the dialog with a click on its toolbar button:

[Calculation module properties toolbar button]

In the calculation module properties dialog, click the Distance calculation button to display the distance calculation dialog:

[Distance calculation dialog]

  • Enable all distance calculations: allows enabling or disabling distance calculation of all registered distance objects.
  • Add new distance object: allows specifying two entities for distance calculation. The list below the button displays all registered distance objects that can be renamed with a double-click. Individual distance objects in the list can be selected, and related properties are then displayed below (see hereafter).
  • Explicit handling: indicates whether the selected distance object should be explicitly handled. If checked, distance calculation for this distance object will not be handled when sim.handleDistance(sim.handle_all_except_explicit) is called, but only if sim.handleDistance(sim.handle_all) or sim.handleDistance(distanceObjectHandle) is called. This is useful if the user wishes to handle distance measurement for that distance object in a child script rather than in the main script (if not checked, distance calculation for that distance object will be handled twice, once when sim.handleDistance(sim.handle_all_except_explicit) is called in the main script, and once when sim.handleDistance(distanceObjectHandle) is called in the child script). Refer also to the section on explicit and non-explicit calls.
  • Use threshold: a distance threshold can be specified to speed-up calculations when the distance pair entities are far apart and distance doesn't need to be calculated then.
  • Display distance segment: if enabled, then a minimum distance segment of that distance object becomes visible in the scene.
  • Segment width: width of the distance segment.
  • Segment color: allows adjusting the color of the distance segment.

  • Recommended topics

  • Coppelia geometric routines
  • Related API functions
  • Measurable objects
  • Scene objects
  • Collections