00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023 INLINE const string &VrpnClient::
00024 get_server_name() const {
00025 return _server_name;
00026 }
00027
00028
00029
00030
00031
00032
00033
00034
00035 INLINE bool VrpnClient::
00036 is_valid() const {
00037 return (_connection->doing_okay() != 0);
00038 }
00039
00040
00041
00042
00043
00044
00045
00046 INLINE bool VrpnClient::
00047 is_connected() const {
00048 return (_connection->connected() != 0);
00049 }
00050
00051
00052
00053
00054
00055
00056
00057
00058 INLINE double VrpnClient::
00059 convert_to_secs(struct timeval msg_time) {
00060 return (double)(msg_time.tv_sec) + (double)msg_time.tv_usec * 0.000001;
00061 }
00062
00063
00064
00065
00066 #if 0
00067
00068
00069
00070
00071
00072
00073 INLINE VrpnClient::
00074 VrpnClient(const string &server) :
00075 ClientBase(server)
00076 {
00077 _connection = vrpn_get_connection_by_name(server.c_str());
00078 }
00079
00080
00081
00082
00083
00084
00085
00086
00087 INLINE void VrpnClient::
00088 tracker_position(const string &tracker, const vrpn_TRACKERCB info) {
00089 double ptime = convert_to_secs(info.msg_time);
00090 LPoint3 pos(info.pos[0], info.pos[1], info.pos[2]);
00091 LVector4 pquat(info.quat[0], info.quat[1], info.quat[2], info.quat[3]);
00092
00093 push_tracker_position(tracker, info.sensor, ptime, pos, pquat);
00094 }
00095
00096
00097
00098
00099
00100
00101
00102
00103 INLINE void VrpnClient::
00104 tracker_velocity(const string &tracker, const vrpn_TRACKERVELCB info) {
00105 double vtime = convert_to_secs(info.msg_time);
00106 LPoint3 vel(info.vel[0], info.vel[1], info.vel[2]);
00107 LVector4 vquat(info.vel_quat[0], info.vel_quat[1],
00108 info.vel_quat[2], info.vel_quat[3]);
00109 PN_stdfloat dt = info.vel_quat_dt;
00110
00111 push_tracker_velocity(tracker, info.sensor, vtime, vel, vquat, dt);
00112 }
00113
00114
00115
00116
00117
00118
00119
00120 INLINE void VrpnClient::
00121 tracker_acceleration(const string &tracker, const vrpn_TRACKERACCCB info) {
00122 double atime = convert_to_secs(info.msg_time);
00123 LPoint3 acc(info.acc[0], info.acc[1], info.acc[2]);
00124 LVector4 aquat(info.acc_quat[0], info.acc_quat[1],
00125 info.acc_quat[2], info.acc_quat[3]);
00126 PN_stdfloat dt = info.acc_quat_dt;
00127
00128 push_tracker_acceleration(tracker, info.sensor, atime, acc, aquat, dt);
00129 }
00130
00131
00132
00133
00134
00135
00136
00137 INLINE void VrpnClient::
00138 analog(const string &analog, const vrpn_ANALOGCB info) {
00139 double atime = convert_to_secs(info.msg_time);
00140
00141 push_analog(analog, atime, info.channel, info.num_channel);
00142 }
00143
00144
00145
00146
00147
00148
00149
00150 INLINE void VrpnClient::
00151 button(const string &button, const vrpn_BUTTONCB info) {
00152 double btime = convert_to_secs(info.msg_time);
00153
00154 push_button(button, btime, info.button, info.state);
00155 }
00156
00157
00158
00159
00160
00161
00162
00163 INLINE void VrpnClient::
00164 dial(const string &dial, const vrpn_DIALCB info) {
00165 double dtime = convert_to_secs(info.msg_time);
00166
00167 push_dial(dial, dtime, info.dial, info.change);
00168 }
00169
00170 #endif