vrpn
07.33
Virtual Reality Peripheral Network
|
Go to the documentation of this file.
66 fprintf(stderr,
"Quat: %lf, %lf, %lf, %lf\n",
p_quat[0],
p_quat[1],
73 fprintf(stderr,
"Quat: %lf, %lf, %lf, %lf\n",
p_vel_quat[0],
85 "vrpn_Poser Request Relative Pos_Quat");
89 "vrpn_Poser Request Relative Velocity");
133 return 1000 - buflen;
156 return 1000 - buflen;
160 const vrpn_float64 quaternion[4])
172 const vrpn_float64 position_delta[3],
173 const vrpn_float64 quaternion[4])
180 p_pos[0] += position_delta[0];
181 p_pos[1] += position_delta[1];
182 p_pos[2] += position_delta[2];
187 const vrpn_float64 velocity[3],
188 const vrpn_float64 quaternion[4],
189 const vrpn_float64 interval)
204 const timeval t,
const vrpn_float64 velocity_delta[3],
205 const vrpn_float64 quaternion[4],
const vrpn_float64 interval_delta)
212 p_vel[0] += velocity_delta[0];
213 p_vel[1] += velocity_delta[1];
214 p_vel[2] += velocity_delta[2];
231 fprintf(stderr,
"vrpn_Poser_Server: No connection\n");
238 fprintf(stderr,
"vrpn_Poser_Server: can't register position handler\n");
249 "vrpn_Poser_Server: can't register relative position handler\n");
256 fprintf(stderr,
"vrpn_Poser_Server: can't register velocity handler\n");
265 fprintf(stderr,
"vrpn_Poser_Server: can't register velocity handler\n");
280 const char* params = (p.
buffer);
286 fprintf(stderr,
"vrpn_Poser_Server: change message payload error\n");
287 fprintf(stderr,
" (got %d, expected %lud)\n", p.
payload_len,
288 static_cast<unsigned long>(7 *
sizeof(vrpn_float64)));
293 for (i = 0; i < 3; i++) {
296 for (i = 0; i < 4; i++) {
301 for (i = 0; i < 3; i++) {
312 memcpy(cp.pos, me->
p_pos,
sizeof(cp.pos));
313 memcpy(cp.quat, me->
p_quat,
sizeof(cp.quat));
325 const char* params = (p.
buffer);
330 fprintf(stderr,
"vrpn_Poser_Server: change message payload error\n");
331 fprintf(stderr,
" (got %d, expected %lud)\n", p.
payload_len,
332 static_cast<unsigned long>(7 *
sizeof(vrpn_float64)));
337 vrpn_float64 dp[3], dq[4];
338 for (i = 0; i < 3; i++) {
341 for (i = 0; i < 4; i++) {
346 for (i = 0; i <= 2; i++)
347 me->
p_pos[i] += dp[i];
351 for (i = 0; i < 3; i++) {
363 memcpy(cp.pos, dp,
sizeof(cp.pos));
364 memcpy(cp.quat, dq,
sizeof(cp.quat));
375 const char* params = (p.
buffer);
380 fprintf(stderr,
"vrpn_Poser_Server: velocity message payload error\n");
381 fprintf(stderr,
" (got %d, expected %lud)\n", p.
payload_len,
382 static_cast<unsigned long>(8 *
sizeof(vrpn_float64)));
387 for (i = 0; i < 3; i++) {
390 for (i = 0; i < 4; i++) {
396 for (i = 0; i < 3; i++) {
411 const char* params = (p.
buffer);
416 fprintf(stderr,
"vrpn_Poser_Server: velocity message payload error\n");
417 fprintf(stderr,
" (got %d, expected %lud)\n", p.
payload_len,
418 static_cast<unsigned long>(8 *
sizeof(vrpn_float64)));
423 vrpn_float64 dv[3], dq[4], di;
424 for (i = 0; i < 3; i++) {
427 for (i = 0; i < 4; i++) {
433 for (i = 0; i < 2; i++)
434 me->
p_vel[i] += dv[i];
439 for (i = 0; i < 3; i++) {
464 fprintf(stderr,
"vrpn_Poser_Remote: No connection\n");
489 const vrpn_float64 position[3],
490 const vrpn_float64 quaternion[4])
497 fprintf(stderr,
"vrpn_Poser_Remote: request_pose failed\n");
505 const struct timeval t,
const vrpn_float64 position_delta[3],
506 const vrpn_float64 quaternion[4])
513 fprintf(stderr,
"vrpn_Poser_Remote: request_pose_relative failed\n");
521 const vrpn_float64 velocity[3],
522 const vrpn_float64 quaternion[4],
523 const vrpn_float64 interval)
530 fprintf(stderr,
"vrpn_Poser_Remote: request_pose_velocity failed\n");
538 const struct timeval t,
const vrpn_float64 velocity_delta[3],
539 const vrpn_float64 quaternion[4],
const vrpn_float64 interval_delta)
547 "vrpn_Poser_Remote: request_pose_velocity_relative failed\n");
564 fprintf(stderr,
"vrpn_Poser_Remote: can't write a message: tossing\n");
581 fprintf(stderr,
"vrpn_Poser_Remote: can't write a message: tossing\n");
598 fprintf(stderr,
"vrpn_Poser_Remote: can't write a message: tossing\n");
615 fprintf(stderr,
"vrpn_Poser_Remote: can't write a message: tossing\n");
vrpn_Poser_Remote(const char *name, vrpn_Connection *c=NULL)
vrpn_float64 p_vel_rot_max[3]
virtual int encode_to(char *buf)
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...
void client_mainloop(void)
Handles functions that all clients should provide in their mainloop() (warning of no server,...
vrpn_Callback_List< vrpn_POSERCB > d_relative_callback_list
virtual int client_send_pose()
virtual void set_pose_velocity_relative(const struct timeval t, const vrpn_float64 velocity_delta[3], const vrpn_float64 quaternion[4], const vrpn_float64 interval_delta)
static int VRPN_CALLBACK handle_change_message(void *userdata, vrpn_HANDLERPARAM p)
virtual void mainloop()
This function should be called each time through app mainloop.
vrpn_float64 p_vel_quat[4]
int request_pose(const struct timeval t, const vrpn_float64 position[3], const vrpn_float64 quaternion[4])
static int VRPN_CALLBACK handle_relative_change_message(void *userdata, vrpn_HANDLERPARAM p)
vrpn_float64 p_vel_min[3]
virtual void set_pose_velocity(const struct timeval t, const vrpn_float64 position[3], const vrpn_float64 quaternion[4], const vrpn_float64 interval)
vrpn_Poser(const char *name, vrpn_Connection *c=NULL)
static int VRPN_CALLBACK handle_vel_change_message(void *userdata, vrpn_HANDLERPARAM p)
virtual void set_pose_relative(const struct timeval t, const vrpn_float64 position_delta[3], const vrpn_float64 quaternion[4])
virtual int register_types(void)
Register the types of messages this device sends/receives. Return 0 on success, -1 on fail.
const vrpn_uint32 vrpn_CONNECTION_LOW_LATENCY
VRPN_API int vrpn_unbuffer(const char **buffer, timeval *t)
Utility routine for taking a struct timeval from a buffer that was sent as a message.
vrpn_float64 p_pos_rot_max[3]
vrpn_int32 req_velocity_m_id
vrpn_Connection * d_connection
Connection that this object talks to.
virtual vrpn_int32 register_message_type(const char *name)
vrpn_float64 p_pos_rot_min[3]
This structure is what is passed to a vrpn_Connection message callback.
vrpn_int32 d_sender_id
Sender ID registered with the connection.
vrpn_int32 req_velocity_relative_m_id
virtual ~vrpn_Poser_Remote(void)
vrpn_float64 p_pos_max[3]
virtual int mainloop(const struct timeval *timeout=NULL)=0
Call each time through program main loop to handle receiving any incoming messages and sending any pa...
virtual void mainloop()
Called once through each main loop iteration to handle updates. Remote object mainloop() should call ...
vrpn_Callback_List< vrpn_POSERCB > d_callback_list
Generic connection class not specific to the transport mechanism.
int request_pose_velocity_relative(const struct timeval t, const vrpn_float64 velocity_delta[3], const vrpn_float64 quaternion[4], const vrpn_float64 interval_delta)
virtual int client_send_pose_velocity()
int request_pose_relative(const struct timeval t, const vrpn_float64 position_delta[3], const vrpn_float64 quaternion[4])
#define vrpn_gettimeofday
virtual void set_pose(const struct timeval t, const vrpn_float64 position[3], const vrpn_float64 quaternion[4])
vrpn_float64 p_vel_rot_min[3]
vrpn_int32 req_position_relative_m_id
virtual int client_send_pose_velocity_relative()
virtual int encode_vel_to(char *buf)
vrpn_Poser_Server(const char *name, vrpn_Connection *c)
virtual ~vrpn_Poser(void)
virtual int init(void)
Initialize things that the constructor can't. Returns 0 on success, -1 on failure.
vrpn_float64 p_pos_min[3]
VRPN_API int vrpn_buffer(char **insertPt, vrpn_int32 *buflen, const timeval t)
Utility routine for placing a timeval struct into a buffer that is to be sent as a message.
vrpn_float64 p_vel_quat_dt
void call_handlers(const CALLBACK_STRUCT &info)
This will pass the referenced parameter as a const to all the callbacks.
vrpn_float64 p_vel_max[3]
static int VRPN_CALLBACK handle_relative_vel_change_message(void *userdata, vrpn_HANDLERPARAM p)
virtual int client_send_pose_relative()
vrpn_int32 req_position_m_id
int request_pose_velocity(const struct timeval t, const vrpn_float64 velocity[3], const vrpn_float64 quaternion[4], const vrpn_float64 interval)
void server_mainloop(void)
Handles functions that all servers should provide in their mainloop() (ping/pong, for example) Should...
struct timeval p_timestamp
Class from which all user-level (and other) classes that communicate with vrpn_Connections should der...