Skip to content
RelativePositionSensor.md

RelativePositionSensor

Measures the ideal relative translational position between two mechanical flanges.

This component calculates the translational position of flange_b with respect to flange_a. It provides this relative position as an output signal s_rel. The sensor is considered ideal because it does not exert any forces on the flanges it connects to, meaning it does not influence the dynamics of the mechanical system. This is enforced by the equation flange_a.f = 0. The primary relationship is:

srel=flangeb.sflangea.s

where s_{rel} is the relative position, flange_b.s is the absolute position of flange_b, and flange_a.s is the absolute position of flange_a.

This component extends from PartialRelativeSensor

Usage

RelativePositionSensor()

Connectors

  • flange_a - (Flange)

  • flange_b - (Flange)

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

Behavior

0=flange_b.f(t)+flange_a.f(t)s_rel(t)=flange_b.s(t)flange_a.s(t)0=flange_a.f(t)

Source

dyad
# Measures the ideal relative translational position between two mechanical flanges.
#
# This component calculates the translational position of `flange_b` with respect to `flange_a`.
# It provides this relative position as an output signal `s_rel`. The sensor is considered
# ideal because it does not exert any forces on the flanges it connects to, meaning it
# does not influence the dynamics of the mechanical system. This is enforced by the
# equation `flange_a.f = 0`. The primary relationship is:
# ```math
# s_{rel} = flange_b.s - flange_a.s
# ```
# where `s_{rel}` is the relative position, `flange_b.s` is the absolute position of `flange_b`,
# and `flange_a.s` is the absolute position of `flange_a`.
component RelativePositionSensor
  extends PartialRelativeSensor
  # Relative position of `flange_b` relative to `flange_a` as output signal
  s_rel = RealOutput() [{
    "Dyad": {
      "placement": {"icon": {"x1": 450, "y1": 950, "x2": 550, "y2": 1050, "rot": 90}}
    }
  }]
relations
  s_rel = flange_b.s-flange_a.s
  0 = flange_a.f
metadata {
  "Dyad": {"icons": {"default": "dyad://TranslationalComponents/RelativeSensor.svg"}}
}
end
Flattened Source
dyad
# Measures the ideal relative translational position between two mechanical flanges.
#
# This component calculates the translational position of `flange_b` with respect to `flange_a`.
# It provides this relative position as an output signal `s_rel`. The sensor is considered
# ideal because it does not exert any forces on the flanges it connects to, meaning it
# does not influence the dynamics of the mechanical system. This is enforced by the
# equation `flange_a.f = 0`. The primary relationship is:
# ```math
# s_{rel} = flange_b.s - flange_a.s
# ```
# where `s_{rel}` is the relative position, `flange_b.s` is the absolute position of `flange_b`,
# and `flange_a.s` is the absolute position of `flange_a`.
component RelativePositionSensor
  # Negative connection flange of the sensor, often considered the reference point.
  flange_a = Flange() [{"Dyad": {"placement": {"icon": {"x1": -50, "y1": 450, "x2": 50, "y2": 550}}}}]
  # Positive connection flange of the sensor, where the measurement is taken relative to flange_a.
  flange_b = Flange() [{"Dyad": {"placement": {"icon": {"x1": 950, "y1": 450, "x2": 1050, "y2": 550}}}}]
  # Relative position of `flange_b` relative to `flange_a` as output signal
  s_rel = RealOutput() [{
    "Dyad": {
      "placement": {"icon": {"x1": 450, "y1": 950, "x2": 550, "y2": 1050, "rot": 90}}
    }
  }]
relations
  0 = flange_a.f+flange_b.f
  s_rel = flange_b.s-flange_a.s
  0 = flange_a.f
metadata {
  "Dyad": {"icons": {"default": "dyad://TranslationalComponents/RelativeSensor.svg"}}
}
end


Test Cases

This is setup code, that must be run before each test case.

julia
using TranslationalComponents
using ModelingToolkit, OrdinaryDiffEqDefault
using Plots
using CSV, DataFrames

snapshotsdir = joinpath(dirname(dirname(pathof(TranslationalComponents))), "test", "snapshots")
"/home/actions-runner-10/.julia/packages/TranslationalComponents/khJb7/test/snapshots"