OSVR-Core
LocomotionComponent.h
Go to the documentation of this file.
1 
11 // Copyright 2015 Sensics, Inc.
12 //
13 // Licensed under the Apache License, Version 2.0 (the "License");
14 // you may not use this file except in compliance with the License.
15 // You may obtain a copy of the License at
16 //
17 // http://www.apache.org/licenses/LICENSE-2.0
18 //
19 // Unless required by applicable law or agreed to in writing, software
20 // distributed under the License is distributed on an "AS IS" BASIS,
21 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
22 // See the License for the specific language governing permissions and
23 // limitations under the License.
24 
25 #ifndef INCLUDED_LocomotionComponent_h_GUID_60F8A9AB_1531_4AB4_E842_89EBB4851EE5
26 #define INCLUDED_LocomotionComponent_h_GUID_60F8A9AB_1531_4AB4_E842_89EBB4851EE5
27 
28 // Internal Includes
29 #include <osvr/Common/Export.h>
34 
36 
37 // Library/third-party includes
38 #include <vrpn_BaseClass.h>
39 
40 // Standard includes
41 // - none
42 
43 namespace osvr {
44 namespace common {
45 
47  OSVR_ChannelCount sensor;
48  OSVR_NaviVelocityState naviVelState;
49  };
50 
52  OSVR_ChannelCount sensor;
53  OSVR_NaviPositionState naviPosnState;
54  };
55 
56  namespace messages {
58  : public MessageRegistration<NaviVelocityRecord> {
59  public:
61 
62  static const char *identifier();
63  };
64 
66  : public MessageRegistration<NaviPositionRecord> {
67  public:
69 
70  static const char *identifier();
71  };
72 
73  } // namespace messages
74 
77  public:
82  static OSVR_COMMON_EXPORT shared_ptr<LocomotionComponent> create();
83 
86 
90 
91  OSVR_COMMON_EXPORT void
92  sendNaviVelocityData(OSVR_NaviVelocityState naviVelState,
93  OSVR_ChannelCount sensor,
94  OSVR_TimeValue const &timestamp);
95 
96  OSVR_COMMON_EXPORT void
97  sendNaviPositionData(OSVR_NaviPositionState naviPosnState,
98  OSVR_ChannelCount sensor,
99  OSVR_TimeValue const &timestamp);
100 
101  typedef std::function<void(NaviVelocityData const &,
102  util::time::TimeValue const &)>
103  NaviVelocityHandler;
104 
105  typedef std::function<void(NaviPositionData const &,
106  util::time::TimeValue const &)>
107  NaviPositionHandler;
108 
109  OSVR_COMMON_EXPORT void
110  registerNaviVelocityHandler(NaviVelocityHandler cb);
111  OSVR_COMMON_EXPORT void
112  registerNaviPositionHandler(NaviPositionHandler cb);
113 
114  private:
116  virtual void m_parentSet();
117 
118  static int VRPN_CALLBACK
119  m_handleNaviVelocityRecord(void *userdata, vrpn_HANDLERPARAM p);
120  static int VRPN_CALLBACK
121  m_handleNaviPositionRecord(void *userdata, vrpn_HANDLERPARAM p);
122 
123  std::vector<NaviVelocityHandler> m_cb_vel;
124  std::vector<NaviPositionHandler> m_cb_posn;
125 
127  common::CommonComponent *m_commonComponent;
128  };
129 
130 } // namespace common
131 } // namespace osvr
132 
133 #endif // INCLUDED_LocomotionComponent_h_GUID_60F8A9AB_1531_4AB4_E842_89EBB4851EE5
uint32_t OSVR_ChannelCount
The integer type specifying a number of channels/sensors or a channel/sensor index.
Definition: ChannelCountC.h:51
Handles spatial transformations.
Definition: SerializationTraitExample_Complicated.h:40
messages::NaviVelocityRecord naviVelRecord
Message from server to client, containing navigation velocity.
Definition: LocomotionComponent.h:85
Definition: CommonComponent.h:44
The main namespace for all C++ elements of the framework, internal and external.
Definition: namespace_osvr.dox:3
Definition: LocomotionComponent.h:65
BaseDevice component, for the VRPN built-in common messages.
Definition: CommonComponent.h:82
Definition: LocomotionComponent.h:57
BaseDevice component.
Definition: LocomotionComponent.h:76
Definition: DeviceComponent.h:42
Definition: LocomotionComponent.h:46
CRTP class template wrapping message-specific data and/or logic.
Definition: MessageRegistration.h:44
A structure defining a 2D vector, which represents position.
Definition: Vec2C.h:48
Definition: LocomotionComponent.h:51
Standardized, portable parallel to struct timeval for representing both absolute times and time inter...
Definition: TimeValueC.h:81
messages::NaviPositionRecord naviPosnRecord
Optional message from server to client, containing navigation position.
Definition: LocomotionComponent.h:89