254
6 Hierarchical Component Models
Fig. 6.63 Optional standard visualizer package
Fig. 6.64 Pictogram
“inverted pendulum on a
cart”
cursor, you can read additional information about creating the desired shape, as
shown in Fig. 6.63.
Let us move on to creating our own components.
Component: Inverted Pendulum on Trolley
Create the component “Inverted pendulum on a cart” (Fig. 6.64).
Using the equations we obtained and connecting the connector and visualizer
libraries, we can write the program code of the inverted pendulum.
model ReversPendulum
parameter Modelica.SIunits.Length l = 0.3 ”thread length”;
parameter Modelica.SIunits.Mass m = 0.2 ”mass of the body”;
parameter Modelica.SIunits.Mass M = 0.5 ”mass of the cart”;
parameter Real b(unit = ”H.s2/m”) = 0.19 ”coefficient of
viscousity”;
parameter Real rad(unit = ”m”) = 0.05 ”radius of the body”;
constant Real pi = 3.1416 ”Pi”;
constant Real g(unit = ”m/s2”) = 9.81;
Real x, xp, yp;
Modelica.Mechanics.MultiBody.Visualizers.Advanced.Shape
thread (shapeType = “cylinder”, length = 2 * l, width = 0.01,
height = 0.01, r = {x, 0, 0},
lengthDirection = {xp - x, yp, 0}, color = {0, 50, 255});
Modelica.Mechanics.MultiBody.Visualizers.Advanced.Shape
bob(shapeType = ”sphere”, length = 2 * rad, width = 2 * rad,
6 Hierarchical Component Models
Fig. 6.63 Optional standard visualizer package
Fig. 6.64 Pictogram
“inverted pendulum on a
cart”
cursor, you can read additional information about creating the desired shape, as
shown in Fig. 6.63.
Let us move on to creating our own components.
Component: Inverted Pendulum on Trolley
Create the component “Inverted pendulum on a cart” (Fig. 6.64).
Using the equations we obtained and connecting the connector and visualizer
libraries, we can write the program code of the inverted pendulum.
model ReversPendulum
parameter Modelica.SIunits.Length l = 0.3 ”thread length”;
parameter Modelica.SIunits.Mass m = 0.2 ”mass of the body”;
parameter Modelica.SIunits.Mass M = 0.5 ”mass of the cart”;
parameter Real b(unit = ”H.s2/m”) = 0.19 ”coefficient of
viscousity”;
parameter Real rad(unit = ”m”) = 0.05 ”radius of the body”;
constant Real pi = 3.1416 ”Pi”;
constant Real g(unit = ”m/s2”) = 9.81;
Real x, xp, yp;
Modelica.Mechanics.MultiBody.Visualizers.Advanced.Shape
thread (shapeType = “cylinder”, length = 2 * l, width = 0.01,
height = 0.01, r = {x, 0, 0},
lengthDirection = {xp - x, yp, 0}, color = {0, 50, 255});
Modelica.Mechanics.MultiBody.Visualizers.Advanced.Shape
bob(shapeType = ”sphere”, length = 2 * rad, width = 2 * rad,
