---
url: /dyad/stable/stdlib/MultibodyComponents/components/PlanarMechanics.RelativePosition.md
description: >-
  Dyad PlanarMechanics.RelativePosition docs.  Measures relative position and
  orientation between the origins of two frame connectors.
---

# `PlanarMechanics.RelativePosition` {#PlanarMechanics.RelativePosition}

Measures relative position and orientation between the origins of two frame connectors.

Computes frame_b - frame_a. This is a sensor component: it reads kinematic quantities without exerting forces. Use `connect` to attach to body frames (sensor forces are zero, so the force balance is unaffected).

This component extends from [`PartialTwoFrameSensor`](../types/PartialTwoFrameSensor.md)

## Usage {#Usage}

`MultibodyComponents.PlanarMechanics.RelativePosition()`

## Parameters: {#Parameters:}

|               Name | Description | Units |             Default value |
| ------------------:| -----------:| -----:| -------------------------:|
| `resolve_in_frame` |             |     – | MultibodyCo...me.FrameA() |

## Connectors {#Connectors}

* `frame_a` - Coordinate system (2-dim.) fixed to the component with one cut-force and cut-torque.

All variables are resolved in the planar world frame. ([`Frame2D`](/stdlib/Dyad/connectors/Frame2D#Frame2D))

* `frame_b` - Coordinate system (2-dim.) fixed to the component with one cut-force and cut-torque.

All variables are resolved in the planar world frame. ([`Frame2D`](/stdlib/Dyad/connectors/Frame2D#Frame2D))

* `frame_resolve` - Coordinate system (2-dim.) fixed to the component with one cut-force and cut-torque.

All variables are resolved in the planar world frame. ([`Frame2D`](/stdlib/Dyad/connectors/Frame2D#Frame2D))

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

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

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

## Behavior {#Behavior}

## Source {#Source}

```dyad
"""
Measures relative position and orientation between the origins of two frame connectors.

Computes frame_b - frame_a. This is a sensor component: it reads kinematic quantities
without exerting forces. Use `connect` to attach to body frames (sensor forces are zero,
so the force balance is unaffected).
"""
component RelativePosition
  extends PartialTwoFrameSensor
  frame_resolve = Frame2D() if resolve_in_frame == MultibodyComponents.ResolveInFrame.FrameResolve() {
    "Dyad": {
      "placement": {
        "diagram": {"iconName": "default", "x1": 450, "y1": -50, "x2": 550, "y2": 50, "rot": 0}
      },
      "tags": []
    }
  }
  "Relative x-position"
  rel_x = RealOutput() {
    "Dyad": {
      "placement": {
        "diagram": {"iconName": "default", "x1": 120, "y1": 960, "x2": 220, "y2": 1060, "rot": 90}
      },
      "tags": []
    }
  }
  "Relative y-position"
  rel_y = RealOutput() {
    "Dyad": {
      "placement": {
        "diagram": {"iconName": "default", "x1": 450, "y1": 960, "x2": 550, "y2": 1060, "rot": 90}
      },
      "tags": []
    }
  }
  "Relative rotation angle (counterclockwise)"
  rel_phi = RealOutput() {
    "Dyad": {
      "placement": {
        "diagram": {"iconName": "default", "x1": 780, "y1": 960, "x2": 880, "y2": 1060, "rot": 90}
      },
      "tags": []
    }
  }
  pos = BasicRelativePosition(resolve_in_frame = resolve_in_frame)
  structural parameter resolve_in_frame::MultibodyComponents.ResolveInFrame = MultibodyComponents.ResolveInFrame.FrameA()
relations
  connect(frame_a, pos.frame_a)
  connect(frame_b, pos.frame_b)
  if resolve_in_frame == MultibodyComponents.ResolveInFrame.FrameResolve()
    connect(frame_resolve, pos.frame_resolve)
  end
  rel_x = pos.rel_x
  rel_y = pos.rel_y
  rel_phi = pos.rel_phi
metadata {
  "Dyad": {
    "icons": {"default": "dyad://MultibodyComponents/TwoFrameSensor.svg"},
    "labels": [{"label": "rel pos", "x": 500, "y": 680, "rot": 0}]
  }
}
end
```

```dyad
"""
Measures relative position and orientation between the origins of two frame connectors.

Computes frame_b - frame_a. This is a sensor component: it reads kinematic quantities
without exerting forces. Use `connect` to attach to body frames (sensor forces are zero,
so the force balance is unaffected).
"""
component RelativePosition
  frame_a = Frame2D() {
    "Dyad": {
      "placement": {
        "diagram": {"iconName": "default", "x1": 50, "y1": 450, "x2": 150, "y2": 550, "rot": 0}
      },
      "tags": []
    }
  }
  frame_b = Frame2D() {
    "Dyad": {
      "placement": {
        "diagram": {"iconName": "default", "x1": 850, "y1": 450, "x2": 950, "y2": 550, "rot": 0}
      },
      "tags": []
    }
  }
  frame_resolve = Frame2D() if resolve_in_frame == MultibodyComponents.ResolveInFrame.FrameResolve() {
    "Dyad": {
      "placement": {
        "diagram": {"iconName": "default", "x1": 450, "y1": -50, "x2": 550, "y2": 50, "rot": 0}
      },
      "tags": []
    }
  }
  "Relative x-position"
  rel_x = RealOutput() {
    "Dyad": {
      "placement": {
        "diagram": {"iconName": "default", "x1": 120, "y1": 960, "x2": 220, "y2": 1060, "rot": 90}
      },
      "tags": []
    }
  }
  "Relative y-position"
  rel_y = RealOutput() {
    "Dyad": {
      "placement": {
        "diagram": {"iconName": "default", "x1": 450, "y1": 960, "x2": 550, "y2": 1060, "rot": 90}
      },
      "tags": []
    }
  }
  "Relative rotation angle (counterclockwise)"
  rel_phi = RealOutput() {
    "Dyad": {
      "placement": {
        "diagram": {"iconName": "default", "x1": 780, "y1": 960, "x2": 880, "y2": 1060, "rot": 90}
      },
      "tags": []
    }
  }
  pos = BasicRelativePosition(resolve_in_frame = resolve_in_frame)
  structural parameter resolve_in_frame::MultibodyComponents.ResolveInFrame = MultibodyComponents.ResolveInFrame.FrameA()
relations
  connect(frame_a, pos.frame_a)
  connect(frame_b, pos.frame_b)
  if resolve_in_frame == MultibodyComponents.ResolveInFrame.FrameResolve()
    connect(frame_resolve, pos.frame_resolve)
  end
  rel_x = pos.rel_x
  rel_y = pos.rel_y
  rel_phi = pos.rel_phi
metadata {
  "Dyad": {
    "icons": {"default": "dyad://MultibodyComponents/TwoFrameSensor.svg"},
    "labels": [{"label": "rel pos", "x": 500, "y": 680, "rot": 0}]
  }
}
end
```

## Test Cases {#Test-Cases}

No test cases defined.

## Related {#Related}

* Examples

* Experiments

* Analyses

* Tests
  * [`SensorsTest`](PlanarMechanics.RelativePosition.md)
