3D Visualization of Mechatronic Sytems Using OpenGL
3D Visualization of Mechatronic Sytems Using OpenGL
net/publication/303718978
CITATIONS READS
0 3,857
3 authors, including:
All content following this page was uploaded by Jakub Čerkala on 01 June 2016.
Abstract — The main goal of this article is to show how to visualize dynamical processes in 3D
environment on the example of nonlinear mathematical pendulum and mobile robot with
differential chassis. Using Matlab or Simulink, by the solution of the model’s differential equations,
which describe its movement properties, it is possible to obtain data for visualization. The article
presents the necessary steps to create an own C# Forms application that is based on OpenGL for
visualization of dynamical system.
I. INTRODUCTION
The computer technology is evolving fast nowadays and it helps us to simplify our daily life.
This development includes also the computer graphics technology, which is extensively used in
various fields, such as entertainment or science. In entertainment, the computer graphics is used
to create video games or the special effects in movies, but in fields of science, it is mainly used
to visualize data. Depending on data, the visualization can by static (image, chart) or dynamic
(animation) and it can be done in 2D or 3D space. This article focuses on visualization of
dynamical systems presented on the example of mathematical pendulum and mobile robot with
differential chassis in three dimensional space. The first step in visualization is the selection of
data source. If we don’t have data measured on real system, we can calculate an approximation
data using mathematical model of selected dynamic system based on physical laws and
mathematics. Moreover, we need 3D models that are used for the data visualization as an
animation. There are several approaches to visualize data, for example by using programs like
Matlab/Simulink [1], [2], which offers a complete solution for dynamical visualization. With
Matlab/Simulink, we can calculate visualization data using simulation models of the chosen
dynamical systems and with the Simulink 3D Animation toolbox [3] we can create complete
visualization with 3D models. There is always an option to create a specialized application
which can visualize dynamical systems that is using a graphical library in chosen programming
language. In this case, the data can be obtained by using external computation in programs like
Matlab/Simulink or by an internal calculation, for example using the Runge – Kutta 4th order
method. This approach requires more programming but it gives the programmer more freedom.
351
Electrical Engineering and Informatics VI
Proceedings of the Faculty of Electrical Engineering and Informatics of the Technical University of Košice
The sum of the forces which are acting on the object is equal with the mass of the object
multiplied by the acceleration of the object. The mathematical equation of this law can be
written as
F ma. (1)
To solve the mathematical pendulum equation of motion we need to calculate the sum of forces
F which are acting on the bob and the bob’s acceleration a. As shown on Fig. 2, the only force
that is acting on the pendulum’s bob is the gravitational force Fg. Because the bob is moving
along the circular arc, we can divide the gravitational force Fg into two components. The first
component of the gravitational force Fcos is parallel to the rod of the pendulum and it doesn’t
affect the pendulum movement. The second component of the gravitational force Fsin is
perpendicular to the pendulum’s rod so it affects the pendulum’s movement [7] and therefore it
can be assumed as F in (1). To calculate the bob’s acceleration a, the second derivation of the
arc’s length s on which the pendulum’s bob moves has to be used. The arc’s length s can be
calculated by multiplication of the pendulum l length with an angular lean , the angular
acceleration of the bob is obtained as [7]
d 2 t a
. (2)
dt 2 l
If we assume that Fsin mg sin t , then we can use the Newton’s second law (1) to get the
following 2nd order differential equations for motion of the mathematical pendulum [8]
d 2 t g
sin t 0 . (3)
dt 2 l
The force acting on the pendulum have always the opposite direction as the angular lean of the
pendulum, that’s why the pendulum is always returning to its vertical position [7]. In case of
damped pendulum, the damping force can be included as [9]
Fd k t , (4)
where k is the damping constant and is the pendulum’s angular velocity that is equal to the
first time derivation of the pendulum’s angular lean [7]. The 2nd order motion differential
equation of the mathematical pendulum with damping force can be written as two 1st order
differential equation for easier numerical implementation as
d t
t , (5)
dt
d t g
sin t k t (6)
dt l
The mathematical model of the mobile robot usually consists of the kinematic model, that
converts robot’s velocities into position and the dynamic model, which represents the influences
of mass, inertia or friction on resulting velocities. In this case, we use only the kinematics
model defined for angular velocities R (t ) , L (t ) that can be written as [10]
r cos (t ) r cos (t )
x (t )
2 2
r sin (t ) r sin (t )
y (t )
d 2 2 R (t )
r r . (7)
dt
(t ) L (t )
2b 2b
(t ) 1 0
R
L (t ) 0 1
simulation result of the mathematical pendulum without damping force is shown on Fig. 4 and
the Fig. 5 shows the obtained data of the mathematical pendulum with damping force.
Fig. 4 The pendulum’s angular deflection without damping force simulated in Matlab
Fig. 5 The pendulum’s angular deflection with damping force simulated in Matlab
The mathematical model of the pendulum (6) can be implemented also as Simulink model. The
simulation results are the same as in previous approach, however the Simulink environment
enables user to change the parameters or simulation properties with minimum input. The
obtained plots that describe the pendulum motion are clear.
Simulation model of mobile robot with differential chassis implemented in Simulink based
on its kinematics (7) can be tested for non-equal input wheel velocities ωR ≠ ωL and the
simulation experiment shown on Fig. 6 presents the movement results.
The movement of the robot is usually shown in plane. But there is no clear information about
the velocities of the robot, its orientation or number of preformed loops. It is unpractical to
independently plot all five position variables [x(t), y(t), φ(t), θR(t), θL(t)]T in term of time,
however the visualization can show them at once in user-friendly form.
VI. VISUALIZATION
To be able to visualize the movement of the models, it is necessary to create a 3D environment
that can import and interpret the data. The key features of the visualization are the camera,
model and the animation loop.
1) Camera
The cameras in a three-dimensional computer graphics play an important role. They are used to
observe the visualization from a freely chosen position and they are used for the projection of
the scene. The projection output image of from the perspective of the camera view. In presented
application, a basic camera was created. This camera has unrestricted movement in 3D
environment and can observe the 3D environment from every perspective.
The possibilities of camera movement are depicted on Fig. 7, the flying camera have
unrestricted movement in the x, y axis and can rotate on axis y and x. When rotating around the
axis z, the only restriction is applied - the camera cannot turn more than 90 degrees up and
down. These restrictions of the rotation around the axis z are important to prevent the camera to
flip upside down.
2) 3D models
3D models are used to show the data during visualization. Three-dimensional models are
created by polygons which are defined by vertices. The combination of polygons will create a
network of polygons, a mesh, which can contain different types of polygons, but the most
common polygon is a triangle - the triangles can be used to create any other existing types of
polygons. For more complex models it is always better to work with more polygons to achieve
a better model accuracy.
For visualization of the mathematical pendulum, we had to create a 3D model of the pendulum.
The 3D model of a mathematical pendulum consists of a static mount, rod and weight. The rod
connects the static mount and weight of the pendulum. The pendulum’s rod is dynamic - its size
is changed according to the length of the pendulum used in simulation. The rod and the weight
are connected and they can move around a pivot point (see Fig. 9). This model was created by
primitives like a cylinder and circle. The 3D models of mobile robot consist of box that
represents the robot’s base and two cylinders as wheels.
Both 3D models are very simple approximations of real systems, because they are created
programmatically, but they serve only as demonstration models. To improve the model quality,
the best approach is to implement the model loader.
VII. CONCLUSION
In this article, we have presented the example how to create a 3D dynamical visualization of the
mathematical pendulum with or without dampening and the mobile robot. With obtained
mathematical models, the simulation models were programmed to get simulation data in
Matlab/Simulink environment. An application with 3D environment based on OpenGL with
free look flying camera was created to visualize obtained data by 3D model of the pendulum.
ACKNOWLEDGMENT
This work has been supported by the Research and Development Operational Program for
project: University Science Park Technicom for innovative applications with knowledge
technology support, ITMS code 26220220182, co-financed by the ERDF (70%) and by grant
KEGA - 001TUKE-4/2015 (30%).
REFERENCES