1 1. motion tracking - polhemus liberty latus references: 1. liberty latus manual, polhemus, 2005 2....
Post on 24-Jan-2016
219 views
TRANSCRIPT
1
1. Motion Tracking - Polhemus Liberty Latus
References:
1. Liberty Latus Manual, Polhemus, 2005
2. G. Burdea and P. Coiffet, Virtual Reality Technology 2nd Ed., Wiley, New Jersey, 2003, Ch.2
3. J.M. Hart, Windows System Programming, 3rd Ed., Addison-Wesley, 2005, Ch.12
Department of ELECTRONIC AND INFORMATION ENGINEERING
1. Motion Tracking – Polhemus Liberty Latus by Dr Daniel Lun
2
Motion Tracking Systems A motion tracking
system is often the most important I/O Devices of a Virtual Reality system
It detects the position and orientation (P&O) of multiple objects in the 3D space and feeds into the VR Engine
Department of ELECTRONIC AND INFORMATION ENGINEERING
1. Motion Tracking – Polhemus Liberty Latus by Dr Daniel Lun
3
3-D System of Coordinates of Objects
3D objects have 6 degrees of freedom (D.O.Fs) of movement: three translations –
(x, y, z); three rotations –
(Azimuth (az), Elevation (el) and Roll (ro)).
Department of ELECTRONIC AND INFORMATION ENGINEERING
1. Motion Tracking – Polhemus Liberty Latus by Dr Daniel Lun
4
Tracking Technologies Trackers measure the motion of “objects” such as user’s
wrist or his head vs. a fixed system of coordinates.
Technologies to perform this task: Magnetic (prevalent, less expensive)
E.g. Polhemus’s Liberty Latus, Ascension’s FOB Ultrasonic (less used, low resolution) Mechanical (special cases, only when size and weight are
not matter) E.g. Fakespace’s Push1280
Vision-based (expensive, high accuracy) E.g. A.R.T. GmbH’s ARTrack
Inertial/Vision-based (cheap but limited functionality) E.g. WII of Nintendo
Department of ELECTRONIC AND INFORMATION ENGINEERING
1. Motion Tracking – Polhemus Liberty Latus by Dr Daniel Lun
5
Characteristics of Trackers Different tracking systems have different characteristics
Measurement rate – Readings/sec; Sensing latency; Sensor noise and drift; Measurement accuracy (errors); Measurement repeatability; Tethered or wireless; Sensing degradation; Restriction on the working environment; Cost
To build a VR system using a particular tracking system, good understanding of its technology and limitations is required
Department of ELECTRONIC AND INFORMATION ENGINEERING
1. Motion Tracking – Polhemus Liberty Latus by Dr Daniel Lun
6
Magnetic Tracking Systems
Definition: A magnetic tracker is a non-contact position measurement device that uses a magnetic field produced by a stationary TRANSMITTER to determine the real-time position of a moving RECEIVER element
Department of ELECTRONIC AND INFORMATION ENGINEERING
1. Motion Tracking – Polhemus Liberty Latus by Dr Daniel Lun
7
Working principle Magnetic field picked up by an antenna can be
converted into electrical signal The electric power induced depends on the
magnetic field strength The longer is the distance between the transmitter and
antenna, the lower is the power
The strength of magnetic field follows inverse square law Magnitude decreases as the square of the distance
Magnetic field is directional E.g. vertical magnetic field can only be picked up by
antenna placed vertically
Department of ELECTRONIC AND INFORMATION ENGINEERING
1. Motion Tracking – Polhemus Liberty Latus by Dr Daniel Lun
8
Working Principle
Receiver antenna(stationary)
Transmitter antenna(moving)
Tx G
Tx BTx RRx BRx RRx G
Time
When the object is moving or rotating, voltage of different magnitude will be generated in its three antennas based on the distance moved and the rotation angle
Such information will be sent to the computer for analyzing the P&O information of the moving object
Magnetic wave
Send back to the computer for further analysis
9
Limitations
Performance will be significantly degraded if there is ferromagnetic material nearby the transmitter or receiver
Department of ELECTRONIC AND INFORMATION ENGINEERING
1. Motion Tracking – Polhemus Liberty Latus by Dr Daniel Lun
10
Case study – Polhemus’s Liberty Latus The LIBERTY LATUS (Large Area Tracking Untethered System)
is a magnetic based motion tracking system Design to track the position and orientation (P&O) of multiple
objects in the 3D space Comprise 3 major components:
SEU – System Electronic Unit Receptors Wireless Markers
Department of ELECTRONIC AND INFORMATION ENGINEERING
1. Motion Tracking – Polhemus Liberty Latus by Dr Daniel Lun
11
Working Principle
Markers/Transmitters(moving)
Receptor / Receiver(stationary)
Magnetic wave of different frequencies
Signals of multiple frequencies are sent back to SEU for analysis
12
Characteristics Each transmitter “marker” position is measured by a receiver
“receptor” within 8 ft. One receiver can track 4 markers. In practice, inaccurate data will be received if the distance
between marker and receptor is larger than 1m The system can have up to 12 markers and up to 16 receptors
In DE505a, 8 markers and 4 receptors are installed Sampling rate is 188 Hz up to 8 markers and drops to 94 Hz from
9 to 12 markers Markers are battery powered up to 2.5 hours and weigh 2 ounces
each Battery life can be shorter when using for long time
For one marker and one receptor accuracy is 0.04 mm and 0.0012 degree at 1 ft range and drops afterwards
Department of ELECTRONIC AND INFORMATION ENGINEERING
1. Motion Tracking – Polhemus Liberty Latus by Dr Daniel Lun
13
Precautions When Using the System
1. Never put metallic objects near the receptors or markers. Wrong data will be generated
2. Never put receptors and markers on the ground in DE505a since there are many metallic conduits laid under the ground
3. Whenever a marker is switched on, there is a possibility that the phase of the data is wrong (from +ve to –ve or vice versa). It will also happen when the marker is moving too far away from the receptors. Switch the marker off and on again to obtain a correct phase
4. When a marker is moved outside 1.5m from the receptors, the data received will have much noise. Denoising technique should be implemented in order to use the data in your game
5. A marker should be moved too close (e.g. < 10cm) to the receptor. Wrong data will be generated
Department of ELECTRONIC AND INFORMATION ENGINEERING
1. Motion Tracking – Polhemus Liberty Latus by Dr Daniel Lun
14
More Precautions
The floor of DE505a is not leveled. Some parts may be slightly higher than the other parts
Try not to use the absolute values of the received data to determine the exact 3D coordinates of a marker in the room, as the values can drift in time
Use the relative difference between measures as much as possible
The battery of the marker can be exhausted much earlier than expected. Replace the battery once noticing that there is abnormality in the received data
Department of ELECTRONIC AND INFORMATION ENGINEERING
1. Motion Tracking – Polhemus Liberty Latus by Dr Daniel Lun
15
Software Architecture
For easy access of the data generated by Liberty Latus, a simple network server is installed that accepts clients’ connection thru Winsock
Motion Tracking
Server
receptor
Marker
Marker
Network backbone
SEU
Windows SocketServer IP: 158.132.148.212Port: 8888
receptor
receptor
receptor
Department of ELECTRONIC AND INFORMATION ENGINEERING
1. Motion Tracking – Polhemus Liberty Latus by Dr Daniel Lun
16
Motion Tracking Server
The server accepts string commands and replies different string for different requests
Some commands are particularly important:1. “hello” – When the user program sends a string
“hello” to the server, the server will return a string “Hello client, have a nice day!”
2. “Q” – For closing a Winsock connection.3. “P” – Return a string that contains the P&O data
of all markers and the status of the markers
Department of ELECTRONIC AND INFORMATION ENGINEERING
1. Motion Tracking – Polhemus Liberty Latus by Dr Daniel Lun
17
Retrieve the P&O Data
When the string of the P&O data is received, the function memcpy() has to be used to convert the string into an array of the structure MarkerData:
#define NMarker 8 //There are 8 markers in DE505a
struct MarkerData //Structure of marker data{
float x, y, z, az, el, ro; //6DOF of a markerbool status; //Status of a marker
};
MarkerData marker[NMarker]; //Define an array of 8 markers
memcpy(marker, stringFromServer, sizeof(marker));//stringFromServer is the string received from server//Must use this command to convert between data type
#define NMarker 8 //There are 8 markers in DE505a
struct MarkerData //Structure of marker data{
float x, y, z, az, el, ro; //6DOF of a markerbool status; //Status of a marker
};
MarkerData marker[NMarker]; //Define an array of 8 markers
memcpy(marker, stringFromServer, sizeof(marker));//stringFromServer is the string received from server//Must use this command to convert between data type
18
Socket API and Socket The socket API is an Interprocess Communication (IPC) programming
interface originally provided as part of the Berkeley UNIX OS Ported to all modern operating systems, including Sun Solaris and
Windows systems It is a de facto standard for programming IPC, and is the basis of more
sophisticated IPC interface such as remote procedure call and remote method invocation
a socket
Process A Process B
• A socket API provides a programming construct termed a socket
• A process wishing to communicate with another process must instantiate such a construct
• The two processes then issue operations provided by the API to send and receive data.
Department of ELECTRONIC AND INFORMATION ENGINEERING
1. Motion Tracking – Polhemus Liberty Latus by Dr Daniel Lun
19
Connection-oriented stream socket A socket programming construct can make use of either
the UDP or TCP protocol Sockets that use UDP for transport are known as
datagram sockets, while sockets that use TCP are termed stream sockets
Socket APIs can support both connectionless and connection-oriented communication at the application layer
For the Motion Tracking Server, it uses stream socket and works in connection-oriented mode, i.e. a connection has to be made before data can be sent or received
Process AsocketAPI runtime
supportProcess B
socketAPI runtime
support
transport layer software transport layer software
connection-oriented datagram socket
20
Windows Sockets API
An extension of the Berkeley Sockets API used in the Windows environment
Porting of code already written for Berkeley Sockets Windows stations easily integrated into TCP/IP networks
Winsock API is supported by a DLL (ws2_32.dll) that can be accessed by linking ws2_32.lib with your project
Include <winsock.h> as well for the definition of some names
Department of ELECTRONIC AND INFORMATION ENGINEERING
1. Motion Tracking – Polhemus Liberty Latus by Dr Daniel Lun
21
General Procedure for Connecting to a Server
WSAStartup( ... ); //1. Initialize
socket ( ... ); //2. Create a socket
connect ( ... ); //3. Connect to the server
send ( ... ); / recv ( ... );
//4. Send or receive data
:
closesocket ( ... );//5. After using the socket,
// close it.
WSACleanup ( ... ); //6. Allow the system to
// free resource allocated
WSAStartup( ... ); //1. Initialize
socket ( ... ); //2. Create a socket
connect ( ... ); //3. Connect to the server
send ( ... ); / recv ( ... );
//4. Send or receive data
:
closesocket ( ... );//5. After using the socket,
// close it.
WSACleanup ( ... ); //6. Allow the system to
// free resource allocated
Just follow the procedure below and fill in the required information:
22
Winsock Initialization
To initialize, a nonstandard Winsock-specific function WSAStartup must be the first function a program calls
For example,
WORD wVersionRequired; //Store the socket version
WSADATA wsaData; //Store socket info
wVersionRequired = ... ; //Input the version number
int error = WSAStartup( // Return non-zero if error
wVersionRequired,
(LPWSADATA)&wsaData);
WORD wVersionRequired; //Store the socket version
WSADATA wsaData; //Store socket info
wVersionRequired = ... ; //Input the version number
int error = WSAStartup( // Return non-zero if error
wVersionRequired,
(LPWSADATA)&wsaData);
23
WSAStartup() Parameters wVersionRequired
Indicates the highest version of the WinSock DLL you need Returns a non-zero value if the DLL cannot support the
version you want Can use a macro MAKEWORD to generate the number wVersionRequired = MAKEWORD(2,2);
//version 2.2
lpWSAData points to a WSADATA structure that returns information on the configuration of the DLL
To obtain the error number, the function WSAGetLastError()
Department of ELECTRONIC AND INFORMATION ENGINEERING
1. Motion Tracking – Polhemus Liberty Latus by Dr Daniel Lun
24
Create a Socket
Call socket() to create (or open) a socket For example,
typedef unsigned int SOCKET;
//Should have been included in <winsock.h>
int af = ...;
int type = ...;
int protocol = ...;
SOCKET theSocket = socket(af, type, protocol);
typedef unsigned int SOCKET;
//Should have been included in <winsock.h>
int af = ...;
int type = ...;
int protocol = ...;
SOCKET theSocket = socket(af, type, protocol);
Department of ELECTRONIC AND INFORMATION ENGINEERING
1. Motion Tracking – Polhemus Liberty Latus by Dr Daniel Lun
25
socket() parameter
Input parameters include af denotes the address family. PF_INET
designates the Internet protocol (IP) type specifies connection-oriented
(SOCK_STREAM) or datagram communications (SOCK_DGRAM)
protocol – unnecessary if using TCP/IP Use IPPROTO_TCP
socket returns SOCKET_ERROR upon failure
Department of ELECTRONIC AND INFORMATION ENGINEERING
1. Motion Tracking – Polhemus Liberty Latus by Dr Daniel Lun
26
Connect to a Server
To connect to the Motion Tracking Server, a client program can call the function connect() if it has a socket
For example,
SOCKET s = ...;
SOCKADDR_IN serverInfo = ...;
int nNameLen = ...;
int connectResult = connect(s,(LPSOCKADDR)&serverInfo,
nNameLen);
SOCKET s = ...;
SOCKADDR_IN serverInfo = ...;
int nNameLen = ...;
int connectResult = connect(s,(LPSOCKADDR)&serverInfo,
nNameLen);
27
connect Parameters
Input parameters: s – a socket created by socket() function &serverInfo – a LPSOCKADDR pointer that points to a
SOCKADDR_IN structure designating the server machine name and port address
nNameLen – should give the size of SOCKADDR_IN Use sizeof()
Return 0 indicates a successful connection, otherwise SOCKET_ERROR indicate failure Possibly due to the server socket is not listening to clients’
request Department of ELECTRONIC AND INFORMATION ENGINEERING
1. Motion Tracking – Polhemus Liberty Latus by Dr Daniel Lun
28
SOCKADDR_IN Structure
The structure SOCKADDR_IN is protocol dependent. For TCP/IP, it is defined as
struct sockaddr_in{
short sin_family; // PF_INETu_short sin_port;struct sin_addr; //4-byte IP addrchar sin_zero [8];
};typedef struct sockaddr_in SOCKADDR_IN
//Should have been defined in //<winsock.h>
struct sockaddr_in{
short sin_family; // PF_INETu_short sin_port;struct sin_addr; //4-byte IP addrchar sin_zero [8];
};typedef struct sockaddr_in SOCKADDR_IN
//Should have been defined in //<winsock.h>
29
Parameters of SOCKADDR_IN sin_family
Address family, should be the same as the parameter af when calling socket(), i.e. PR_INET, e.g.
sin_port Specify port number of the server Should call the function htons() to enter this
value. E.g.
int portNo = …; //Specify the port numberserverInfo.sin_port = htons(portNo);
int portNo = …; //Specify the port numberserverInfo.sin_port = htons(portNo);
serverInfo.sin_family = PF_INET;serverInfo.sin_family = PF_INET;
30
Parameters of SOCKADDR_IN sin_addr
sin_addr is a structure that has a sub-member s_addr. Should be filled with server’s IP address
The function inet_addr() can be used as follows:
std::string ipAddress; // Assume ipAddress contains // the IP address of the serverSOCKADDR_IN sa;
//Define an instance of the structuresa.sin_addr.s_addr = inet_addr(ipAddress.c_str());
//Set the IP address of server
std::string ipAddress; // Assume ipAddress contains // the IP address of the serverSOCKADDR_IN sa;
//Define an instance of the structuresa.sin_addr.s_addr = inet_addr(ipAddress.c_str());
//Set the IP address of server
sin_zeros Just to pad enough zeros to make the structure the
same size as SOCKADDR. No need to initialize it
31
Send or Receive Data
After the connection is made, the client can send or receive data to or from the server
Partner stations exchange data using send() and recv()
send() and recv() have identical arguments:int send ( int recv (
SOCKET s, SOCKET s,
LPSTR lpBuffer, LPSTR lpBuffer,
int nBufferLen, int nBufferLen,
int nFlags); int nFlags);
Department of ELECTRONIC AND INFORMATION ENGINEERING
1. Motion Tracking – Polhemus Liberty Latus by Dr Daniel Lun
32
send / recv Parameters lpBuffer
send: the string to be sent recv: keep the received string
nBufferLen send: the length of the string recv: the size of the buffer used to keep the string
nFlags Can be used to indicate urgency Can also be used to allow reading the data but not removing it In general, use 0
Return the actual number of bytes transmitted or received. An error is indicated by the value SOCKET_ERROR
Department of ELECTRONIC AND INFORMATION ENGINEERING
1. Motion Tracking – Polhemus Liberty Latus by Dr Daniel Lun
33
When Finish …
When finish transmitting or receiving data, remember to destroy the socket and release the resource
Use closesocket() and WSACleanup() as follows:
SOCKET s;: //After finish using the socket ...:
closesocket(s);//The name of the socket is s
WSACleanup(); //Release the resource acquired
SOCKET s;: //After finish using the socket ...:
closesocket(s);//The name of the socket is s
WSACleanup(); //Release the resource acquired
34
System Software Architecture
Motion Tracking
Server
Network backbone
Windows SocketServer IP: 158.132.148.212Port: 8888
Motion Tracking
Server Simulator
Windows SocketServer IP: 158.132.148.218Port: 8889
Latus
mMarker[8]
WindowSocket
ClientWindows Socket
Your Client Program
Ogre Graphics Engine
Should be used to keeping the current markers’ data
35
Responses of the Servers
String sent from the client
Response of the server
“hello” “Hello client, have a nice day!”
“Q” The Winsock connection will be terminated
“P” Return a string that contains the P&O data of all markers and the status of the markers
Department of ELECTRONIC AND INFORMATION ENGINEERING
1. Motion Tracking – Polhemus Liberty Latus by Dr Daniel Lun
36
Structure of the Client Program
Latus-mMarker[NMARKER] : MarkerData
+Initialize(...)+UpdatePO(...)+GetX(...)+GetY(...)+GetZ(...)+GetAZ(...)+GetEL(...)+GetRO(...)+GetStatus(...)
WindowSocket-mSocket : SOCKET-mConnect : bool
+ConnectToHost(...)+CloseConnection(...)+SendMsg(...)+ReceiveMsg(...)+IsConnect(...)
WindowSocket is the base class for realizing Windows Sockets
Latus is derived from WindowSocket that extends its function to obtain markers’ data on the network
37
Things to be done in Lab1
Construct a basic Ogre game Implement the class WindowSocket Implement the class Latus Apply the markers’ data obtained using the
Latus class to the movement of Ogre objects
Department of ELECTRONIC AND INFORMATION ENGINEERING
1. Motion Tracking – Polhemus Liberty Latus by Dr Daniel Lun