Manipulator model — различия между версиями

Материал из Department of Theoretical and Applied Mechanics
Перейти к: навигация, поиск
(See also)
(Cross-platform version for Linux Ubuntu)
 
(не показано 9 промежуточных версий этого же участника)
Строка 57: Строка 57:
 
But it's not enough. We want to get motion and it should be smooth. So we need to go through many points between each position. There is a problem that appears if we try to rotate vector around two axis at the same time. Rotations are not additive, so we can't just rotate on a small angle each step. The solution is simple, we need to rotate vector on bigger angle on each step from the initial position.
 
But it's not enough. We want to get motion and it should be smooth. So we need to go through many points between each position. There is a problem that appears if we try to rotate vector around two axis at the same time. Rotations are not additive, so we can't just rotate on a small angle each step. The solution is simple, we need to rotate vector on bigger angle on each step from the initial position.
  
==About program interface==
+
==About program interface in C#==
 
Because program doesn't have help yet, I should give some information about it's interface.<br>
 
Because program doesn't have help yet, I should give some information about it's interface.<br>
 
I'll tell about each tab:
 
I'll tell about each tab:
Строка 65: Строка 65:
 
Left/Right – rotation around vertical axis<br>
 
Left/Right – rotation around vertical axis<br>
 
Ctrl + Up/Down/Left/Right – faster rotation<br>
 
Ctrl + Up/Down/Left/Right – faster rotation<br>
+/- (OemPlus/OemMinus) –Foundation Zoom<br>
+
+/- (OemPlus/OemMinus) –Zoom<br>
 
<gallery widths=550px heights=300px perrow = 1>
 
<gallery widths=550px heights=300px perrow = 1>
 
Файл:Graph_Tab_0.jpg‎
 
Файл:Graph_Tab_0.jpg‎
 
</gallery>
 
</gallery>
 +
 
===Settings===
 
===Settings===
 
This one is responsible for customization of model appearance. You can change model color and opacity, quality and speed of basis rotation.
 
This one is responsible for customization of model appearance. You can change model color and opacity, quality and speed of basis rotation.
Строка 90: Строка 91:
 
Drawing of objects is done by triangulation, that means that we need to build it of triangles.
 
Drawing of objects is done by triangulation, that means that we need to build it of triangles.
 
Notice that back side of triangles is transparent as default.
 
Notice that back side of triangles is transparent as default.
 +
<br><br><br>
  
 
+
==Cross-platform version for Linux Ubuntu==
 
+
===Strange crazy idea===
 
+
[[Файл:Linux_penguin.jpg|100px|right]]
 +
[[Файл:Ubuntu_logo.png|80px|right]]
 +
The number of Linux OS users is increasing so I came to idea of making this program portable for this OS. But I faced an immense problem: Wine & mono doesn't support WPF graphics. That were really bad news, which meant that I wont be able to run this program on Linux. And finally after scrolling about some hundred pages I thought: "I can't port C# program with WPF to Linux, but I want it to work there, so Let's rewrite it in C++ with QT and OpenGL!" This idea is crazy enough to be good i think.
 +
===First steps===
 +
The first thing I should do was to find a good cross-platform IDE which I will use, because I don't like compiling project from the terminal. Finally I installed QT Creator IDE and started studying it, by the way trying to writing something that resembles program interface...
  
 
==Maybe this can be used==
 
==Maybe this can be used==
Строка 125: Строка 131:
 
[[Медиа:Hand_Model_x86.zip|Hand_Model_x86.zip]]<br>
 
[[Медиа:Hand_Model_x86.zip|Hand_Model_x86.zip]]<br>
 
[[Медиа:Hand_Model_x64.zip|Hand_Model_x64.zip]]<br>
 
[[Медиа:Hand_Model_x64.zip|Hand_Model_x64.zip]]<br>
 +
 +
==Change log==
 +
'''ver_1.0.0.34:'''
 +
*Quaternion optimization + bugfix
 +
*Improved triangulation quality
 +
*Added simple Help
 +
