vrpn
07.33
Virtual Reality Peripheral Network
|
Go to the documentation of this file.
13 const char * source,
const char * set_config,
24 FILE * fp = fopen(set_config,
"r");
26 fprintf(stderr,
"Can't open joy config file, using default..\n");
27 fprintf(stderr,
"Channel Accel 1.0, Power 1, Init Identity Matrix. \n");
28 for (i=0; i< 7; i++) {
32 for ( i =0; i< 4; i++)
33 for (
int j=0; j< 4; j++)
35 initMatrix[0][0] = initMatrix[2][2] =
36 initMatrix[1][1] = initMatrix[3][3] = 1.0;
38 for (i=0; i< 7; i++) {
39 if (fscanf(fp,
"%lf %d", &chanAccel[i], &chanPower[i]) != 2) {
40 fprintf(stderr,
"Cannot read acceleration and power from file\n");
43 fprintf(stderr,
"Chan[%d] = (%lf %d)\n", i, chanAccel[i], chanPower[i]);
46 for (
int j=0; j< 4; j++) {
47 if (fscanf(fp,
"%lf", &initMatrix[i][j]) < 0) {
48 perror(
"vrpn_Tracker_JoyFly::vrpn_Tracker_JoyFly(): Could not read matrix value");
55 q_matrix_copy(currentMatrix, initMatrix);
68 if (joy_remote != NULL)
72 fprintf(stderr,
"Sending a report\n");
80 "\nvrpn_Tracker_Flock: cannot write message ... tossing");
82 fprintf(stderr,
"\nvrpn_Tracker_Flock: No valid connection");
89 #define ONE_SEC (1000000l)
94 double tx, ty, tz, rx, ry, rz;
102 printf(
"Joy total = %d,Chan[0] = %lf\n",
105 if (pts->prevtime.tv_sec == -1) {
108 deltaT = (pts->prevtime.tv_sec*
ONE_SEC + pts->prevtime.tv_usec) -
113 memcpy(&(pts->prevtime), &b.
msg_time,
sizeof(
struct timeval));
115 for (i=0; i< 7; i++) {
119 for (j=0; j< pts->chanPower[i]; j++)
122 temp[i] *= pts->chanAccel[i];
124 temp[i] = -fabs(temp[i]) * pts->chanAccel[i];
144 q_euler_to_col_matrix(newM, rz, ry, rx);
145 newM[3][0] = tx; newM[3][1] = ty; newM[3][2] = tz;
155 q_matrix_mult(
final, newM, currentMatrix);
156 q_matrix_copy(currentMatrix,
final);
157 q_row_matrix_to_xyz_quat( & xq, currentMatrix);
161 for (i=0; i< 3; i++) {
164 printf(
"(x, y, z)= %lf %lf %lf\n",
pos[0],
pos[1],
pos[2]);
165 for (i=0; i< 4; i++) {
175 printf(
"Get a new connection, reset virtual_Tracker\n");
181 q_matrix_copy(currentMatrix, initMatrix);
182 prevtime.tv_sec = -1;
183 prevtime.tv_usec = -1;
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...
const char * vrpn_got_connection
virtual int encode_to(char *buf)
virtual void mainloop(void)
Called once through each main loop iteration to handle updates. Remote object mainloop() should call ...
void update(q_matrix_type &)
const int vrpn_TRACKER_REPORT_READY
const vrpn_uint32 vrpn_CONNECTION_LOW_LATENCY
vrpn_Connection * d_connection
Connection that this object talks to.
virtual vrpn_int32 register_message_type(const char *name)
vrpn_Tracker_JoyFly(const char *name, vrpn_Connection *c, const char *source, const char *config_file_name, vrpn_Connection *sourceConnection=NULL)
This object has been superceded by the vrpn_Tracker_AnalogFly object.
This structure is what is passed to a vrpn_Connection message callback.
static int VRPN_CALLBACK handle_newConnection(void *, vrpn_HANDLERPARAM)
vrpn_int32 d_sender_id
Sender ID registered with the connection.
virtual ~vrpn_Tracker_JoyFly(void)
static void VRPN_CALLBACK handle_joystick(void *, const vrpn_ANALOGCB)
vrpn_float64 channel[vrpn_CHANNEL_MAX]
virtual void mainloop()
Called once through each main loop iteration to handle updates. Remote object mainloop() should call ...
Generic connection class not specific to the transport mechanism.
const int vrpn_TRACKER_SYNCING
virtual int register_handler(vrpn_int32 type, vrpn_MESSAGEHANDLER handler, void *userdata, vrpn_int32 sender=vrpn_ANY_SENDER)
Set up (or remove) a handler for a message of a given type. Optionally, specify which sender to handl...
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...