RflySimSDK v3.08
RflySimSDK说明文档
载入中...
搜索中...
未找到
vrpn_Tracker_RazerHydra.h
浏览该文件的文档.
1/** @file
2 @brief Header
3
4 @date 2011
5
6 @author
7 Ryan Pavlik
8 <rpavlik@iastate.edu> and <abiryan@ryand.net>
9 http://academic.cleardefinition.com/
10 Iowa State University Virtual Reality Applications Center
11 Human-Computer Interaction Graduate Program
12*/
13
14// Copyright Iowa State University 2011.
15// Distributed under the Boost Software License, Version 1.0.
16// (See accompanying file LICENSE_1_0.txt or copy at
17// http://www.boost.org/LICENSE_1_0.txt)
18
19#pragma once
20
21// Internal Includes
22#include "quat.h" // for q_vec_type
23#include "vrpn_Analog.h" // for vrpn_Analog
24#include "vrpn_Button.h" // for vrpn_Button_Filter
25#include "vrpn_Tracker.h" // for vrpn_Tracker
26
27// Library/third-party includes
28// - none
29
30// Standard includes
31// - none
32
33#ifdef VRPN_USE_HID
34
35#include "vrpn_HumanInterface.h"
36#include "vrpn_OwningPtr.h"
37
38/** @brief Device supporting the Razer Hydra game controller as a tracker,
39 analog device, and button device, using the USB HID protocol directly
40
41 The left wand (the one with LB and LT on its "end" buttons - look from above)
42 is sensor 0, and the right wand (with RB and RT on it) is sensor 1.
43 The "front" of the base is the side opposite the cables: there's a small
44 logo on it. You can have the base in any orientation you want, but the info
45 that follows assumes you have the base sitting on a desk, with the front toward you.
46 If you have the base in a different coordinate frame in the world, please make
47 the appropriate mental transformations yourself. :)
48
49 When starting the VRPN server, make sure that the left wand is somewhere to
50 the left of the base, and the right wand somewhere right of the base -
51 they do not need to be placed on the base or any more complicated homing/calibration
52 procedure. This is for the hemisphere tracking: it needs to have an "initial state"
53 that is roughly known, so it uses the sign of the X coordinate position.
54
55 (If you can't do this for whatever reason, modification of the driver code for an
56 alternate calibration procedure is possible.)
57
58 If using the Hydra on Windows, the server will work with or without the official
59 Razer Hydra drivers installed. If you are only using the device with VRPN, don't
60 install the official drivers. However, if you do have them installed, make sure that
61 the "Hydra Configurator" and the Hydra system tray icon are closed to avoid unexpected
62 failure (their software can switch the device out of the mode that VRPN uses).
63
64 Works great on Linux (regardless of endianness) - no drivers needed, thanks to USB HID.
65
66 The base coordinate system is right-handed with the axes:
67 * X - out the right of the base
68 * Y - out the front of the base
69 * Z - down
70
71 The wand coordinates are also right-handed, with the tracked point somewhere near
72 the cable entry to the controller. When held with the joystick vertical, the axes
73 are:
74 * X - to the right
75 * Y - out the front of the controller (trigger buttons)
76 * Z - Up, along the joystick
77
78 Buttons are as follows, with the right controller's button channels starting
79 at 7 instead of 0:
80 * 0 - "middle" button below joystick
81 * 1-4 - numbered buttons
82 * 5 - "bumper" button (above trigger)
83 * 6 - joystick button (if you push straight down on the joystick)
84
85 Analog channels are as follows, with the right controller starting at 3
86 instead of 0:
87 * 0 - joystick left/right: centered at 0, right is positive, in [-1, 1]
88 * 1 - joystick up/down: centered at 0, up is positive, in [-1, 1]
89 * 2 - analog trigger, in range 0 (not pressed) to 1 (fully pressed).
90*/
91
93{
94 public:
95 vrpn_Tracker_RazerHydra(const char* name, vrpn_Connection* con = NULL);
96 vrpn_Tracker_RazerHydra(const char* name, hid_device* ctrl_dev,
97 hid_device* data_dev,
98 vrpn_Connection* con = NULL);
99 vrpn_Tracker_RazerHydra(const char* name, const char* ctrl_dev_path,
100 const char* data_dev_path,
101 vrpn_Connection* con = NULL);
103
104 virtual void mainloop();
105
106 virtual bool reconnect();
107
108 private:
109 void _shared_init();
110 enum HydraStatus
111 {
112 HYDRA_WAITING_FOR_CONNECT,
113 HYDRA_LISTENING_AFTER_CONNECT,
114 HYDRA_LISTENING_AFTER_SET_FEATURE,
115 HYDRA_REPORTING
116 };
117
118 enum
119 {
120 ANALOG_CHANNELS = 6,
121 BUTTON_CHANNELS = 14,
122 POSE_CHANNELS = 2
123 };
124
125 void _swap_channels();
126 void _waiting_for_connect();
127 void _listening_after_connect();
128 void _listening_after_set_feature();
129
130 void _enter_motion_controller_mode();
131
132 void _report_for_sensor(int sensorNum, vrpn_uint8 * data, double dt);
133
134 HydraStatus status;
135 bool _wasInGamepadMode;
136 int _attempt;
137 struct timeval _timestamp;
138 struct timeval _connected;
139 struct timeval _set_feature;
140
141 const float _docking_distance;
142 bool _docked[POSE_CHANNELS];
143 bool _calibration_done[POSE_CHANNELS];
144 int _mirror[POSE_CHANNELS];
145 int _sign_x[POSE_CHANNELS];
146 q_vec_type _old_position[POSE_CHANNELS];
147
148 q_type _calibration_pose_conj[POSE_CHANNELS];
149
150 // This device has both a control and a data interface.
151 // On the mac, we may need to swap these because we can't tell which
152 // is which when we open them.
153 class MyInterface;
154
157};
158
159#else
160class VRPN_API vrpn_Tracker_RazerHydra;
161#endif
162
定义 vrpn_OwningPtr.h:74
定义 vrpn_Analog.h:28
定义 vrpn_Button.h:66
Generic connection class not specific to the transport mechanism.
定义 vrpn_Connection.h:562
Device supporting the Razer Hydra game controller as a tracker, analog device, and button device,...
定义 vrpn_Tracker_RazerHydra.h:93
virtual void mainloop()
定义 vrpn_Tracker.h:49