43 void seek(MessageBuffer::const_iterator& iter,
size_t offset)
56 char const* pData = &(*iter);
57 target = *((T
const*) pData);
59 seek(iter,
sizeof(T));
65 pOutEntityID = sourceID >> 16;
68 pOutMemberID = sourceID & 0x0000ffff;
73 void decode_timecode(
unsigned int inTimecode,
unsigned int inTimecodeSubframe,
int& hour,
int& minute,
int& second,
int& frame,
int& subframe)
75 hour = (inTimecode>>24)&255;
76 minute = (inTimecode>>16)&255;
77 second = (inTimecode>>8)&255;
78 frame = inTimecode&255;
79 subframe = inTimecodeSubframe;
83 void stringify_timecode(
unsigned int inTimecode,
unsigned int inTimecodeSubframe,
char *Buffer,
int BufferSize)
86 int hour, minute, second, frame, subframe;
87 decode_timecode(inTimecode, inTimecodeSubframe, hour, minute, second, frame, subframe);
89 snprintf(Buffer,BufferSize,
"%2d:%2d:%2d:%2d.%d",hour, minute, second, frame, subframe);
90 for(
unsigned int i=0; i < strlen(Buffer); i++)
108 pkt.numDataBytes = 0;
112 char *pBuffer = &msgBuffer[0];
113 memcpy(pBuffer, &pkt, msgBuffer.size());
121 char const* pBuffer = &msgBuffer[0];
122 natnet::Packet
const* packet = (natnet::Packet
const*)pBuffer;
124 int nver[4] = {0, 0, 0, 0};
125 int sver[4] = {0, 0, 0, 0};
126 for(
int i=0;i<4;++i) {
127 nver[i] = (int)(packet->data.sender.natNetVersion[i]);
128 sver[i] = (int)(packet->data.sender.version[i]);
136 MessageBuffer::const_iterator& msgBufferIter,
145 ROS_DEBUG(
" Pos: [%3.2f,%3.2f,%3.2f], Ori: [%3.2f,%3.2f,%3.2f,%3.2f]",
146 rigidBody.
pose.position.x,
147 rigidBody.
pose.position.y,
148 rigidBody.
pose.position.z,
149 rigidBody.
pose.orientation.x,
150 rigidBody.
pose.orientation.y,
151 rigidBody.
pose.orientation.z,
152 rigidBody.
pose.orientation.w);
169 ROS_DEBUG(
" Successfully tracked in this frame: %s",
180 MessageBuffer::const_iterator msgBufferIter = msgBuffer.begin();
194 int numMarkerSets = 0;
197 ROS_DEBUG(
"Marker set count: %d", numMarkerSets);
206 strcpy(markerSet.name, &(*msgBufferIter));
208 ROS_DEBUG(
" Marker set %d: %s", icnt++, markerSet.name);
213 markerSet.markers.resize(numMarkers);
214 ROS_DEBUG(
" Number of markers: %d", numMarkers);
217 for (
auto& marker : markerSet.markers)
221 ROS_DEBUG(
" Marker %d: [x=%3.2f,y=%3.2f,z=%3.2f]",
222 jcnt++, marker.x, marker.y, marker.z);
227 ROS_DEBUG(
"*** UNLABELED MARKERS (Deprecated) ***");
228 int numUnlabeledMarkers = 0;
231 ROS_DEBUG(
"Unlabled marker count: %d", numUnlabeledMarkers);
239 ROS_DEBUG(
" Marker %d: [x=%3.2f,y=%3.2f,z=%3.2f]",
240 icnt++, marker.x, marker.y, marker.z);
246 int numRigidBodies = 0;
249 ROS_DEBUG(
"Rigid count: %d", numRigidBodies);
264 int numSkeletons = 0;
266 ROS_DEBUG(
"Skeleton count: %d", numSkeletons);
269 for (
int j=0; j < numSkeletons; j++)
274 ROS_DEBUG(
"Skeleton ID: %d", skeletonId);
277 int numRigidBodies = 0;
279 ROS_DEBUG(
"Rigid body count: %d", numRigidBodies);
282 for (
int j=0; j < numRigidBodies; j++)
286 rigidBodyMessagePart.
deserialize(msgBufferIter, rigidBody, NatNetVersion);
297 int numLabeledMarkers = 0;
299 ROS_DEBUG(
"Labeled marker count: %d", numLabeledMarkers);
302 for (
int j=0; j < numLabeledMarkers; j++)
306 int modelId, markerId;
321 bool bOccluded = (params & 0x01) != 0;
323 bool bPCSolved = (params & 0x02) != 0;
325 bool bModelSolved = (params & 0x04) != 0;
329 bool bHasModel = (params & 0x08) != 0;
331 bool bUnlabeled = (params & 0x10) != 0;
333 bool bActiveMarker = (params & 0x20) != 0;
337 ROS_DEBUG(
" MarkerID: %d, ModelID: %d", markerId, modelId);
339 marker.
x, marker.
y, marker.
z);
346 float residual = 0.0f;
360 ROS_DEBUG(
"Force plate count: %d", numForcePlates);
361 for (
int iForcePlate = 0; iForcePlate < numForcePlates; iForcePlate++)
364 int forcePlateId = 0;
366 ROS_DEBUG(
"Force plate ID: %d", forcePlateId);
371 ROS_DEBUG(
" Number of channels: %d", numChannels);
374 for (
int i = 0; i < numChannels; i++)
379 for (
int j = 0; j < numFrames; j++)
396 ROS_DEBUG(
"Device count: %d", numDevices);
398 for (
int iDevice = 0; iDevice < numDevices; iDevice++)
410 for (
int i = 0; i < numChannels; i++)
415 for (
int j = 0; j < nFrames; j++)
434 unsigned int timecode = 0;
436 unsigned int timecodeSub = 0;
438 char szTimecode[128] =
"";
442 double timestamp = 0.0f;
451 float fTimestamp = 0.0f;
453 timestamp = (double)fTimestamp;
455 ROS_DEBUG(
"Timestamp: %3.3f", timestamp);
460 uint64_t cameraMidExposureTimestamp = 0;
462 ROS_DEBUG(
"Mid-exposure timestamp: %" PRIu64
"", cameraMidExposureTimestamp);
464 uint64_t cameraDataReceivedTimestamp = 0;
466 ROS_DEBUG(
"Camera data received timestamp: %" PRIu64
"", cameraDataReceivedTimestamp);
468 uint64_t transmitTimestamp = 0;
470 ROS_DEBUG(
"Transmit timestamp: %" PRIu64
"", transmitTimestamp);
477 bool bIsRecording = (params & 0x01) != 0;
479 bool bTrackedModelsChanged = (params & 0x02) != 0;
493 char const* pMsgBuffer = &msgBuffer[0];
494 natnet::Packet
const* packet = (natnet::Packet
const*)(pMsgBuffer);
508 ROS_WARN(
"Client has not received server info request. Parsing data message aborted.");
526 ROS_WARN(
"Received unrecognized request");
static void dispatch(MessageBuffer const &, mocap_optitrack::DataModel *)
Version const & getNatNetVersion() const
void seek(MessageBuffer::const_iterator &iter, size_t offset)
void deserialize(MessageBuffer::const_iterator &, mocap_optitrack::RigidBody &, mocap_optitrack::Version const &)
#define ROS_INFO_ONCE(...)
std::string const & getVersionString() const
static const int ServerInfo
Data object holding information about a single rigid body within a mocap skeleton.
virtual void deserialize(MessageBuffer const &, mocap_optitrack::DataModel *)
Data object holding poses of a tracked model's components.
static const int UnrecognizedRequest
std::vector< char > MessageBuffer
std::vector< RigidBody > rigidBodies
Version class containing the version information and helpers for comparison.
void read_and_seek(MessageBuffer::const_iterator &iter, T &target)
static const int FrameOfData
bool hasServerInfo() const
Version const & getServerVersion() const
void stringify_timecode(unsigned int inTimecode, unsigned int inTimecodeSubframe, char *Buffer, int BufferSize)
Data object holding the position of a single mocap marker in 3d space.
void decode_marker_id(int sourceID, int &pOutEntityID, int &pOutMemberID)
virtual void deserialize(MessageBuffer const &, mocap_optitrack::DataModel *)
The data model for this node.
void decode_timecode(unsigned int inTimecode, unsigned int inTimecodeSubframe, int &hour, int &minute, int &second, int &frame, int &subframe)
virtual void serialize(MessageBuffer &msgBuffer, mocap_optitrack::DataModel const *)
static const int ModelDef
std::vector< MarkerSet > markerSets
void setVersions(int *nver, int *sver)
std::vector< Marker > otherMarkers