Skip to content
LIBRARY
Distance.md

Distance

Measures the Euclidean distance between the origins of two frame connectors.

Frame-invariant scalar: no resolve_in_frame is needed. A small regularization parameter s_small provides a smooth (differentiable) extension near zero distance, avoiding the sqrt derivative singularity there.

This is a sensor: no forces or torques are exerted.

Usage

MultibodyComponents.Distance(s_small=1e-10)

Parameters:

NameDescriptionUnitsDefault value
s_smallDistance threshold below which a smooth quadratic replaces sqrt, avoiding the derivative singularity at zero distancem1e-10

Connectors

  • frame_a - Frame3D is the fundamental 3D connector used for 6DOF motion. Most components have one or several Frame

connectors that can be connected together (Frame3D)

  • frame_b - Frame3D is the fundamental 3D connector used for 6DOF motion. Most components have one or several Frame

connectors that can be connected together (Frame3D)

  • distance - This connector represents a real signal as an output from a component (RealOutput)

Variables

NameDescriptionUnits
L2Squared distance between the frame_a and frame_b origins

Behavior

Dict{MIME{Symbol("text/plain")}, String} with 1 entry: MIME type text/plain => "Error displaying result"

Source

dyad
"""
Measures the Euclidean distance between the origins of two frame connectors.

Frame-invariant scalar: no `resolve_in_frame` is needed. A small regularization
parameter `s_small` provides a smooth (differentiable) extension near zero
distance, avoiding the `sqrt` derivative singularity there.

This is a sensor: no forces or torques are exerted.
"""
component Distance
  frame_a = Frame3D() {
    "Dyad": {
      "placement": {
        "diagram": {"iconName": "default", "x1": -50, "y1": 450, "x2": 50, "y2": 550, "rot": 0}
      },
      "tags": []
    }
  }
  frame_b = Frame3D() {
    "Dyad": {
      "placement": {
        "diagram": {"iconName": "default", "x1": 950, "y1": 450, "x2": 1050, "y2": 550, "rot": 0}
      },
      "tags": []
    }
  }
  distance = RealOutput() {
    "Dyad": {
      "placement": {"diagram": {"x1": 450, "y1": 1000, "x2": 550, "y2": 1100, "rot": 90}}
    }
  }
  "Distance threshold below which a smooth quadratic replaces sqrt, avoiding the derivative singularity at zero distance"
  parameter s_small::Length = 1e-10
  "Squared distance between the frame_a and frame_b origins"
  variable L2::Real
relations
  frame_a.f = [0, 0, 0]
  frame_a.tau = [0, 0, 0]
  frame_b.f = [0, 0, 0]
  frame_b.tau = [0, 0, 0]
  L2 = dot(frame_b.r_0 - frame_a.r_0, frame_b.r_0 - frame_a.r_0)
  distance = ifelse(L2 > s_small ^ 2, sqrt(L2), L2 / (2 * s_small) * (3 - L2 / s_small ^ 2))
metadata {
  "Dyad": {
    "icons": {"default": "dyad://MultibodyComponents/TwoFrameSensor.svg"},
    "labels": [
      {
        "label": "$(instance)",
        "x": 500,
        "y": 150,
        "rot": 0,
        "attrs": {"font-size": "140"}
      },
      {"label": "distance", "x": 500, "y": 680, "rot": 0}
    ]
  }
}
end
Flattened Source
dyad
"""
Measures the Euclidean distance between the origins of two frame connectors.

Frame-invariant scalar: no `resolve_in_frame` is needed. A small regularization
parameter `s_small` provides a smooth (differentiable) extension near zero
distance, avoiding the `sqrt` derivative singularity there.

This is a sensor: no forces or torques are exerted.
"""
component Distance
  frame_a = Frame3D() {
    "Dyad": {
      "placement": {
        "diagram": {"iconName": "default", "x1": -50, "y1": 450, "x2": 50, "y2": 550, "rot": 0}
      },
      "tags": []
    }
  }
  frame_b = Frame3D() {
    "Dyad": {
      "placement": {
        "diagram": {"iconName": "default", "x1": 950, "y1": 450, "x2": 1050, "y2": 550, "rot": 0}
      },
      "tags": []
    }
  }
  distance = RealOutput() {
    "Dyad": {
      "placement": {"diagram": {"x1": 450, "y1": 1000, "x2": 550, "y2": 1100, "rot": 90}}
    }
  }
  "Distance threshold below which a smooth quadratic replaces sqrt, avoiding the derivative singularity at zero distance"
  parameter s_small::Length = 1e-10
  "Squared distance between the frame_a and frame_b origins"
  variable L2::Real
relations
  frame_a.f = [0, 0, 0]
  frame_a.tau = [0, 0, 0]
  frame_b.f = [0, 0, 0]
  frame_b.tau = [0, 0, 0]
  L2 = dot(frame_b.r_0 - frame_a.r_0, frame_b.r_0 - frame_a.r_0)
  distance = ifelse(L2 > s_small ^ 2, sqrt(L2), L2 / (2 * s_small) * (3 - L2 / s_small ^ 2))
metadata {
  "Dyad": {
    "icons": {"default": "dyad://MultibodyComponents/TwoFrameSensor.svg"},
    "labels": [
      {
        "label": "$(instance)",
        "x": 500,
        "y": 150,
        "rot": 0,
        "attrs": {"font-size": "140"}
      },
      {"label": "distance", "x": 500, "y": 680, "rot": 0}
    ]
  }
}
end


Test Cases

No test cases defined.