model RelativePosition "Measure relative position and orientation between the origins of two frame connectors"
extends Internal.PartialRelativeSensor;
Modelica.Blocks.Interfaces.RealOutput r_rel[3](final quantity = {"Position", "Position", "Angle"}, final unit = {"m", "m", "rad"}) "Vector of relative measurements from frame_a to frame_b on position level, resolved in frame defined by resolveInFrame"
annotation (Placement(transformation(
extent = {
{-10, -10},
{10, 10}},
rotation = -90,
origin = {0, -110})));
Interfaces.Frame_resolve frame_resolve if resolveInFrame == Modelica.Mechanics.MultiBody.Types.ResolveInFrameAB.frame_resolve "Coordinate system in which r_rel is optionally resolved"
annotation (Placement(
transformation(extent = {
{84, 64},
{116, 96}}),
iconTransformation(extent = {
{84, 65},
{116, 97}})));
parameter Modelica.Mechanics.MultiBody.Types.ResolveInFrameAB resolveInFrame = Modelica.Mechanics.MultiBody.Types.ResolveInFrameAB.frame_a "Frame in which output vector r_rel shall be resolved (1: world, 2: frame_a, 3: frame_b, 4: frame_resolve)";
protected
Internal.BasicRelativePosition relativePosition(resolveInFrame = resolveInFrame) annotation (Placement(transformation(extent = {
{-10, -10},
{10, 10}})));
Interfaces.ZeroPosition zeroPosition if not resolveInFrame == Modelica.Mechanics.MultiBody.Types.ResolveInFrameAB.frame_resolve annotation (Placement(transformation(extent = {
{52, 20},
{72, 40}})));
equation
connect(relativePosition.frame_a,frame_a) annotation (Line(
points = {
{-10, 0},
{-32.5, 0},
{-32.5, 0},
{-55, 0},
{-55, 0},
{-100, 0}},
color = {95, 95, 95},
thickness = 0.5));
connect(relativePosition.frame_b,frame_b) annotation (Line(
points = {
{10, 0},
{32.5, 0},
{32.5, 0},
{55, 0},
{55, 0},
{100, 0}},
color = {95, 95, 95},
thickness = 0.5));
connect(relativePosition.r_rel,r_rel) annotation (Line(
points = {
{0, -11},
{0, -35.75},
{0, -35.75},
{0, -60.5},
{0, -60.5},
{0, -110}},
color = {0, 0, 127}));
connect(relativePosition.frame_resolve,frame_resolve) annotation (Line(
points = {
{10, 8.1},
{26, 8.1},
{26, 8},
{36, 8},
{36, 80},
{100, 80}},
color = {95, 95, 95},
pattern = LinePattern.Dot));
connect(zeroPosition.frame_resolve,relativePosition.frame_resolve) annotation (Line(
points = {
{52, 30},
{36, 30},
{36, 8.1},
{10, 8.1}},
color = {95, 95, 95},
pattern = LinePattern.Dot));
annotation (
Icon(
coordinateSystem(
preserveAspectRatio = true,
extent = {
{-100, -100},
{100, 100}}),
graphics = {
Line(
points = {
{0, -70},
{0, -100}},
color = {0, 0, 127}),
Text(
extent = {
{18, -80},
{102, -110}},
textString = "r_rel"),
Text(
extent = {
{-150, 140},
{150, 100}},
textString = "%name",
textColor = {0, 0, 255})}),
Documentation(
revisions = "<html>\n<p>\n<img src=\"modelica://PlanarMechanics/Resources/Images/dlr_logo.png\" alt=\"DLR logo\">\n<strong>Developed 2010 at the DLR Institute of System Dynamics and Control</strong>\n</p>\n</html>",
info = "<html>\n<p>\nThe relative position and angle vector [<var>x</var> <var>y</var> <var>φ</var>]\nbetween the origins of <code>frame_a</code> and of <code>frame_b</code>\nare determined and provided at the output signal connector <code>r_rel</code>.\n</p>\n<p>\nVia parameter <code>resolveInFrame</code> it is defined, in which frame\nthe position vector is resolved.\n</p>\n\n<table border=\"1\" cellspacing=\"0\" cellpadding=\"2\">\n <caption align=\"bottom\">Options of parameter <strong>resolveInFrame</strong></caption>\n <tr>\n <th>resolveInFrame = …</th>\n <th>Output vector resolved in</th>\n </tr>\n <tr>\n <td valign=\"top\">Types.ResolveInFrameAB.world</td>\n <td valign=\"top\">world frame</td>\n </tr>\n <tr>\n <td valign=\"top\">Types.ResolveInFrameAB.frame_a</td>\n <td valign=\"top\">frame_a</td>\n </tr>\n <tr>\n <td valign=\"top\">Types.ResolveInFrameAB.frame_b</td>\n <td valign=\"top\">frame_b</td>\n </tr>\n <tr>\n <td valign=\"top\">Types.ResolveInFrameAB.frame_resolve</td>\n <td valign=\"top\">frame_resolve (must be connected)</td>\n </tr>\n</table>\n\n<p>\nIf <code>resolveInFrame = Types.ResolveInFrameAB.frame_resolve</code>,\nthe conditional connector <code>frame_resolve</code> is enabled\nand <code>r_rel</code> is resolved in the frame, to which\n<code>frame_resolve</code> is connected.\nNote, if this connector is enabled, it must be connected.\n</p>\n<p>\nExample: If <code>resolveInFrame = Types.ResolveInFrameAB.frame_resolve</code>,\nthe output vector is computed as:\n</p>\n<div>\n<img src=\"modelica://PlanarMechanics/Resources/Images/equations/equation-LrRs4SXG.png\" alt=\"r_rel = transpose([cos(frame_resolve.phi), -sin(frame_resolve.phi), 0; sin(frame_resolve.phi),cos(frame_resolve.phi), 0;0,0,1]) * [frame_b.x - frame_a.x;frame_b.y - frame_a.y;frame_b.phi - frame_a.phi]\"/>\n</div>\n</html>"));
end RelativePosition;