title: Inverted pendulum angle values in Modelica
body: <p>I want to create a system that will simulate inverted wheel pendulum with moment exchange ilustrated below.</p>
  
  <p><img src="https://i.stack.imgur.com/BRh1Q.jpg" alt="enter image description here"></p>
  
  <p>So far I have a system which consists of three models:</p>
  
  <p><strong>RotationalPendulum.mo</strong></p>
  
  <pre><code>model RotationalPendulum
    import Modelica.SIunits;
    Modelica.Mechanics.Rotational.Interfaces.Flange_a p;
    parameter SIunits.Length L = 1.0;
    parameter SIunits.Mass m = 1.0;
  protected
    SIunits.AngularVelocity omega;
    SIunits.AngularAcceleration alpha;
    parameter SIunits.MomentOfInertia J = m * L ^ 2;
    constant Real g = Modelica.Constants.g_n;
  equation
    // equation to compute p.tau
  end RotationalPendulum;
  </code></pre>
  
  <p><strong>FrictionlessJoint.mo</strong></p>
  
  <pre><code>model FrictionlessJoint
      Modelica.Mechanics.Rotational.Interfaces.Flange_a a;
      Modelica.Mechanics.Rotational.Interfaces.Flange_b b;
  equation
      a.tau = 0;
      b.tau = 0;
  end FrictionlessJoint;
  </code></pre>
  
  <p><strong>PendulumSystem.mo</strong></p>
  
  <pre><code>model PendulumSystem "Simple pendulum"
    RotationalPendulum pend(m = 1, p(phi(start = 1, fixed = true)));
    FrictionlessJoint joint;
    Modelica.Mechanics.Rotational.Components.Fixed fixed;
  equation
    connect(pend.p,joint.a);
    connect(joint.b,fixed.flange);
  end PendulumSystem;
  </code></pre>
  
  <p>In RotationalPendulum.mo model is an equation which should be responsible to compute value of Tau and has this form:</p>
  
  <pre><code>tau=gamma1*sin(q1)+kp*(q2+gamma2*q1)+kv*(d/dt(q2)+gamma2*d/dt(q1))
  </code></pre>
  
  <p>where gamma1, gamma2, kp, kv are constants and q1 = theta1, q2 = (theta1 + theta2). </p>
  
  <p>The problem I have is that I don't know how to get value of theta1 since it's an angle of the rod, but the equation is located in the model of rotational pendulum where I can access only value of theta2 which is p.phi (if I'm not mistaken). Thanks for any ideas and help.</p>