Documente Academic
Documente Profesional
Documente Cultură
is the matrix,
i
is the
variable and i is frame 0..n.
(
(
(
(
1 0 0 0
cos sin 0
sin sin cos cos cos sin
cos sin sin cos sin cos
) (
1
i i i
i i i i i i i
i i i i i i i
i
i
i
d
a
a
A
Eq. 1
For the PHANTOM Omni haptic device n=3 and gives the following transformation
matrices between all frames.
(
(
(
(
=
1 0 0 0
0 0 1 0
0 cos 0 sin
0 sin 0 cos
) (
1 1
1 1
1
0
1
A
Eq. 2
(
(
(
(
=
1 0 0 0
0 1 0 0
sin 0 cos sin
cos 0 sin cos
) (
2 2 2 2
2 2 2 2
2
1
2
a
a
A Eq. 3
(
(
(
(
=
1 0 0 0
0 1 0 0
sin 0 cos sin
cos 0 sin cos
) (
3 3 3 3
3 3 3 3
3
2
3
a
a
A Eq. 4
Based on these matrices the homogenous transformation matrix
0
e
T is computed,
which yields the position and orientation of the end effector with respect to the base
frame 0. (Frame 3 is equal to the frame of the end effector).
(
(
(
(
+ + + +
+
+
=
= = =
1 0 0 0
0
) ( ) ( ) (
2 2 3 2 3 2 3 3 3 2 3 2 3 2 3 2
2 1 2 3 2 1 3 3 2 1 3 1 3 2 1 3 2 1 3 2 1 3 2 1
2 1 2 2 1 3 3 3 2 1 3 1 2 3 1 3 2 1 3 2 1 3 2 1
3
2
3 2
1
2 1
0
1
0
3
0
s a s c a s c a c c s s s c c s
c s a s s s a c s s a c c s s s s s s s s c s s
c c a s c s a c c c a s s c c s c c s s c c c c
A A A T T
e
Eq. 5
Where c
1
indicates cos(
1
), s
2
indicates sin(
2
) and so on. In the derived
transformation matrix the three first rows of the last column give the global position
of the end effector.
8
|
|
|
.
|
\
|
+ +
+
+
=
|
|
|
.
|
\
|
2 2 3 2 3 2 3 3
2 1 2 3 2 1 3 3 2 1 3
2 1 2 2 1 3 3 3 2 1 3
_ _
sin sin cos sin cos
cos sin sin sin sin cos sin sin
cos cos sin cos sin cos cos cos
a a a
a a a
a a a
z
y
x
effector end pos
Eq. 6
The expression of the end effectors position is built up in Simulink by connecting
blocks and signals to create an algorithm of the kinematics.
3.2 Collision Detection Algorithm
The pre-defined workspace of the virtual environment gives virtual boundaries that
limit the free space movements. In our case, the workspace is created as a bounding
box showed in figure 4.
The position of the end effector is calculated by the kinematic algorithm and the
locations of the virtual walls are pre-defined. By checking the xyz-coordinates of the
end effector in relation to the boundaries collision detection is performed in real time
on the dSPACE CPU. The collision detection algorithm is built up with blocks in
Simulink as presented in figure 5.
ymin
zmax
xmax
ymax
zmin
xmin
z
x
y
posend_effector
Figure 4. Workspace in the virtual environment is pre-defined as a bounding box.
9
Figure 5. The collision detection algorithm for xyz-coordinates created in Simulink.
3.3 Haptic Feedback
If the collision detection algorithm finds collision between the sphere, which
illustrates the depicted position and movements of the end effector, and the virtual
walls a haptic feedback will be sent to the user. The force feedback gives the user a
sense of touching the virtual walls and the sphere can be dragged along the
boundaries.
The basic idea with the haptic algorithm is based on the well known proxy-probe
method. The probe position is equal to the global position of the end effector
independent if collision or not. The proxy position is the position on the boundary
where collision occurs. The force algorithm is a modified spring-damper model
e d c e d k F + =
, where the spring constant, k, and the damper constant, c, are
arbitrary chosen. d is the distance between the proxy and the probe and e is the
normalized gradient to the collided surface. See figure 6.
Figure 6. The haptic algorithm when collision occurs in the virtual environment.
F
d
e
Probe
Proxy
Free Workspace
Boundary
10
The motivation of using the spring-damper model as a relevant haptic algorithm is as
follows. Assume that the probe and the proxy are two dynamical masses that moves in
relation to each other connected by a spring and a damper. The derivation and
motivation is based on the approximations proved in figure 7.
Figure 7. Approximations used for derivation of using the spring-damper model as a haptic algorithm.
Based on the approximations from figure 7 the following derivation shows that
spring-damper model gives a relevant haptic feedback for the probe-proxy case.
Newtons second law gives:
= x m F
x
Eq. 7
x m F g m x c x k
probe external probe
= + + Eq. 8
The probe is assumed to be weightless by motivation from above = 0
probe
m
= + 0
external
F x c x k Eq. 9
x c x k F
external
+ = Q.E.D.
mproxy
mprobe
Approximate the proxy with
a wall that not moves.
mprobe
The probe can be assumed to
be weightless; since if no
external force (no collision):
Equilibrium and probe=proxy at
the wall or in free workspace.
Probe=Proxy
If there is collision detected: An
external force is applied based
on the spring-damper model.
mprobe
Fexternal
Create a free body diagram in
equilibrium of the probe object.
x=the distance the probe has
been moved from the proxy (wall)
by the external force.
g m
probe
x k x c
external
F
x
11
3.4 Motor Torques
The force that occurs if collision is detected must be transformed to corresponding
motor torques for the three motors. Inertia, and hence dynamic impacts, is assumed to
be neglected; therefore will not the motor torques be dependent of velocity and
acceleration. The mechanical construction of the PHANTOM Omni gives that two of
the motors rotate around the global x-axis and one motor rotates around the global z-
axis. See figure 8.
Figure 8. Relevant parameters for the torque algorithm.
The torque algorithm is described in relation to the information given in figure 8. The
three known positions from the origin
1
p ,
2
p and
end
p give the corresponding vector
directions of the links
1
L ,
2
L and
3
L . The three dimensional force vector is
determined from the haptic algorithm and located at the position of the end effector.
The algorithm gives the torques
1
T ,
2
T and
3
T in three dimensions for each motor, but
T
1z
, T
2x
and T
3x
are the only used components.
0
1 1
= p L Eq. 10
1 2 2
p p L = Eq. 11
2 3
p p L
end
= Eq. 12
( )
z
T k j i F L L L T
1 3 2 1 1
... ... ... + = + + = Eq. 13
( )
x
T k j i F L L T
2 3 2 2
... ... ... + = + = Eq. 14
x
T k j i F L T
3 3 3
... ... ... + = = Eq. 15
F
1
L
2
L
3
L
1
p
2
p
end
p
0
z
T
1
x
T
2
x
T
3
x
y
z
12
3.5 PWM-signals
A PWM-signal must be sent to control a motor from the dSPACE CPU. Hence, the
above mentioned motor torques is changed to currents based on gear ratio and motor
type. The currents (one for each motor) are normalized to relevant PWM-signals (0-
1). The PWM signals are sent to the motors that strengthen the wires of the haptic
device and give the user a feeling of force feedback when collision is detected in the
virtual environment.
3.6 PI-control of the Current
An error is established by comparing the measured actual motor currents and the
calculated motor currents. A PI-controller is implemented to reduce the errors of the
algorithm that calculates the motor currents. The integration part of the controller is
removing the static error and summing the current difference every time a PWM-
signal is sent to the motors. Hence, after a while the errors are reduced. The P-factor
is tested and verified for a specific constant value. The control signal of the current is
sent back to the motor. See figure 9.
Figure 9. Simulink model of the PI-controller for one motor.
The real current in the motor is measured by using an operational amplifier (Opamp).
A resistor is mounted in serial connection with the motor, and the Opamp is
measuring the voltage drop over the resistor when activating the motor. The voltage
drop is taken in to the dSPACE platform. The motor current is received by dividing
the voltage drop with the resistor value.
3.7 Graphic Rendering
To do the haptic feedback more understandable a 3D virtual environment is built up
and visualized. The collision detection is based on max/min- boundaries along the
xyz-axes, which easily is rendered as a virtual cube having the walls at the given
boundary values. A small sphere is graphic rendered to illustrate the movements of
the end effector of the haptic device. The sphere follows the movements of the end
effector in real time at 30 Hz, which enables visualization of the collision with the
virtual walls. There are no deformations of the collided walls; hence just the
13
translation of the sphere needs to be updated in the graphics loop since the other
objects are static unchanged. The virtual environment presented in figure 10 is
rendered using the MATLAB VR Toolbox.
Figure 10. The virtual environment including the walls and the sphere.
The work presented in sub-sections 3.1-3.6 is implemented and built up in Simulink
and by using the real time workshop it is compiled and downloaded to the dSPACE
processor. All the collision detection and haptic feedback is performed on the
dSPACE platform at 20 kHz in real time. To extend the solution with 3D visualization
a virtual environment is created and connected to the system through the MATLAB
VR Toolbox, which is running on the PC. The position of the end effector is in real
time transferred with MLIB functions from the dSPACE CPU to the PC for
visualization. The translation of the small sphere in the virtual environment directly
follows the position of the end effector in real time.
4. Test Results and Verification
In this paper some early test results and verification of the haptic algorithm is
presented. The test is based on the application described above with the small sphere
that collides with the walls in the virtual environment.
4.1 Product Specification
A Pentium D 2.8 GHz with 2.0 GB RAM desktop PC was used for this application.
The graphic card is an Intel 82945G Express. A dismantled Sensable PHANTOM
Omni is used as a haptic device. No drivers or API components are required since
direct connection to low-level sensors and dc-motors. The dSPACE CPU platform is
used for real time controlling and routing of signals. MATLAB 7.2 and Simulink 6.4
were used with the Real Time Workshop. The MATLAB Virtual Reality Toolbox 4.0
was used for graphic rendering.
14
4.2 The Application
A 3D rendered small sphere is following the movements of the end effector and
collision detection is performed against pre-defined virtual walls. The virtual
environment is created in the V-Realm Builder VRML-editor. A MATLAB m-file
consisting of all variables must be updated before compiling the Simulink model and
download it to the dSPACE platform for every new application.
4.3 Test Procedure and Results
The developed haptic platform described above has been tested and verified for the
basic application of the sphere colliding with virtual walls along the global xyz-axes.
A user is holding the haptic device and manipulating the virtual objects. A haptic
feedback is sent to the device when the operator moves the sphere so it collides with
the walls, which gives the user a sense of kinestic and tactile feedback. Test data has
been logged from a specific test, where the user is dragging the sphere against one
wall and relevant data are saved. The logged data are the position of the probe relative
to the wall, the calculated force, the torques and the PWM-signals for the three
motors. See figure 11-14. The globally defined boundary conditions of the walls and
the pre-defined spring and damper constants of the force algorithm were also used for
the analysis of the system. The test procedure took place for one certain case of pre-
defined parameters and logged data. The stiffness constant in the haptic algorithm was
set to a high value to give the user a sense of collision between two rigid materials. As
mentioned above the virtual scene was 3D rendered for visual feedback.
Figure 11. Position of the sphere relative to
the wall.
Figure 13. The modeled torques for the three
motors.
Figure 12. The magnitude of the calculated
force.
Figure 14. The PWM-signals for the three
motors.
15
The result from figure 11 indicates that the position of the sphere follows the position
of the wall very well, but follows the user movements into the material when applying
higher force. The surface is modeled to be quite stiff; therefore the probe is not deeper
in to the material which had been the case for a surface modeled with a lower spring
constant. From figure 12 it can be seen that the magnitude of the calculated force
directly follows the penetration distance of the surface: this is as expected. The force
is transformed to corresponding motor torques for the three motors. Figure 13 depicts
that the modeled torques (T
1z
, T
2x
and T
3x
) are varying as the user is dragging and
pushing the sphere along the surface of the wall. T
1z
is zero because no collision in the
y-direction. Any other conclusions are hard to draw. The PWM-signal sent from
dSPACE to each motor directly follows the torque, as illustrated in figure 14. It is
hereby verified that the force algorithm and the MATLAB/Simulink haptic system
works properly for this application.
There have also been blind tests with subjects that never tried haptics before; and they
recognize that you really get a realistic perception of touching the virtual objects.
5. Conclusion and Future Work
In this work a haptic interface for MATLAB/Simulink has been developed. A
PHANTOM Omni haptic device is dismantled and the sensors and actuators are low
level connected to a dSPACE platform for real time communication. The haptic
algorithm including kinematics, collision detection, force calculation, transformations
to motor torques and implementation of a PI controller is modelled in Simulink. The
developed algorithms built up of Simulink blocks are compiled with the Real Time
Workshop. A virtual reality scene is built up in the MATLAB VR Toolbox for real
time 3D visualization.
There are some major benefits to use this system:
MATLAB/Simulink enables model based programming instead of using the
C++ programming language.
The low level connection to the haptic device conveys use of self-developed
haptic algorithms without any required drivers and APIs.
Easy implementation and verification of self modified or constructed haptic
devices is possible in this system.
In this system all the haptic algorithm information is built up in Simulink
separately from the graphics. To create it in this way increases the knowledge
of the separation between haptic and graphic rendering.
The developed haptic platform has been tested and verified for the basic application
of a 3D rendered small sphere that follows the movements of the end effector and
collision detection is performed against pre-defined virtual walls. By good results
from the tests it was hereby verified that the force algorithm and the
MATLAB/Simulink haptic system works properly for this application.
Possible future work could include some of the following suggestions:
To create other applications will include more advanced collision detection
algorithms for arbitrary modeled 3D objects.
16
Development of physical based force algorithms, not just the commonly used
spring-damper model.
In relation to previous work [1]; implement haptic milling applications in the
MATLAB/Simulink haptic interface. Enable more functions to manipulate the
virtual objects than just touch them, e.g. cutting, milling and shape
deformations of the objects.
Analysis of the impact when two stiff materials are colliding. Implement
already developed force feedback algorithms for this case [20]. Investigate
important parameters for the haptic control algorithm to avoid stability
problems. Analyze the influence of the haptic rate for this problem.
Perform blind tests, where subjects both touch real objects and virtual objects.
For modeling of realistic stiffness in the haptic feedback.
In this paper the dynamical impact of the motor torques model is assumed to
be neglected. In future work a dynamical based model will be implemented
and this assumption will be investigated.
Develop a 6-DOF haptic device, which can give the user a haptic feedback of
both force and torques, implement it to this system for tests and verification.
This is important for further progress of the haptic research topic.
Supplementary development of the MATLAB/Simulink haptic system so it
can be used in robotic education and control engineering laborations with
focus on haptics.
Acknowledgements
This research is part of the development of a Haptic Milling Surgery Simulator. In
context of this project exchange student Mustafa Umut Akan from Sabanci University
in Turkey has done a great effort.
Nomenclature
i
Angle between z
i-1
and z
i
[rad]
i
Angle between x
i-1
and x
i
[rad]
a
i
Distance along x
i
from O
i
[m]
1 i
i
A
Homogenous transformation matrix to
go from one frame to another [4x4]
c
i
cos(
i
)
c Damper constant [Ns/m]
d Distance between the proxy and the
probe [m]
d