/* This function must only be called after startNewRigidBody has been called. */ bool vrpn_Tracker_PhaseSpace::addRigidMarker(int sensor, int led_id, float x, float y, float z) { #ifdef DEBUG printf("%s %d %d %f %f %f\n", __PRETTY_FUNCTION__, sensor, led_id, x, y, z); #endif if(!owlRunning) return false; if(slave) return false; if(numRigids == 0) { fprintf(stderr, "Error: Attempting to add rigid body marker with no rigid body defined."); return false; } if(numMarkers >= VRPN_PHASESPACE_MAXMARKERS) { fprintf(stderr, "Error: Maximum markers (%d) exceeded.\n", VRPN_PHASESPACE_MAXMARKERS); return false; } float xyz[3]; xyz[0] = x; xyz[1] = y; xyz[2] = z; owlMarkeri(MARKER(numRigids,sensor),OWL_SET_LED,led_id); owlMarkerfv(MARKER(numRigids,sensor),OWL_SET_POSITION,&xyz[0]); if(!owlGetStatus()) return false; numMarkers++; return true; }
bool vrpn_Tracker_PhaseSpace::addMarker(int sensor,int led_id) { #ifdef DEBUG printf("%s %d %d\n", __PRETTY_FUNCTION__, sensor, led_id); #endif if(!owlRunning) return false; if(slave) return false; if(numMarkers >= VRPN_PHASESPACE_MAXMARKERS) { fprintf(stderr, "Error: Maximum markers (%d) exceeded.\n", VRPN_PHASESPACE_MAXMARKERS); return false; } owlMarkeri(MARKER(0,sensor),OWL_SET_LED,led_id); if(!owlGetStatus()) return false; numMarkers++; return true; }
void PhasespaceCore::initializeCommunication() { ROS_INFO_STREAM("[PhaseSpace] Initalizing the PhaseSpace..."); // opens a socket and configures the communication channels to pass data between the OWL server and client; this // function will block until there is a connection or an error; returns the passed flags if OK if (owlInit(server_ip_.c_str(), init_flags_) < 0) { ROS_FATAL_STREAM("[PhaseSpace] Can't initialize the communication with OWL server: " << owlGetError()); throw excp_; } // initializes a point tracker: // - OWL_CREATE: tells the system to create a tracker // - OWL_POINT_TRACKER: specifies the creation of a point tracker owlTrackeri(tracker_, OWL_CREATE, OWL_POINT_TRACKER); // creates the marker structures, each with the proper id: // - MARKER Macro: builds a marker id out of a tracker id and marker index // - OWL_SET_LED: the following 'i' is an integer representing the LED ID of the marker for (int i=0; i<init_marker_count_; i++) { owlMarkeri(MARKER(tracker_, i), OWL_SET_LED, i); } // enables the tracker (it has to be disabled when the markers have to be added) owlTracker(tracker_, OWL_ENABLE); // checking the status will block until all commands are processed and any errors are sent to the client if (!owlGetStatus()) { ROS_FATAL_STREAM("[PhaseSpace] Initialization generic error: " << owlGetError()); throw excp_; } // sets frequency with default maximum value (OWL_MAX_FREQUENCY = 480 Hz): // - OWL_FREQUENCY: specifies the rate at which the server streams data owlSetFloat(OWL_FREQUENCY, OWL_MAX_FREQUENCY); // enables the streaming of data owlSetInteger(OWL_STREAMING, OWL_ENABLE); }