---
url: /dyad/stable/stdlib/TranslationalComponents/components/Sensors.RelativePositionSensor.md
description: >-
  Dyad Sensors.RelativePositionSensor docs.  Measures the ideal relative
  translational position between two mechanical flanges.
---

# `Sensors.RelativePositionSensor` {#Sensors.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:

$$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`.

This component extends from [`TranslationalComponents.Interfaces.PartialRelativeSensor`](../types/Interfaces.PartialRelativeSensor.md)

## Usage {#Usage}

`TranslationalComponents.Sensors.RelativePositionSensor()`

## Connectors {#Connectors}

* `flange_a` - This connector represents a mechanical flange with position and force as the potential and flow variables, respectively. ([`Flange`](/stdlib/Dyad/connectors/Flange#Flange))

* `flange_b` - This connector represents a mechanical flange with position and force as the potential and flow variables, respectively. ([`Flange`](/stdlib/Dyad/connectors/Flange#Flange))

* `s_rel` - This connector represents a real signal as an output from a component ([`RealOutput`](/stdlib/Dyad/connectors/RealOutput#RealOutput))

## Behavior {#Behavior}

$$ \begin{align}
0 &= \mathtt{flange_a.f}\left( t \right) + \mathtt{flange_b.f}\left( t \right) \\
\mathtt{s_rel}\left( t \right) &=  - \mathtt{flange_a.s}\left( t \right) + \mathtt{flange_b.s}\left( t \right) \\
0 &= \mathtt{flange_a.f}\left( t \right)
\end{align}
$$

## Source {#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 TranslationalComponents.Interfaces.PartialRelativeSensor
  "Relative position of `flange_b` relative to `flange_a` as output signal"
  s_rel = RealOutput(units = "m") {
    "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"},
    "labels": [{"label": "$(instance)", "layer": "icon", "x": 500, "y": 1198, "rot": 0}]
  }
}
end
````

````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(units = "m") {
    "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"},
    "labels": [{"label": "$(instance)", "layer": "icon", "x": 500, "y": 1198, "rot": 0}]
  }
}
end
````

## Test Cases {#Test-Cases}

No test cases defined.

## Related {#Related}

* Examples

* Experiments

* Analyses

* Tests
  * [`RelativeSensors`](Sensors.RelativePositionSensor.md)
