vrpn
07.33
Virtual Reality Peripheral Network
|
Go to the documentation of this file.
10 #define M_PI 3.14159265358979323846
16 bool absolute,
bool reportChanges,
20 d_which_button (params->reset_which),
21 d_clutch_button(NULL),
22 d_clutch_which (params->clutch_which),
23 d_clutch_engaged(false),
24 d_clutch_was_off(false),
25 d_update_interval (update_rate ? (1/update_rate) : 1.0),
26 d_absolute (absolute),
27 d_reportChanges (reportChanges),
28 d_worldFrame (worldFrame)
77 fprintf(stderr,
"vrpn_Tracker_AnalogFly: "
107 fprintf(stderr,
"vrpn_Tracker_AnalogFly: "
132 for ( i =0; i< 4; i++) {
133 for (
int j=0; j< 4; j++) {
191 double value_offset = value - full->
axis.
offset;
192 double value_abs = fabs(value_offset);
197 full->
af->vrpn_Tracker::timestamp = info.
msg_time;
201 if (value_abs <= full->axis.thresh) {
207 if (value_offset >=0) {
239 if (info.
state == 1) {
254 if (full->
axis.
name == NULL) {
return 0; }
263 printf(
"vrpn_Tracker_AnalogFly: Adding local analog %s\n",
269 printf(
"vrpn_Tracker_AnalogFly: Adding remote analog %s\n",
273 if (full->
ana == NULL) {
274 fprintf(stderr,
"vrpn_Tracker_AnalogFly: "
275 "Can't open Analog %s\n",full->
axis.
name);
291 if (full->
ana == NULL) {
return 0; }
308 printf(
"Get a new connection, reset virtual_Tracker\n");
382 fprintf(stderr,
"Tracker AnalogFly: "
383 "cannot write message: tossing\n");
386 fprintf(stderr,
"Tracker AnalogFly: "
387 "No valid connection\n");
414 (
double time_interval)
416 double tx,ty,tz, rx,ry,rz;
433 q_euler_to_col_matrix(diffM, rz, ry, rx);
434 diffM[3][0] = tx; diffM[3][1] = ty; diffM[3][2] = tz;
452 q_from_euler(diff_orient, rz, ry, rx);
453 q_xyz_quat_type diff;
454 q_vec_set(diff.xyz, tx, ty, tz);
455 q_copy(diff.quat, diff_orient);
456 q_xyz_quat_type diff_inverse;
457 q_xyz_quat_invert(&diff_inverse, &diff);
458 q_matrix_type di_matrix;
459 q_to_col_matrix(di_matrix, diff_inverse.quat);
460 di_matrix[3][0] = diff_inverse.xyz[0];
461 di_matrix[3][1] = diff_inverse.xyz[1];
462 di_matrix[3][2] = diff_inverse.xyz[2];
482 diffM[3][0] = 0; diffM[3][1] = 0; diffM[3][2] = 0;
508 for (i=0; i< 3; i++) {
511 for (i=0; i< 4; i++) {
517 (
double elapsedInterval)
const {
q_matrix_type d_clutchMatrix
int register_autodeleted_handler(vrpn_int32 type, vrpn_MESSAGEHANDLER handler, void *userdata, vrpn_int32 sender=vrpn_ANY_SENDER)
Registers a handler with the connection, and remembers to delete at destruction.
virtual int pack_message(vrpn_uint32 len, struct timeval time, vrpn_int32 type, vrpn_int32 sender, const char *buffer, vrpn_uint32 class_of_service)
Pack a message that will be sent the next time mainloop() is called. Turn off the RELIABLE flag if yo...
static void VRPN_CALLBACK handle_analog_update(void *userdata, const vrpn_ANALOGCB info)
virtual int encode_to(char *buf)
double vrpn_TimevalDurationSeconds(struct timeval endT, struct timeval startT)
Return the number of seconds between startT and endT as a floating-point value.
vrpn_Button_Remote * d_reset_button
char * clutch_name
Clutch device that is used to enable relative motion over.
const char * vrpn_got_first_connection
These are the strings that define the system-generated message types that tell when connections are r...
virtual void mainloop()
Called once through each main loop iteration to handle updates. Remote object mainloop() should call ...
vrpn_TAF_axis sx
Rotation in the positive direction about the three axes.
q_matrix_type d_currentMatrix
int teardown_channel(vrpn_TAF_fullaxis *full)
const vrpn_uint32 vrpn_CONNECTION_LOW_LATENCY
vrpn_Tracker_AnalogFly * af
vrpn_Connection * d_connection
Connection that this object talks to.
This class will turn an analog device such as a joystick or a camera.
static void VRPN_CALLBACK handle_clutch_press(void *userdata, const vrpn_BUTTONCB info)
virtual vrpn_int32 register_message_type(const char *name)
virtual ~vrpn_Tracker_AnalogFly(void)
This structure is what is passed to a vrpn_Connection message callback.
char * reset_name
Button device that is used to reset the matrix to the origin.
void update_matrix_based_on_values(double time_interval)
vrpn_int32 d_sender_id
Sender ID registered with the connection.
vrpn_Button_Remote * d_clutch_button
int setup_channel(vrpn_TAF_fullaxis *full)
void convert_matrix_to_tracker(void)
vrpn_float64 channel[vrpn_CHANNEL_MAX]
virtual void reset(void)
Reset the current matrix to zero and store it into the tracker position/quaternion location.
q_matrix_type d_initMatrix
virtual int unregister_change_handler(void *userdata, vrpn_ANALOGCHANGEHANDLER handler)
virtual void mainloop()
Called once through each main loop iteration to handle updates. Remote object mainloop() should call ...
vrpn_TAF_axis x
Translation along each of these three axes.
Generic connection class not specific to the transport mechanism.
#define vrpn_gettimeofday
struct timeval d_prevtime
static int VRPN_CALLBACK handle_newConnection(void *, vrpn_HANDLERPARAM)
vrpn_Tracker_AnalogFly(const char *name, vrpn_Connection *trackercon, vrpn_Tracker_AnalogFlyParam *params, float update_rate, bool absolute=vrpn_FALSE, bool reportChanges=VRPN_FALSE, bool worldFrame=VRPN_FALSE)
virtual int register_change_handler(void *userdata, vrpn_ANALOGCHANGEHANDLER handler)
void server_mainloop(void)
Handles functions that all servers should provide in their mainloop() (ping/pong, for example) Should...
static void VRPN_CALLBACK handle_reset_press(void *userdata, const vrpn_BUTTONCB info)
bool shouldReport(double elapsedInterval) const