*Fixed bug in rotation of spheres
 +
'''ver_1.0.0.33:'''
 +
*Saving Graph settings to the binary file
 +
*Rotation of hand parts
 +
*Using quaternions instead of rotation tensors
 +
*Rotation optimization
  
 
== See also ==
 
== See also ==
Строка 132: Строка 150:
  
 
==Links==
 
==Links==
[http://wat.gamedev.ru/articles/quaternions] - some information about quaternions (RU)<br>
+
[http://wat.gamedev.ru/articles/quaternions LINK] - some information about quaternions (RU)<br>
[http://www.wpftutorial.net/IntroductionTo3D.html] - about 3D graphics in WPF
+
[http://www.wpftutorial.net/IntroductionTo3D.html LINK] - about 3D graphics in WPF (EN)<br>
  
  
 
[[Category: Студенческие проекты]]
 
[[Category: Студенческие проекты]]

Текущая версия на 00:34, 3 декабря 2012

TM 1.jpg

Description[править]

This is the page of a project related to project "Fencing".

Developers[править]

Dzenushko Dainis

Global Task[править]

The main aim of this project is development of a program which will be useful for recording and calculation of manipulator's movement.

Current task[править]

Current task is development of fencer's hand model. That means to create mathematical model, that finds the position of a hand and comes to this position from any previous position with visualization on C# language, using parameters (changes of angles in joints and coordinates of a shoulder)

Some information about modelling[править]

Degrees of freedom[править]

Hand bones.jpg

This model has 9 degrees of freedom:
2 — translation movement of a shoulder (front/back; up/down)
3 — shoulder joint as a ball joint
1 — elbow joint 
1 — rotation of wrist round it’s axis
2 — wrist (2 perpendicular cylindrical joints)

Hand rotation[править]

Vector rotation.png

In order to rotate any 3D object we should rotate related vector.
But how to rotate vector?
This programm uses quaternions for vector rotation.

Quaternions[править]

Usually quaternions are defined as a number system that extends the complex numbers to 4D space. In a simplier way we can define quaternions as 4 numbers with specific operations and properties.
[math]Q = (w,x,y,z) = w + xi + yj + zk[/math] , where i,j,k satisfies
[math]i^2 = j^2 = k^2 = ijk = -1[/math]

Useful formulas[править]

Droid confus.jpg

We are going to use quaternion written as
[math]Q = [w,v][/math] - where [math]w[/math] - scalar and [math]v[/math] - vector
In these terms we have rotation quaternion
[math]Q = \left[ \cos \left( \frac{\alpha}{2} \right), \sin \left( \frac{\alpha}{2} \right)v \right][/math]
This is the quaternion that rotates round vector [math]v[/math] on angle [math]\alpha[/math]
[math]Q* = [w, -v][/math] - conjugated quaternion
[math]norm(Q) = \sqrt{w^2 + x^2 + y^2 +z^2}[/math] - norm of quaternion
[math]Q^{-1} = \frac{Q*}{norm(Q)}[/math] - reverse quaternion
[math]QQ' = [ ww' - v \cdot v', v \times v' + wv' + w' v][/math] - quaternion multiplication

Rotate vector[править]

HowTo.gif

In order to rotate the vector [math]r[/math] we need to go through the following steps:
1) Cast vector to quaternion It's easy to make quaternion of vector. Just add zero to the scalar part and your vector to the vector part of quaternion
[math]R = [0,r][/math]
2) Multiply
[math]R' = Q R Q^{-1}[/math]
Now we have quaternion [math]R[/math] rotated.
3)Cast back After all we should cast quaternion [math]R'[/math] to vector [math]r'[/math]. It's as easy as first cast, just forget about scalar part. Vector part of [math]R'[/math] is ours [math]r'[/math] vector.

Rotation[править]

Rotation hand.jpg

