line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
# |
2
|
|
|
|
|
|
|
# Rinchi Common Image Generator Interface for Perl |
3
|
|
|
|
|
|
|
# Class Identifier: f78ae2d2-200e-11de-bdb2-001c25551abc |
4
|
|
|
|
|
|
|
# Author: Brian M. Ames |
5
|
|
|
|
|
|
|
# |
6
|
|
|
|
|
|
|
|
7
|
|
|
|
|
|
|
package Rinchi::CIGIPP::MotionTrackerControl; |
8
|
|
|
|
|
|
|
|
9
|
1
|
|
|
1
|
|
27
|
use 5.006; |
|
1
|
|
|
|
|
4
|
|
|
1
|
|
|
|
|
45
|
|
10
|
1
|
|
|
1
|
|
7
|
use strict; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
35
|
|
11
|
1
|
|
|
1
|
|
7
|
use warnings; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
40
|
|
12
|
1
|
|
|
1
|
|
6
|
use Carp; |
|
1
|
|
|
|
|
3
|
|
|
1
|
|
|
|
|
6103
|
|
13
|
|
|
|
|
|
|
|
14
|
|
|
|
|
|
|
require Exporter; |
15
|
|
|
|
|
|
|
|
16
|
|
|
|
|
|
|
our @ISA = qw(Exporter); |
17
|
|
|
|
|
|
|
|
18
|
|
|
|
|
|
|
# Items to export into callers namespace by default. Note: do not export |
19
|
|
|
|
|
|
|
# names by default without a very good reason. Use EXPORT_OK instead. |
20
|
|
|
|
|
|
|
# Do not simply export all your public functions/methods/constants. |
21
|
|
|
|
|
|
|
|
22
|
|
|
|
|
|
|
# This allows declaration use Rinchi::CIGI::AtmosphereControl ':all'; |
23
|
|
|
|
|
|
|
# If you do not need this, moving things directly into @EXPORT or @EXPORT_OK |
24
|
|
|
|
|
|
|
# will save memory. |
25
|
|
|
|
|
|
|
our %EXPORT_TAGS = ( 'all' => [ qw( |
26
|
|
|
|
|
|
|
|
27
|
|
|
|
|
|
|
) ] ); |
28
|
|
|
|
|
|
|
|
29
|
|
|
|
|
|
|
our @EXPORT_OK = ( @{ $EXPORT_TAGS{'all'} } ); |
30
|
|
|
|
|
|
|
|
31
|
|
|
|
|
|
|
our @EXPORT = qw( |
32
|
|
|
|
|
|
|
|
33
|
|
|
|
|
|
|
); |
34
|
|
|
|
|
|
|
|
35
|
|
|
|
|
|
|
our $VERSION = '0.01'; |
36
|
|
|
|
|
|
|
|
37
|
|
|
|
|
|
|
# Preloaded methods go here. |
38
|
|
|
|
|
|
|
|
39
|
|
|
|
|
|
|
=head1 NAME |
40
|
|
|
|
|
|
|
|
41
|
|
|
|
|
|
|
Rinchi::CIGIPP::MotionTrackerControl - Perl extension for the Common Image |
42
|
|
|
|
|
|
|
Generator Interface - Motion Tracker Control data packet. |
43
|
|
|
|
|
|
|
data packet. |
44
|
|
|
|
|
|
|
=head1 SYNOPSIS |
45
|
|
|
|
|
|
|
|
46
|
|
|
|
|
|
|
use Rinchi::CIGIPP::MotionTrackerControl; |
47
|
|
|
|
|
|
|
my $mt_ctl = Rinchi::CIGIPP::MotionTrackerControl->new(); |
48
|
|
|
|
|
|
|
|
49
|
|
|
|
|
|
|
$packet_type = $mt_ctl->packet_type(); |
50
|
|
|
|
|
|
|
$packet_size = $mt_ctl->packet_size(); |
51
|
|
|
|
|
|
|
$view_ident = $mt_ctl->view_ident(10606); |
52
|
|
|
|
|
|
|
$tracker_ident = $mt_ctl->tracker_ident(122); |
53
|
|
|
|
|
|
|
$yaw_enable = $mt_ctl->yaw_enable(Rinchi::CIGIPP->Enable); |
54
|
|
|
|
|
|
|
$pitch_enable = $mt_ctl->pitch_enable(Rinchi::CIGIPP->Enable); |
55
|
|
|
|
|
|
|
$roll_enable = $mt_ctl->roll_enable(Rinchi::CIGIPP->Disable); |
56
|
|
|
|
|
|
|
$z_enable = $mt_ctl->z_enable(Rinchi::CIGIPP->Enable); |
57
|
|
|
|
|
|
|
$y_enable = $mt_ctl->y_enable(Rinchi::CIGIPP->Disable); |
58
|
|
|
|
|
|
|
$x_enable = $mt_ctl->x_enable(Rinchi::CIGIPP->Enable); |
59
|
|
|
|
|
|
|
$boresight_enable = $mt_ctl->boresight_enable(Rinchi::CIGIPP->Disable); |
60
|
|
|
|
|
|
|
$tracker_enable = $mt_ctl->tracker_enable(Rinchi::CIGIPP->Disable); |
61
|
|
|
|
|
|
|
$view_group = $mt_ctl->view_group(Rinchi::CIGIPP->View); |
62
|
|
|
|
|
|
|
|
63
|
|
|
|
|
|
|
=head1 DESCRIPTION |
64
|
|
|
|
|
|
|
|
65
|
|
|
|
|
|
|
The Motion Tracker Control packet is used to initialize and change properties |
66
|
|
|
|
|
|
|
of tracked input devices connected to the IG. These devices may include head |
67
|
|
|
|
|
|
|
trackers, eye trackers, wands, trackballs, etc. If more than one head tracker |
68
|
|
|
|
|
|
|
is used to control a view or view group, the order in which the transformations |
69
|
|
|
|
|
|
|
are applied is determined by the IG. |
70
|
|
|
|
|
|
|
|
71
|
|
|
|
|
|
|
The Host may request the instantaneous position and orientation of a tracker |
72
|
|
|
|
|
|
|
device by sending a Position Request packet with its Object Class attribute set |
73
|
|
|
|
|
|
|
to Motion Tracker (4). |
74
|
|
|
|
|
|
|
|
75
|
|
|
|
|
|
|
Note that if tracked input devices are connected to the Host, the Host should |
76
|
|
|
|
|
|
|
interpret the tracked input data and send the appropriate CIGI packets to |
77
|
|
|
|
|
|
|
achieve the desired effect on the IG. For example, the Host would interpret |
78
|
|
|
|
|
|
|
input from a connected head tracker and send View Control packets to the IG to |
79
|
|
|
|
|
|
|
move the eyepoint of the appropriate view or view group. |
80
|
|
|
|
|
|
|
|
81
|
|
|
|
|
|
|
=head2 EXPORT |
82
|
|
|
|
|
|
|
|
83
|
|
|
|
|
|
|
None by default. |
84
|
|
|
|
|
|
|
|
85
|
|
|
|
|
|
|
#============================================================================== |
86
|
|
|
|
|
|
|
|
87
|
|
|
|
|
|
|
=item new $mt_ctl = Rinchi::CIGIPP::MotionTrackerControl->new() |
88
|
|
|
|
|
|
|
|
89
|
|
|
|
|
|
|
Constructor for Rinchi::MotionTrackerControl. |
90
|
|
|
|
|
|
|
|
91
|
|
|
|
|
|
|
=cut |
92
|
|
|
|
|
|
|
|
93
|
|
|
|
|
|
|
sub new { |
94
|
1
|
|
|
1
|
1
|
304
|
my $class = shift; |
95
|
1
|
|
33
|
|
|
8
|
$class = ref($class) || $class; |
96
|
|
|
|
|
|
|
|
97
|
1
|
|
|
|
|
18
|
my $self = { |
98
|
|
|
|
|
|
|
'_Buffer' => '', |
99
|
|
|
|
|
|
|
'_ClassIdent' => 'f78ae2d2-200e-11de-bdb2-001c25551abc', |
100
|
|
|
|
|
|
|
'_Pack' => 'CCSCCCC', |
101
|
|
|
|
|
|
|
'_Swap1' => 'CCvCCCC', |
102
|
|
|
|
|
|
|
'_Swap2' => 'CCnCCCC', |
103
|
|
|
|
|
|
|
'packetType' => 18, |
104
|
|
|
|
|
|
|
'packetSize' => 8, |
105
|
|
|
|
|
|
|
'viewIdent' => 0, |
106
|
|
|
|
|
|
|
'trackerIdent' => 0, |
107
|
|
|
|
|
|
|
'_bitfields1' => 0, # Includes bitfields yawEnable, pitchEnable, rollEnable, zEnable, yEnable, xEnable, boresightEnable, and trackerEnable. |
108
|
|
|
|
|
|
|
'yawEnable' => 0, |
109
|
|
|
|
|
|
|
'pitchEnable' => 0, |
110
|
|
|
|
|
|
|
'rollEnable' => 0, |
111
|
|
|
|
|
|
|
'zEnable' => 0, |
112
|
|
|
|
|
|
|
'yEnable' => 0, |
113
|
|
|
|
|
|
|
'xEnable' => 0, |
114
|
|
|
|
|
|
|
'boresightEnable' => 0, |
115
|
|
|
|
|
|
|
'trackerEnable' => 0, |
116
|
|
|
|
|
|
|
'_bitfields2' => 0, # Includes bitfields unused32, and viewGroup. |
117
|
|
|
|
|
|
|
'viewGroup' => 0, |
118
|
|
|
|
|
|
|
'_unused33' => 0, |
119
|
|
|
|
|
|
|
}; |
120
|
|
|
|
|
|
|
|
121
|
1
|
50
|
|
|
|
4
|
if (@_) { |
122
|
0
|
0
|
|
|
|
0
|
if (ref($_[0]) eq 'ARRAY') { |
|
|
0
|
|
|
|
|
|
123
|
0
|
|
|
|
|
0
|
$self->{'_Buffer'} = $_[0][0]; |
124
|
|
|
|
|
|
|
} elsif (ref($_[0]) eq 'HASH') { |
125
|
0
|
|
|
|
|
0
|
foreach my $attr (keys %{$_[0]}) { |
|
0
|
|
|
|
|
0
|
|
126
|
0
|
0
|
|
|
|
0
|
$self->{"_$attr"} = $_[0]->{$attr} unless ($attr =~ /^_/); |
127
|
|
|
|
|
|
|
} |
128
|
|
|
|
|
|
|
} |
129
|
|
|
|
|
|
|
} |
130
|
|
|
|
|
|
|
|
131
|
1
|
|
|
|
|
4
|
bless($self,$class); |
132
|
1
|
|
|
|
|
3
|
return $self; |
133
|
|
|
|
|
|
|
} |
134
|
|
|
|
|
|
|
|
135
|
|
|
|
|
|
|
#============================================================================== |
136
|
|
|
|
|
|
|
|
137
|
|
|
|
|
|
|
=item sub packet_type() |
138
|
|
|
|
|
|
|
|
139
|
|
|
|
|
|
|
$value = $mt_ctl->packet_type(); |
140
|
|
|
|
|
|
|
|
141
|
|
|
|
|
|
|
Data Packet Identifier. |
142
|
|
|
|
|
|
|
|
143
|
|
|
|
|
|
|
This attribute identifies this data packet as the Motion Tracker Control |
144
|
|
|
|
|
|
|
packet. The value of this attribute must be 18. |
145
|
|
|
|
|
|
|
|
146
|
|
|
|
|
|
|
=cut |
147
|
|
|
|
|
|
|
|
148
|
|
|
|
|
|
|
sub packet_type() { |
149
|
1
|
|
|
1
|
1
|
6
|
my ($self) = @_; |
150
|
1
|
|
|
|
|
8
|
return $self->{'packetType'}; |
151
|
|
|
|
|
|
|
} |
152
|
|
|
|
|
|
|
|
153
|
|
|
|
|
|
|
#============================================================================== |
154
|
|
|
|
|
|
|
|
155
|
|
|
|
|
|
|
=item sub packet_size() |
156
|
|
|
|
|
|
|
|
157
|
|
|
|
|
|
|
$value = $mt_ctl->packet_size(); |
158
|
|
|
|
|
|
|
|
159
|
|
|
|
|
|
|
Data Packet Size. |
160
|
|
|
|
|
|
|
|
161
|
|
|
|
|
|
|
This attribute indicates the number of bytes in this data packet. The value of |
162
|
|
|
|
|
|
|
this attribute must be 8. |
163
|
|
|
|
|
|
|
|
164
|
|
|
|
|
|
|
=cut |
165
|
|
|
|
|
|
|
|
166
|
|
|
|
|
|
|
sub packet_size() { |
167
|
1
|
|
|
1
|
1
|
6
|
my ($self) = @_; |
168
|
1
|
|
|
|
|
3
|
return $self->{'packetSize'}; |
169
|
|
|
|
|
|
|
} |
170
|
|
|
|
|
|
|
|
171
|
|
|
|
|
|
|
#============================================================================== |
172
|
|
|
|
|
|
|
|
173
|
|
|
|
|
|
|
=item sub view_ident([$newValue]) |
174
|
|
|
|
|
|
|
|
175
|
|
|
|
|
|
|
$value = $mt_ctl->view_ident($newValue); |
176
|
|
|
|
|
|
|
|
177
|
|
|
|
|
|
|
View/View Group ID. |
178
|
|
|
|
|
|
|
|
179
|
|
|
|
|
|
|
This attribute specifies the view or view group to which the tracking device is attached. |
180
|
|
|
|
|
|
|
|
181
|
|
|
|
|
|
|
=cut |
182
|
|
|
|
|
|
|
|
183
|
|
|
|
|
|
|
sub view_ident() { |
184
|
1
|
|
|
1
|
1
|
6
|
my ($self,$nv) = @_; |
185
|
1
|
50
|
|
|
|
4
|
if (defined($nv)) { |
186
|
1
|
|
|
|
|
3
|
$self->{'viewIdent'} = $nv; |
187
|
|
|
|
|
|
|
} |
188
|
1
|
|
|
|
|
3
|
return $self->{'viewIdent'}; |
189
|
|
|
|
|
|
|
} |
190
|
|
|
|
|
|
|
|
191
|
|
|
|
|
|
|
#============================================================================== |
192
|
|
|
|
|
|
|
|
193
|
|
|
|
|
|
|
=item sub tracker_ident([$newValue]) |
194
|
|
|
|
|
|
|
|
195
|
|
|
|
|
|
|
$value = $mt_ctl->tracker_ident($newValue); |
196
|
|
|
|
|
|
|
|
197
|
|
|
|
|
|
|
Tracker ID. |
198
|
|
|
|
|
|
|
|
199
|
|
|
|
|
|
|
This attribute specifies the tracker whose state the data in this packet represents. |
200
|
|
|
|
|
|
|
|
201
|
|
|
|
|
|
|
=cut |
202
|
|
|
|
|
|
|
|
203
|
|
|
|
|
|
|
sub tracker_ident() { |
204
|
1
|
|
|
1
|
1
|
6
|
my ($self,$nv) = @_; |
205
|
1
|
50
|
|
|
|
5
|
if (defined($nv)) { |
206
|
1
|
|
|
|
|
3
|
$self->{'trackerIdent'} = $nv; |
207
|
|
|
|
|
|
|
} |
208
|
1
|
|
|
|
|
4
|
return $self->{'trackerIdent'}; |
209
|
|
|
|
|
|
|
} |
210
|
|
|
|
|
|
|
|
211
|
|
|
|
|
|
|
#============================================================================== |
212
|
|
|
|
|
|
|
|
213
|
|
|
|
|
|
|
=item sub yaw_enable([$newValue]) |
214
|
|
|
|
|
|
|
|
215
|
|
|
|
|
|
|
$value = $mt_ctl->yaw_enable($newValue); |
216
|
|
|
|
|
|
|
|
217
|
|
|
|
|
|
|
Yaw Enable. |
218
|
|
|
|
|
|
|
|
219
|
|
|
|
|
|
|
This attribute is used to enable or disable the yaw (Z-axis rotation) of the |
220
|
|
|
|
|
|
|
motion tracker. |
221
|
|
|
|
|
|
|
|
222
|
|
|
|
|
|
|
Disable 0 |
223
|
|
|
|
|
|
|
Enable 1 |
224
|
|
|
|
|
|
|
|
225
|
|
|
|
|
|
|
=cut |
226
|
|
|
|
|
|
|
|
227
|
|
|
|
|
|
|
sub yaw_enable() { |
228
|
1
|
|
|
1
|
1
|
3
|
my ($self,$nv) = @_; |
229
|
1
|
50
|
|
|
|
3
|
if (defined($nv)) { |
230
|
1
|
50
|
33
|
|
|
16
|
if (($nv==0) or ($nv==1)) { |
231
|
1
|
|
|
|
|
4
|
$self->{'yawEnable'} = $nv; |
232
|
1
|
|
|
|
|
3
|
$self->{'_bitfields1'} |= ($nv << 7) &0x80; |
233
|
|
|
|
|
|
|
} else { |
234
|
0
|
|
|
|
|
0
|
carp "yaw_enable must be 0 (Disable), or 1 (Enable)."; |
235
|
|
|
|
|
|
|
} |
236
|
|
|
|
|
|
|
} |
237
|
1
|
|
|
|
|
15
|
return (($self->{'_bitfields1'} & 0x80) >> 7); |
238
|
|
|
|
|
|
|
} |
239
|
|
|
|
|
|
|
|
240
|
|
|
|
|
|
|
#============================================================================== |
241
|
|
|
|
|
|
|
|
242
|
|
|
|
|
|
|
=item sub pitch_enable([$newValue]) |
243
|
|
|
|
|
|
|
|
244
|
|
|
|
|
|
|
$value = $mt_ctl->pitch_enable($newValue); |
245
|
|
|
|
|
|
|
|
246
|
|
|
|
|
|
|
Pitch Enable. |
247
|
|
|
|
|
|
|
|
248
|
|
|
|
|
|
|
This attribute is used to enable or disable the pitch (Y-axis rotation) of the |
249
|
|
|
|
|
|
|
motion tracker. |
250
|
|
|
|
|
|
|
|
251
|
|
|
|
|
|
|
Disable 0 |
252
|
|
|
|
|
|
|
Enable 1 |
253
|
|
|
|
|
|
|
|
254
|
|
|
|
|
|
|
=cut |
255
|
|
|
|
|
|
|
|
256
|
|
|
|
|
|
|
sub pitch_enable() { |
257
|
1
|
|
|
1
|
1
|
2
|
my ($self,$nv) = @_; |
258
|
1
|
50
|
|
|
|
5
|
if (defined($nv)) { |
259
|
1
|
50
|
33
|
|
|
7
|
if (($nv==0) or ($nv==1)) { |
260
|
1
|
|
|
|
|
4
|
$self->{'pitchEnable'} = $nv; |
261
|
1
|
|
|
|
|
2
|
$self->{'_bitfields1'} |= ($nv << 6) &0x40; |
262
|
|
|
|
|
|
|
} else { |
263
|
0
|
|
|
|
|
0
|
carp "pitch_enable must be 0 (Disable), or 1 (Enable)."; |
264
|
|
|
|
|
|
|
} |
265
|
|
|
|
|
|
|
} |
266
|
1
|
|
|
|
|
5
|
return (($self->{'_bitfields1'} & 0x40) >> 6); |
267
|
|
|
|
|
|
|
} |
268
|
|
|
|
|
|
|
|
269
|
|
|
|
|
|
|
#============================================================================== |
270
|
|
|
|
|
|
|
|
271
|
|
|
|
|
|
|
=item sub roll_enable([$newValue]) |
272
|
|
|
|
|
|
|
|
273
|
|
|
|
|
|
|
$value = $mt_ctl->roll_enable($newValue); |
274
|
|
|
|
|
|
|
|
275
|
|
|
|
|
|
|
Roll Enable. |
276
|
|
|
|
|
|
|
|
277
|
|
|
|
|
|
|
This attribute is used to enable or disable the roll (X-axis rotation) of the |
278
|
|
|
|
|
|
|
motion tracker. |
279
|
|
|
|
|
|
|
|
280
|
|
|
|
|
|
|
Disable 0 |
281
|
|
|
|
|
|
|
Enable 1 |
282
|
|
|
|
|
|
|
|
283
|
|
|
|
|
|
|
=cut |
284
|
|
|
|
|
|
|
|
285
|
|
|
|
|
|
|
sub roll_enable() { |
286
|
1
|
|
|
1
|
1
|
3
|
my ($self,$nv) = @_; |
287
|
1
|
50
|
|
|
|
4
|
if (defined($nv)) { |
288
|
1
|
50
|
33
|
|
|
6
|
if (($nv==0) or ($nv==1)) { |
289
|
1
|
|
|
|
|
3
|
$self->{'rollEnable'} = $nv; |
290
|
1
|
|
|
|
|
4
|
$self->{'_bitfields1'} |= ($nv << 5) &0x20; |
291
|
|
|
|
|
|
|
} else { |
292
|
0
|
|
|
|
|
0
|
carp "roll_enable must be 0 (Disable), or 1 (Enable)."; |
293
|
|
|
|
|
|
|
} |
294
|
|
|
|
|
|
|
} |
295
|
1
|
|
|
|
|
3
|
return (($self->{'_bitfields1'} & 0x20) >> 5); |
296
|
|
|
|
|
|
|
} |
297
|
|
|
|
|
|
|
|
298
|
|
|
|
|
|
|
#============================================================================== |
299
|
|
|
|
|
|
|
|
300
|
|
|
|
|
|
|
=item sub z_enable([$newValue]) |
301
|
|
|
|
|
|
|
|
302
|
|
|
|
|
|
|
$value = $mt_ctl->z_enable($newValue); |
303
|
|
|
|
|
|
|
|
304
|
|
|
|
|
|
|
Z Enable. |
305
|
|
|
|
|
|
|
|
306
|
|
|
|
|
|
|
This attribute is used to enable or disable the Z-axis position of the motion tracker. |
307
|
|
|
|
|
|
|
|
308
|
|
|
|
|
|
|
Disable 0 |
309
|
|
|
|
|
|
|
Enable 1 |
310
|
|
|
|
|
|
|
|
311
|
|
|
|
|
|
|
=cut |
312
|
|
|
|
|
|
|
|
313
|
|
|
|
|
|
|
sub z_enable() { |
314
|
1
|
|
|
1
|
1
|
3
|
my ($self,$nv) = @_; |
315
|
1
|
50
|
|
|
|
5
|
if (defined($nv)) { |
316
|
1
|
50
|
33
|
|
|
6
|
if (($nv==0) or ($nv==1)) { |
317
|
1
|
|
|
|
|
2
|
$self->{'zEnable'} = $nv; |
318
|
1
|
|
|
|
|
4
|
$self->{'_bitfields1'} |= ($nv << 4) &0x10; |
319
|
|
|
|
|
|
|
} else { |
320
|
0
|
|
|
|
|
0
|
carp "z_enable must be 0 (Disable), or 1 (Enable)."; |
321
|
|
|
|
|
|
|
} |
322
|
|
|
|
|
|
|
} |
323
|
1
|
|
|
|
|
3
|
return (($self->{'_bitfields1'} & 0x10) >> 4); |
324
|
|
|
|
|
|
|
} |
325
|
|
|
|
|
|
|
|
326
|
|
|
|
|
|
|
#============================================================================== |
327
|
|
|
|
|
|
|
|
328
|
|
|
|
|
|
|
=item sub y_enable([$newValue]) |
329
|
|
|
|
|
|
|
|
330
|
|
|
|
|
|
|
$value = $mt_ctl->y_enable($newValue); |
331
|
|
|
|
|
|
|
|
332
|
|
|
|
|
|
|
Y Enable. |
333
|
|
|
|
|
|
|
|
334
|
|
|
|
|
|
|
This attribute is used to enable or disable the Y-axis position of the motion tracker. |
335
|
|
|
|
|
|
|
|
336
|
|
|
|
|
|
|
Disable 0 |
337
|
|
|
|
|
|
|
Enable 1 |
338
|
|
|
|
|
|
|
|
339
|
|
|
|
|
|
|
=cut |
340
|
|
|
|
|
|
|
|
341
|
|
|
|
|
|
|
sub y_enable() { |
342
|
1
|
|
|
1
|
1
|
3
|
my ($self,$nv) = @_; |
343
|
1
|
50
|
|
|
|
3
|
if (defined($nv)) { |
344
|
1
|
50
|
33
|
|
|
13
|
if (($nv==0) or ($nv==1)) { |
345
|
1
|
|
|
|
|
2
|
$self->{'yEnable'} = $nv; |
346
|
1
|
|
|
|
|
3
|
$self->{'_bitfields1'} |= ($nv << 3) &0x08; |
347
|
|
|
|
|
|
|
} else { |
348
|
0
|
|
|
|
|
0
|
carp "y_enable must be 0 (Disable), or 1 (Enable)."; |
349
|
|
|
|
|
|
|
} |
350
|
|
|
|
|
|
|
} |
351
|
1
|
|
|
|
|
4
|
return (($self->{'_bitfields1'} & 0x08) >> 3); |
352
|
|
|
|
|
|
|
} |
353
|
|
|
|
|
|
|
|
354
|
|
|
|
|
|
|
#============================================================================== |
355
|
|
|
|
|
|
|
|
356
|
|
|
|
|
|
|
=item sub x_enable([$newValue]) |
357
|
|
|
|
|
|
|
|
358
|
|
|
|
|
|
|
$value = $mt_ctl->x_enable($newValue); |
359
|
|
|
|
|
|
|
|
360
|
|
|
|
|
|
|
X Enable. |
361
|
|
|
|
|
|
|
|
362
|
|
|
|
|
|
|
This attribute is used to enable or disable the X-axis position of the motion tracker. |
363
|
|
|
|
|
|
|
|
364
|
|
|
|
|
|
|
Disable 0 |
365
|
|
|
|
|
|
|
Enable 1 |
366
|
|
|
|
|
|
|
|
367
|
|
|
|
|
|
|
=cut |
368
|
|
|
|
|
|
|
|
369
|
|
|
|
|
|
|
sub x_enable() { |
370
|
1
|
|
|
1
|
1
|
6
|
my ($self,$nv) = @_; |
371
|
1
|
50
|
|
|
|
17
|
if (defined($nv)) { |
372
|
1
|
50
|
33
|
|
|
10
|
if (($nv==0) or ($nv==1)) { |
373
|
1
|
|
|
|
|
2
|
$self->{'xEnable'} = $nv; |
374
|
1
|
|
|
|
|
4
|
$self->{'_bitfields1'} |= ($nv << 2) &0x04; |
375
|
|
|
|
|
|
|
} else { |
376
|
0
|
|
|
|
|
0
|
carp "x_enable must be 0 (Disable), or 1 (Enable)."; |
377
|
|
|
|
|
|
|
} |
378
|
|
|
|
|
|
|
} |
379
|
1
|
|
|
|
|
4
|
return (($self->{'_bitfields1'} & 0x04) >> 2); |
380
|
|
|
|
|
|
|
} |
381
|
|
|
|
|
|
|
|
382
|
|
|
|
|
|
|
#============================================================================== |
383
|
|
|
|
|
|
|
|
384
|
|
|
|
|
|
|
=item sub boresight_enable([$newValue]) |
385
|
|
|
|
|
|
|
|
386
|
|
|
|
|
|
|
$value = $mt_ctl->boresight_enable($newValue); |
387
|
|
|
|
|
|
|
|
388
|
|
|
|
|
|
|
Boresight Enable. |
389
|
|
|
|
|
|
|
|
390
|
|
|
|
|
|
|
This attribute is used to set the boresight state of the external tracking |
391
|
|
|
|
|
|
|
device. This mode is used to reestablish the tracker's “center” position at the |
392
|
|
|
|
|
|
|
current position and orientation. |
393
|
|
|
|
|
|
|
|
394
|
|
|
|
|
|
|
Note: If boresighting is enabled, the Host must send a Motion Tracker Control |
395
|
|
|
|
|
|
|
packet with Boresight Enable set to Disable (0) to return the tracker to normal |
396
|
|
|
|
|
|
|
operation. The IG will continue to update the boresight position each frame |
397
|
|
|
|
|
|
|
until that occurs. |
398
|
|
|
|
|
|
|
|
399
|
|
|
|
|
|
|
Disable 0 |
400
|
|
|
|
|
|
|
Enable 1 |
401
|
|
|
|
|
|
|
|
402
|
|
|
|
|
|
|
=cut |
403
|
|
|
|
|
|
|
|
404
|
|
|
|
|
|
|
sub boresight_enable() { |
405
|
1
|
|
|
1
|
1
|
3
|
my ($self,$nv) = @_; |
406
|
1
|
50
|
|
|
|
5
|
if (defined($nv)) { |
407
|
1
|
50
|
33
|
|
|
14
|
if (($nv==0) or ($nv==1)) { |
408
|
1
|
|
|
|
|
2
|
$self->{'boresightEnable'} = $nv; |
409
|
1
|
|
|
|
|
3
|
$self->{'_bitfields1'} |= ($nv << 1) &0x02; |
410
|
|
|
|
|
|
|
} else { |
411
|
0
|
|
|
|
|
0
|
carp "boresight_enable must be 0 (Disable), or 1 (Enable)."; |
412
|
|
|
|
|
|
|
} |
413
|
|
|
|
|
|
|
} |
414
|
1
|
|
|
|
|
4
|
return (($self->{'_bitfields1'} & 0x02) >> 1); |
415
|
|
|
|
|
|
|
} |
416
|
|
|
|
|
|
|
|
417
|
|
|
|
|
|
|
#============================================================================== |
418
|
|
|
|
|
|
|
|
419
|
|
|
|
|
|
|
=item sub tracker_enable([$newValue]) |
420
|
|
|
|
|
|
|
|
421
|
|
|
|
|
|
|
$value = $mt_ctl->tracker_enable($newValue); |
422
|
|
|
|
|
|
|
|
423
|
|
|
|
|
|
|
Tracker Enable. |
424
|
|
|
|
|
|
|
|
425
|
|
|
|
|
|
|
This attribute specifies whether the tracking device is enabled. |
426
|
|
|
|
|
|
|
|
427
|
|
|
|
|
|
|
Disable 0 |
428
|
|
|
|
|
|
|
Enable 1 |
429
|
|
|
|
|
|
|
|
430
|
|
|
|
|
|
|
=cut |
431
|
|
|
|
|
|
|
|
432
|
|
|
|
|
|
|
sub tracker_enable() { |
433
|
1
|
|
|
1
|
1
|
2
|
my ($self,$nv) = @_; |
434
|
1
|
50
|
|
|
|
5
|
if (defined($nv)) { |
435
|
1
|
50
|
33
|
|
|
7
|
if (($nv==0) or ($nv==1)) { |
436
|
1
|
|
|
|
|
9
|
$self->{'trackerEnable'} = $nv; |
437
|
1
|
|
|
|
|
3
|
$self->{'_bitfields1'} |= $nv &0x01; |
438
|
|
|
|
|
|
|
} else { |
439
|
0
|
|
|
|
|
0
|
carp "tracker_enable must be 0 (Disable), or 1 (Enable)."; |
440
|
|
|
|
|
|
|
} |
441
|
|
|
|
|
|
|
} |
442
|
1
|
|
|
|
|
4
|
return ($self->{'_bitfields1'} & 0x01); |
443
|
|
|
|
|
|
|
} |
444
|
|
|
|
|
|
|
|
445
|
|
|
|
|
|
|
#============================================================================== |
446
|
|
|
|
|
|
|
|
447
|
|
|
|
|
|
|
=item sub view_group([$newValue]) |
448
|
|
|
|
|
|
|
|
449
|
|
|
|
|
|
|
$value = $mt_ctl->view_group($newValue); |
450
|
|
|
|
|
|
|
|
451
|
|
|
|
|
|
|
View/View Group Select. |
452
|
|
|
|
|
|
|
|
453
|
|
|
|
|
|
|
This attribute specifies whether the tracking device is attached to a single |
454
|
|
|
|
|
|
|
view or a view group. If set to View (0), the View/View Group ID attribute |
455
|
|
|
|
|
|
|
identifies a single view. If set to View Group (1), that attribute identifies a |
456
|
|
|
|
|
|
|
view group. |
457
|
|
|
|
|
|
|
|
458
|
|
|
|
|
|
|
View 0 |
459
|
|
|
|
|
|
|
ViewGroup 1 |
460
|
|
|
|
|
|
|
|
461
|
|
|
|
|
|
|
=cut |
462
|
|
|
|
|
|
|
|
463
|
|
|
|
|
|
|
sub view_group() { |
464
|
1
|
|
|
1
|
1
|
4
|
my ($self,$nv) = @_; |
465
|
1
|
50
|
|
|
|
4
|
if (defined($nv)) { |
466
|
1
|
50
|
33
|
|
|
6
|
if (($nv==0) or ($nv==1)) { |
467
|
1
|
|
|
|
|
3
|
$self->{'viewGroup'} = $nv; |
468
|
1
|
|
|
|
|
3
|
$self->{'_bitfields2'} |= $nv &0x01; |
469
|
|
|
|
|
|
|
} else { |
470
|
0
|
|
|
|
|
0
|
carp "view_group must be 0 (View), or 1 (ViewGroup)."; |
471
|
|
|
|
|
|
|
} |
472
|
|
|
|
|
|
|
} |
473
|
1
|
|
|
|
|
3
|
return ($self->{'_bitfields2'} & 0x01); |
474
|
|
|
|
|
|
|
} |
475
|
|
|
|
|
|
|
|
476
|
|
|
|
|
|
|
#========================================================================== |
477
|
|
|
|
|
|
|
|
478
|
|
|
|
|
|
|
=item sub pack() |
479
|
|
|
|
|
|
|
|
480
|
|
|
|
|
|
|
$value = $mt_ctl->pack(); |
481
|
|
|
|
|
|
|
|
482
|
|
|
|
|
|
|
Returns the packed data packet. |
483
|
|
|
|
|
|
|
|
484
|
|
|
|
|
|
|
=cut |
485
|
|
|
|
|
|
|
|
486
|
|
|
|
|
|
|
sub pack($) { |
487
|
1
|
|
|
1
|
1
|
7
|
my $self = shift ; |
488
|
|
|
|
|
|
|
|
489
|
1
|
|
|
|
|
8
|
$self->{'_Buffer'} = CORE::pack($self->{'_Pack'}, |
490
|
|
|
|
|
|
|
$self->{'packetType'}, |
491
|
|
|
|
|
|
|
$self->{'packetSize'}, |
492
|
|
|
|
|
|
|
$self->{'viewIdent'}, |
493
|
|
|
|
|
|
|
$self->{'trackerIdent'}, |
494
|
|
|
|
|
|
|
$self->{'_bitfields1'}, # Includes bitfields yawEnable, pitchEnable, rollEnable, zEnable, yEnable, xEnable, boresightEnable, and trackerEnable. |
495
|
|
|
|
|
|
|
$self->{'_bitfields2'}, # Includes bitfields unused32, and viewGroup. |
496
|
|
|
|
|
|
|
$self->{'_unused33'}, |
497
|
|
|
|
|
|
|
); |
498
|
|
|
|
|
|
|
|
499
|
1
|
|
|
|
|
4
|
return $self->{'_Buffer'}; |
500
|
|
|
|
|
|
|
} |
501
|
|
|
|
|
|
|
|
502
|
|
|
|
|
|
|
#========================================================================== |
503
|
|
|
|
|
|
|
|
504
|
|
|
|
|
|
|
=item sub unpack() |
505
|
|
|
|
|
|
|
|
506
|
|
|
|
|
|
|
$value = $mt_ctl->unpack(); |
507
|
|
|
|
|
|
|
|
508
|
|
|
|
|
|
|
Unpacks the packed data packet. |
509
|
|
|
|
|
|
|
|
510
|
|
|
|
|
|
|
=cut |
511
|
|
|
|
|
|
|
|
512
|
|
|
|
|
|
|
sub unpack($) { |
513
|
0
|
|
|
0
|
1
|
|
my $self = shift @_; |
514
|
|
|
|
|
|
|
|
515
|
0
|
0
|
|
|
|
|
if (@_) { |
516
|
0
|
|
|
|
|
|
$self->{'_Buffer'} = shift @_; |
517
|
|
|
|
|
|
|
} |
518
|
0
|
|
|
|
|
|
my ($a,$b,$c,$d,$e,$f,$g) = CORE::unpack($self->{'_Pack'},$self->{'_Buffer'}); |
519
|
0
|
|
|
|
|
|
$self->{'packetType'} = $a; |
520
|
0
|
|
|
|
|
|
$self->{'packetSize'} = $b; |
521
|
0
|
|
|
|
|
|
$self->{'viewIdent'} = $c; |
522
|
0
|
|
|
|
|
|
$self->{'trackerIdent'} = $d; |
523
|
0
|
|
|
|
|
|
$self->{'_bitfields1'} = $e; # Includes bitfields yawEnable, pitchEnable, rollEnable, zEnable, yEnable, xEnable, boresightEnable, and trackerEnable. |
524
|
0
|
|
|
|
|
|
$self->{'_bitfields2'} = $f; # Includes bitfields unused32, and viewGroup. |
525
|
0
|
|
|
|
|
|
$self->{'_unused33'} = $g; |
526
|
|
|
|
|
|
|
|
527
|
0
|
|
|
|
|
|
$self->{'yawEnable'} = $self->yaw_enable(); |
528
|
0
|
|
|
|
|
|
$self->{'pitchEnable'} = $self->pitch_enable(); |
529
|
0
|
|
|
|
|
|
$self->{'rollEnable'} = $self->roll_enable(); |
530
|
0
|
|
|
|
|
|
$self->{'zEnable'} = $self->z_enable(); |
531
|
0
|
|
|
|
|
|
$self->{'yEnable'} = $self->y_enable(); |
532
|
0
|
|
|
|
|
|
$self->{'xEnable'} = $self->x_enable(); |
533
|
0
|
|
|
|
|
|
$self->{'boresightEnable'} = $self->boresight_enable(); |
534
|
0
|
|
|
|
|
|
$self->{'trackerEnable'} = $self->tracker_enable(); |
535
|
0
|
|
|
|
|
|
$self->{'viewGroup'} = $self->view_group(); |
536
|
|
|
|
|
|
|
|
537
|
0
|
|
|
|
|
|
return $self->{'_Buffer'}; |
538
|
|
|
|
|
|
|
} |
539
|
|
|
|
|
|
|
|
540
|
|
|
|
|
|
|
#========================================================================== |
541
|
|
|
|
|
|
|
|
542
|
|
|
|
|
|
|
=item sub byte_swap() |
543
|
|
|
|
|
|
|
|
544
|
|
|
|
|
|
|
$obj_name->byte_swap(); |
545
|
|
|
|
|
|
|
|
546
|
|
|
|
|
|
|
Byte swaps the packed data packet. |
547
|
|
|
|
|
|
|
|
548
|
|
|
|
|
|
|
=cut |
549
|
|
|
|
|
|
|
|
550
|
|
|
|
|
|
|
sub byte_swap($) { |
551
|
0
|
|
|
0
|
1
|
|
my $self = shift @_; |
552
|
|
|
|
|
|
|
|
553
|
0
|
0
|
|
|
|
|
if (@_) { |
554
|
0
|
|
|
|
|
|
$self->{'_Buffer'} = shift @_; |
555
|
|
|
|
|
|
|
} else { |
556
|
0
|
|
|
|
|
|
$self->pack(); |
557
|
|
|
|
|
|
|
} |
558
|
0
|
|
|
|
|
|
my ($a,$b,$c,$d,$e,$f,$g) = CORE::unpack($self->{'_Swap1'},$self->{'_Buffer'}); |
559
|
|
|
|
|
|
|
|
560
|
0
|
|
|
|
|
|
$self->{'_Buffer'} = CORE::pack($self->{'_Swap2'},$a,$b,$c,$d,$e,$f,$g); |
561
|
0
|
|
|
|
|
|
$self->unpack(); |
562
|
|
|
|
|
|
|
|
563
|
0
|
|
|
|
|
|
return $self->{'_Buffer'}; |
564
|
|
|
|
|
|
|
} |
565
|
|
|
|
|
|
|
|
566
|
|
|
|
|
|
|
1; |
567
|
|
|
|
|
|
|
__END__ |