BasicAbsoluteAngularVelocity

model BasicAbsoluteAngularVelocity "Basic sensor to measure absolute angular velocity"
    import Modelica.Mechanics.MultiBody.Frames;
    import Modelica.Mechanics.MultiBody.Types.ResolveInFrameA;

    extends Modelica.Mechanics.MultiBody.Sensors.Internal.PartialAbsoluteBaseSensor;

    Modelica.Blocks.Interfaces.RealOutput w[3](each final quantity = "AngularVelocity", each final unit = "rad/s") "Absolute angular velocity vector"
        annotation (Placement(transformation(
            origin = {110, 0},
            extent = {
                {-10, -10}, 
                {10, 10}})));
    parameter Modelica.Mechanics.MultiBody.Types.ResolveInFrameA resolveInFrame = Modelica.Mechanics.MultiBody.Types.ResolveInFrameA.frame_a "Frame in which output vector w is resolved (world, frame_a, or frame_resolve)";
equation
    if resolveInFrame == ResolveInFrameA.world then 
        w = Frames.angularVelocity1(frame_a.R);
    elseif resolveInFrame == ResolveInFrameA.frame_a then 
        w = Frames.angularVelocity2(frame_a.R);
    elseif resolveInFrame == ResolveInFrameA.frame_resolve then 
        w = Frames.resolveRelative(Frames.angularVelocity1(frame_a.R), frame_a.R, frame_resolve.R);
    else 
        assert(false, "Wrong value for parameter resolveInFrame");
        w = zeros(3);
    end if;

    annotation (
        Icon(
            coordinateSystem(
                preserveAspectRatio = true,
                extent = {
                    {-100, -100}, 
                    {100, 100}}),
            graphics = {
                Text(
                    extent = {
                        {62, 48}, 
                        {146, 18}},
                    textString = "w"), 
                Text(
                    extent = {
                        {-130, 76}, 
                        {131, 124}},
                    textString = "%name",
                    lineColor = {0, 0, 255})}),
        Documentation(info = "<html>\n<p>\nThis basic sensor is aimed to be used within advanced sensors where\nthe absolute angular velocity of frame_a should be determined.\nThis vector is provided at the output signal connector&nbsp;<strong>w</strong>.\n</p>\n\n<p>\nVia parameter <strong>resolveInFrame</strong> it is defined, in which frame\nthe angular velocity is resolved:\n</p>\n\n<table border=1 cellspacing=0 cellpadding=2>\n<tr><th><strong>resolveInFrame =<br>Types.ResolveInFrameA.</strong></th><th><strong>Meaning</strong></th></tr>\n<tr><td>world</td>\n    <td>Resolve vector in world frame</td></tr>\n\n<tr><td>frame_a</td>\n    <td>Resolve vector in frame_a</td></tr>\n\n<tr><td>frame_resolve</td>\n    <td>Resolve vector in frame_resolve</td></tr>\n</table>\n\n<p>\nIn this basic sensor model, <strong>the connector frame_resolve\nis always enabled and must be connected</strong>.\nIf resolveInFrame = Types.ResolveInFrameA.frame_resolve, the vector&nbsp;w is\nresolved in the frame to which frame_resolve is connected.\n</p>\n\n<h4>Example</h4>\n<p>\nIf resolveInFrame = Types.ResolveInFrameA.frame_a, the output vector is\ncomputed as:\n</p>\n\n<blockquote><pre>\nw = MultiBody.Frames.angularVelocity2(frame_a.R);\n</pre></blockquote>\n</html>"));
end BasicAbsoluteAngularVelocity;