OK! We already can rotate any vector around any on any angle (but not bigger than 180deg)!
But it's not enough. We want to get motion and it should be smooth. So we need to go through many points between each position. There is a problem that appears if we try to rotate vector around two axis at the same time. Rotations are not additive, so we can't just rotate on a small angle each step. The solution is simple, we need to rotate vector on bigger angle on each step from the initial position.

About program interface in C#[править]

Because program doesn't have help yet, I should give some information about it's interface.
I'll tell about each tab:

Graph[править]

This tab is responsible for visualization of movement. There are some keys working on this tab:
Up/Down – rotation around horizontal axis
Left/Right – rotation around vertical axis
Ctrl + Up/Down/Left/Right – faster rotation
+/- (OemPlus/OemMinus) –Zoom



Settings[править]

This one is responsible for customization of model appearance. You can change model color and opacity, quality and speed of basis rotation.



3D Graphics realization[править]

Program interface is developed by using special library WPF (Windows Presentation Foundation) and Microsoft Visual Studio's built-in XAML redactor.

  • What is WPF:

“The Windows Presentation Foundation is Microsoft’s next generation UI framework to create applications with a rich user experience. It is part of the .NET framework 3.0 and higher. WPF combines application UIs, 2D graphics, 3D graphics, documents and multimedia into one single framework. Its vector based rendering engine uses hardware acceleration of modern graphic cards. This makes the UI faster, scalable and resolution independent. etc.”

  • Viewport3D element:
Scene viewport.jpg

Graphics contents in 3-D WPF application is encapsulated in Viewport3D element, which can be placed on two-dimensional element such as program window. Graphics system identifies Viewport3D as two-dimensional visual element such as many in WPF. Viewport3D function as preview window of three-dimensional scene. More precisely it is projection of 3-D scene on plane (screen).

Triangulation.jpg
  • Drawing 3D objects

Drawing of objects is done by triangulation, that means that we need to build it of triangles. Notice that back side of triangles is transparent as default.


Cross-platform version for Linux Ubuntu[править]

Strange crazy idea[править]

Linux penguin.jpg
Ubuntu logo.png

The number of Linux OS users is increasing so I came to idea of making this program portable for this OS. But I faced an immense problem: Wine & mono doesn't support WPF graphics. That were really bad news, which meant that I wont be able to run this program on Linux. And finally after scrolling about some hundred pages I thought: "I can't port C# program with WPF to Linux, but I want it to work there, so Let's rewrite it in C++ with QT and OpenGL!" This idea is crazy enough to be good i think.

First steps[править]

The first thing I should do was to find a good cross-platform IDE which I will use, because I don't like compiling project from the terminal. Finally I installed QT Creator IDE and started studying it, by the way trying to writing something that resembles program interface...

Maybe this can be used[править]

This program in future can be used as a package for modelling manipulators. They are very similar to hand, so the idea is the same.



Last Features[править]

DONE.jpg

ver_1.0.0.33:

  • Saving Graph settings to the binary file
  • Rotation of hand parts
  • Using quaternions instead of rotation tensors
  • Rotation optimization

Future Features[править]

Coming soon.gif

Under development...

  • Optimization of calculations related to rotation
  • Switching to post-processing visualization instead of visualization and calculation at the same time
  • Preparing the code for development of different manipulators
  • Development of interface for user defined manipulators and movement

Last, sometimes stable version[править]

KTULHU.png

First run of the program may ask you to create file with default settings, just click 'OK' and it'll run

ver_1.0.0.33:[править]

Click "Simulate" to see the model default movement.
Hand_Model_x86.zip
Hand_Model_x64.zip

Change log[править]

ver_1.0.0.34:

  • Quaternion optimization + bugfix
  • Improved triangulation quality
  • Added simple Help
  • Fixed bug in rotation of spheres

ver_1.0.0.33:

  • Saving Graph settings to the binary file
  • Rotation of hand parts
  • Using quaternions instead of rotation tensors
  • Rotation optimization

See also[править]

project "Fencing"
Department for Theoretical Mechanics

Links[править]

LINK - some information about quaternions (RU)
LINK - about 3D graphics in WPF (EN)