AbsolutePosition

model AbsolutePosition "Measure absolute position and orientation of the origin of frame connector"
    extends Internal.PartialAbsoluteSensor;

    Modelica.Blocks.Interfaces.RealOutput r[3](final quantity = {"Position", "Position", "Angle"}, final unit = {"m", "m", "rad"}) "Vector of absolute measurements of frame_a on position level, resolved in frame defined by resolveInFrame"
        annotation (Placement(transformation(
            extent = {
                {-10, -10}, 
                {10, 10}},
            origin = {110, 0})));
    Interfaces.Frame_resolve frame_resolve if resolveInFrame == Modelica.Mechanics.MultiBody.Types.ResolveInFrameA.frame_resolve "Coordinate system in which output vector r is optionally resolved"
        annotation (Placement(transformation(
            extent = {
                {-16, -16}, 
                {16, 16}},
            rotation = -90,
            origin = {0, -100})));
    parameter Modelica.Mechanics.MultiBody.Types.ResolveInFrameA resolveInFrame = Modelica.Mechanics.MultiBody.Types.ResolveInFrameA.frame_a "Frame in which output vector r shall be resolved (1: world, 2: frame_a, 3:frame_resolve)";
protected
    Internal.BasicAbsolutePosition position(resolveInFrame = resolveInFrame) annotation (Placement(transformation(extent = {
        {-10, -10}, 
        {10, 10}})));
    Interfaces.ZeroPosition zeroPosition if not resolveInFrame == Modelica.Mechanics.MultiBody.Types.ResolveInFrameA.frame_resolve annotation (Placement(transformation(extent = {
        {20, -40}, 
        {40, -20}})));
equation
    connect(position.r,r) annotation (Line(
        points = {
            {11, 0}, 
            {35.75, 0}, 
            {35.75, 0}, 
            {60.5, 0}, 
            {60.5, 0}, 
            {110, 0}},
        color = {0, 0, 127}));
    connect(position.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(position.frame_resolve,frame_resolve) annotation (Line(
        points = {
            {0, -10}, 
            {0, -32.5}, 
            {0, -32.5}, 
            {0, -55}, 
            {0, -100}, 
            {0, -100}},
        color = {95, 95, 95},
        pattern = LinePattern.Dot));
    connect(zeroPosition.frame_resolve,position.frame_resolve) annotation (Line(
        points = {
            {20, -30}, 
            {0, -30}, 
            {0, -10}},
        color = {95, 95, 95},
        pattern = LinePattern.Dot));

    annotation (
        Icon(
            coordinateSystem(
                preserveAspectRatio = true,
                extent = {
                    {-100, -100}, 
                    {100, 100}}),
            graphics = {
                Line(
                    points = {
                        {70, 0}, 
                        {100, 0}},
                    color = {0, 0, 127}), 
                Text(
                    extent = {
                        {62, 46}, 
                        {146, 16}},
                    textString = "r"), 
                Text(
                    extent = {
                        {15, -67}, 
                        {146, -92}},
                    textColor = {95, 95, 95},
                    textString = "resolve"), 
                Line(
                    points = {
                        {0, -100}, 
                        {0, -70}},
                    pattern = LinePattern.Dot), 
                Text(
                    extent = {
                        {-150, 120}, 
                        {150, 80}},
                    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 absolute position and angle vector [<var>x</var>&nbsp;<var>y</var>&nbsp;<var>&phi;</var>]\nof the origin of <code>frame_a</code> is determined and provided at the output signal\nconnector&nbsp;<code>r</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 = &hellip;</th>\n    <th>Output vector resolved in</th>\n  </tr>\n  <tr>\n    <td valign=\"top\">Types.ResolveInFrameA.world</td>\n    <td valign=\"top\">world frame</td>\n  </tr>\n  <tr>\n    <td valign=\"top\">Types.ResolveInFrameA.frame_a</td>\n    <td valign=\"top\">frame_a</td>\n  </tr>\n  <tr>\n    <td valign=\"top\">Types.ResolveInFrameA.frame_resolve</td>\n    <td valign=\"top\">frame_resolve (must be connected)</td>\n  </tr>\n</table>\n\n<p>\nIf <code>resolveInFrame&nbsp;= Types.ResolveInFrameA.frame_resolve</code>,\nthe conditional connector <code>frame_resolve</code> is enabled\nand&nbsp;<code>r</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.ResolveInFrameA.frame_resolve</code>,\nthe output vector is computed as:\n</p>\n<div>\n<img src=\"modelica://PlanarMechanics/Resources/Images/equations/equation-dcUlfcwL.png\" alt=\"r =transpose([cos(frame_resolve.phi), -sin(frame_resolve.phi), 0; sin(frame_resolve.phi),cos(frame_resolve.phi), 0;0, 0, 1]) * [frame_a.x;frame_a.y;frame_a.phi] - [0;0;frame_resolve.phi]\"/>\n</div>\n</html>"));
end AbsolutePosition;