channel.cc
Go to the documentation of this file.
1 
39 
47 
49 
50 #ifdef WIN32
51 #include <ws2tcpip.h>
52 #else
53 #include <netdb.h>
54 #endif
55 #include <errno.h>
56 #include <fcntl.h>
57 
58 namespace crl {
59 namespace multisense {
60 namespace details {
61 
62 //
63 // Implementation constructor
64 
65 impl::impl(const std::string& address, const RemoteHeadChannel& cameraId, const std::string& ifName) :
66  m_serverSocket(INVALID_SOCKET),
67  m_serverSocketPort(0),
68  m_sensorAddress(),
69  m_sensorMtu(MAX_MTU_SIZE),
70  m_incomingBuffer(MAX_MTU_SIZE),
71  m_txSeqId(0),
72  m_lastRxSeqId(-1),
73  m_unWrappedRxSeqId(0),
74  m_udpTrackerCache(UDP_TRACKER_CACHE_DEPTH),
75  m_rxLargeBufferPool(),
76  m_rxSmallBufferPool(),
77  m_imageMetaCache(IMAGE_META_CACHE_DEPTH),
78  m_udpAssemblerMap(),
79  m_dispatchLock(),
80  m_streamLock(),
81  m_threadsRunning(false),
82  m_rxThreadP(NULL),
83  m_rxLock(),
84  m_statusThreadP(NULL),
85  m_imageListeners(),
86  m_lidarListeners(),
87  m_ppsListeners(),
88  m_imuListeners(),
89  m_compressedImageListeners(),
90  m_watch(),
91  m_messages(),
92  m_streamsEnabled(0),
93  m_timeLock(),
94  m_timeOffsetInit(false),
95  m_timeOffset(0),
96  m_networkTimeSyncEnabled(true),
97  m_ptpTimeSyncEnabled(false),
98  m_sensorVersion()
99 {
100 
101 #if WIN32
102  WSADATA wsaData;
103  int result = WSAStartup (MAKEWORD (0x02, 0x02), &wsaData);
104  if (result != 0)
105  CRL_EXCEPTION("WSAStartup() failed: %d", result);
106 
107 #endif
108 
109  struct addrinfo hints, *res;
110  memset(&hints, 0, sizeof(hints));
111  hints.ai_family = AF_INET;
112  hints.ai_socktype = 0;
113 
114  const int addrstatus = getaddrinfo(address.c_str(), NULL, &hints, &res);
115  if (addrstatus != 0 || res == NULL)
116  CRL_EXCEPTION("unable to resolve \"%s\": %s", address.c_str(), strerror(errno));
117 
118  in_addr addr;
119  memcpy(&addr, &(((struct sockaddr_in *)(res->ai_addr))->sin_addr), sizeof(in_addr));
120 
121  memset(&m_sensorAddress, 0, sizeof(m_sensorAddress));
122 
123  m_sensorAddress.sin_family = AF_INET;
124  m_sensorAddress.sin_port = htons(DEFAULT_SENSOR_TX_PORT + static_cast<uint16_t>(cameraId + 1));
125  m_sensorAddress.sin_addr = addr;
126 
127  freeaddrinfo(res);
128 
129  //
130  // Create a pool of RX buffers
131 
132  uint32_t largeBufferRetry = 0;
133  for(uint32_t i=0; i<RX_POOL_LARGE_BUFFER_COUNT;)
134  {
135  try {
137  i++;
138  largeBufferRetry = 0;
139  }
140  catch (const std::exception &e) {
141  CRL_DEBUG("Failed to allocate memory (will sleep and try again): %s", e.what());
142  usleep(static_cast<unsigned int> (10000));
143  largeBufferRetry++;
144 
145  if (largeBufferRetry >= MAX_BUFFER_ALLOCATION_RETRIES)
146  throw e;
147  }
148  }
149 
150  uint32_t smallBufferRetry = 0;
151  for(uint32_t i=0; i<RX_POOL_SMALL_BUFFER_COUNT;)
152  {
153  try {
155  i++;
156  smallBufferRetry = 0;
157  }
158  catch (const std::exception &e) {
159  CRL_DEBUG("Failed to allocate memory (will sleep and try again): %s", e.what());
160  usleep(static_cast<unsigned int> (10000));
161  smallBufferRetry++;
162 
163  if (smallBufferRetry >= MAX_BUFFER_ALLOCATION_RETRIES)
164  throw e;
165  }
166  }
167 
168  //
169  // Bind to the port
170 
171  try {
172  bind(ifName);
173  } catch (const std::exception& e) {
174  CRL_DEBUG("exception: %s\n", e.what());
175  cleanup();
176  throw e;
177  }
178 
179  //
180  // Register any special UDP reassemblers
181 
183 
184  //
185  // Create UDP reception thread
186 
187  m_threadsRunning = true;
188  m_rxThreadP = new utility::Thread(rxThread, this);
189 
190  //
191  // Request the current operating MTU of the device
192 
193  wire::SysMtu mtu;
194 
195  Status status = waitData(wire::SysGetMtu(), mtu);
196  if (Status_Ok != status) {
197  cleanup();
198  CRL_EXCEPTION("failed to establish comms with the sensor at \"%s\", with remote head enum %d",
199  address.c_str(), cameraId);
200  } else {
201 
202  //
203  // Use the same MTU for TX
204 
205  m_sensorMtu = mtu.mtu;
206  }
207 
208  //
209  // Request version info from the device
210 
212  if (Status_Ok != status) {
213  cleanup();
214  CRL_EXCEPTION("failed to request version info from sensor at \"%s\"",
215  address.c_str());
216  }
217 
218  //
219  // Create status thread
220 
222 }
223 
224 //
225 // Implementation cleanup
226 
228 {
229  m_threadsRunning = false;
230 
231  if (m_rxThreadP)
232  delete m_rxThreadP;
233  if (m_statusThreadP)
234  delete m_statusThreadP;
235 
236  std::list<ImageListener*>::const_iterator iti;
237  for(iti = m_imageListeners.begin();
238  iti != m_imageListeners.end();
239  iti ++)
240  delete *iti;
241  std::list<LidarListener*>::const_iterator itl;
242  for(itl = m_lidarListeners.begin();
243  itl != m_lidarListeners.end();
244  itl ++)
245  delete *itl;
246  std::list<PpsListener*>::const_iterator itp;
247  for(itp = m_ppsListeners.begin();
248  itp != m_ppsListeners.end();
249  itp ++)
250  delete *itp;
251  std::list<ImuListener*>::const_iterator itm;
252  for(itm = m_imuListeners.begin();
253  itm != m_imuListeners.end();
254  itm ++)
255  delete *itm;
256  std::list<CompressedImageListener*>::const_iterator itc;
257  for(itc = m_compressedImageListeners.begin();
258  itc != m_compressedImageListeners.end();
259  itc ++)
260  delete *itc;
261 
262  BufferPool::const_iterator it;
263  for(it = m_rxLargeBufferPool.begin();
264  it != m_rxLargeBufferPool.end();
265  ++it)
266  delete *it;
267  for(it = m_rxSmallBufferPool.begin();
268  it != m_rxSmallBufferPool.end();
269  ++it)
270  delete *it;
271 
272  m_imageListeners.clear();
273  m_lidarListeners.clear();
274  m_ppsListeners.clear();
275  m_imuListeners.clear();
277  m_rxLargeBufferPool.clear();
278  m_rxSmallBufferPool.clear();
279 
280  if (m_serverSocket > 0)
282 
283 #if WIN32
284  WSACleanup ();
285 #endif
286 }
287 
288 //
289 // Implementation destructor
290 
292 {
293  cleanup();
294 }
295 
296 //
297 // Binds the communications channel, preparing it to send/receive data
298 // over the network.
299 
300 void impl::bind(const std::string& ifName)
301 {
302  //
303  // Create the socket.
304 
305  m_serverSocket = socket(AF_INET, SOCK_DGRAM, IPPROTO_UDP);
306  if (m_serverSocket < 0)
307  CRL_EXCEPTION("failed to create the UDP socket: %s",
308  strerror(errno));
309 
310  #if __linux__
311  //
312  // Bind to spcific interface if specified
313  if (!ifName.empty()){
314  if (0 != setsockopt(m_serverSocket, SOL_SOCKET, SO_BINDTODEVICE, ifName.c_str(), ifName.size())){
315  CRL_EXCEPTION("Failed to bind to device %s. Error: %s", ifName.c_str(),
316  strerror(errno));
317  }
318  }
319  #else
320  if (!ifName.empty())
321  CRL_DEBUG("User specified binding to adapter %s, but this feature is only supported under linux. Ignoring bind to specific adapter", ifName.c_str());
322  #endif
323 
324  //
325  // Turn non-blocking on.
326 #if WIN32
327  u_long ioctl_arg = 1;
328  if (0 != ioctlsocket(m_serverSocket, FIONBIO, &ioctl_arg))
329  CRL_EXCEPTION("failed to make a socket non-blocking: %d",WSAGetLastError ());
330 #else
331  const int flags = fcntl(m_serverSocket, F_GETFL, 0);
332 
333  if (0 != fcntl(m_serverSocket, F_SETFL, flags | O_NONBLOCK))
334  CRL_EXCEPTION("failed to make a socket non-blocking: %s",
335  strerror(errno));
336 #endif
337 
338  //
339  // Allow reusing sockets.
340 
341  int reuseSocket = 1;
342 
343  if (0 != setsockopt(m_serverSocket, SOL_SOCKET, SO_REUSEADDR, (char*) &reuseSocket,
344  sizeof(reuseSocket)))
345  CRL_EXCEPTION("failed to turn on socket reuse flag: %s",
346  strerror(errno));
347 
348  //
349  // We want very large buffers to store several images
350 
351 #if __APPLE__
352  // MacOS cannot reliably allocate a buffer larger than this
353  int bufferSize = 4 * 1024 * 1024;
354 #else
355  int bufferSize = 48 * 1024 * 1024;
356 #endif
357 
358  if (0 != setsockopt(m_serverSocket, SOL_SOCKET, SO_RCVBUF, (char*) &bufferSize,
359  sizeof(bufferSize)) ||
360  0 != setsockopt(m_serverSocket, SOL_SOCKET, SO_SNDBUF, (char*) &bufferSize,
361  sizeof(bufferSize)))
362  CRL_EXCEPTION("failed to adjust socket buffer sizes (%d bytes): %s",
363  bufferSize, strerror(errno));
364 
365  //
366  // Bind the connection to the port.
367 
368  struct sockaddr_in address;
369 
370  address.sin_family = AF_INET;
371  address.sin_port = htons(0); // system assigned
372  address.sin_addr.s_addr = htonl(INADDR_ANY);
373 
374  if (0 != ::bind(m_serverSocket, (struct sockaddr*) &address, sizeof(address)))
375  CRL_EXCEPTION("failed to bind the server socket to system-assigned port: %s",
376  strerror(errno));
377 
378  //
379  // Retrieve the system assigned local UDP port
380 #if WIN32
381  int len = sizeof(address);
382 #else
383  socklen_t len = sizeof(address);
384 #endif
385  if (0 != getsockname(m_serverSocket, (struct sockaddr*) &address, &len))
386  CRL_EXCEPTION("getsockname() failed: %s", strerror(errno));
387  m_serverSocketPort = htons(address.sin_port);
388 }
389 
390 //
391 // Publish a stream to the sensor
392 
394 {
395  //
396  // Install the header
397 
398  wire::Header& header = *(reinterpret_cast<wire::Header*>(stream.data()));
399 
400  header.magic = wire::HEADER_MAGIC;
401  header.version = wire::HEADER_VERSION;
402  header.group = wire::HEADER_GROUP;
403  header.flags = 0;
404 #if WIN32
405  // TBD: This returns the post-incremented value
406  header.sequenceIdentifier = InterlockedIncrement16((short*)&m_txSeqId);
407 #else
408  // TBD: This returns the pre-incremented value
409  header.sequenceIdentifier = __sync_fetch_and_add(&m_txSeqId, 1);
410 #endif
411  header.messageLength = static_cast<uint32_t> (stream.tell() - sizeof(wire::Header));
412  header.byteOffset = 0;
413 
414  //
415  // Send the packet along
416 
417 // disable MSVC warning for narrowing conversion.
418 #ifdef WIN32
419 #pragma warning (push)
420 #pragma warning (disable : 4267)
421 #endif
422  const int32_t ret = sendto(m_serverSocket, (char*)stream.data(), stream.tell(), 0,
423  (struct sockaddr *) &m_sensorAddress,
424  sizeof(m_sensorAddress));
425 #ifdef WIN32
426 #pragma warning (pop)
427 #endif
428 
429  if (static_cast<size_t>(ret) != stream.tell())
430  CRL_EXCEPTION("error sending data to sensor, %d/%d bytes written: %s",
431  ret, stream.tell(), strerror(errno));
432 }
433 
434 //
435 // Convert data source types from wire<->API. These match 1:1 right now, but we
436 // want the freedom to change the wire protocol as we see fit.
437 
439 {
440  wire::SourceType wire_mask = 0;
441 
442  if (mask & Source_Raw_Left) wire_mask |= wire::SOURCE_RAW_LEFT;
443  if (mask & Source_Raw_Right) wire_mask |= wire::SOURCE_RAW_RIGHT;
444  if (mask & Source_Raw_Aux) wire_mask |= wire::SOURCE_RAW_AUX;
445  if (mask & Source_Luma_Left) wire_mask |= wire::SOURCE_LUMA_LEFT;
446  if (mask & Source_Luma_Right) wire_mask |= wire::SOURCE_LUMA_RIGHT;
447  if (mask & Source_Luma_Aux) wire_mask |= wire::SOURCE_LUMA_AUX;
450  if (mask & Source_Luma_Rectified_Aux) wire_mask |= wire::SOURCE_LUMA_RECT_AUX;
451  if (mask & Source_Chroma_Left) wire_mask |= wire::SOURCE_CHROMA_LEFT;
452  if (mask & Source_Chroma_Right) wire_mask |= wire::SOURCE_CHROMA_RIGHT;
454  if (mask & Source_Chroma_Aux) wire_mask |= wire::SOURCE_CHROMA_AUX;
455  if (mask & Source_Disparity) wire_mask |= wire::SOURCE_DISPARITY;
456  if (mask & Source_Disparity_Right) wire_mask |= wire::SOURCE_DISPARITY_RIGHT;
457  if (mask & Source_Disparity_Aux) wire_mask |= wire::SOURCE_DISPARITY_AUX;
458  if (mask & Source_Disparity_Cost) wire_mask |= wire::SOURCE_DISPARITY_COST;
459  if (mask & Source_Jpeg_Left) wire_mask |= wire::SOURCE_JPEG_LEFT;
460  if (mask & Source_Rgb_Left) wire_mask |= wire::SOURCE_RGB_LEFT;
461  if (mask & Source_Lidar_Scan) wire_mask |= wire::SOURCE_LIDAR_SCAN;
462  if (mask & Source_Imu) wire_mask |= wire::SOURCE_IMU;
463  if (mask & Source_Pps) wire_mask |= wire::SOURCE_PPS;
464  if (mask & Source_Compressed_Left) wire_mask |= wire::SOURCE_COMPRESSED_LEFT;
468  if (mask & Source_Compressed_Aux) wire_mask |= wire::SOURCE_COMPRESSED_AUX;
473 
474  return wire_mask;
475 }
476 
478 {
479  DataSource api_mask = 0;
480 
481  if (mask & wire::SOURCE_RAW_LEFT) api_mask |= Source_Raw_Left;
482  if (mask & wire::SOURCE_RAW_RIGHT) api_mask |= Source_Raw_Right;
483  if (mask & wire::SOURCE_RAW_AUX) api_mask |= Source_Raw_Aux;
484  if (mask & wire::SOURCE_LUMA_LEFT) api_mask |= Source_Luma_Left;
485  if (mask & wire::SOURCE_LUMA_RIGHT) api_mask |= Source_Luma_Right;
486  if (mask & wire::SOURCE_LUMA_AUX) api_mask |= Source_Luma_Aux;
490  if (mask & wire::SOURCE_CHROMA_LEFT) api_mask |= Source_Chroma_Left;
491  if (mask & wire::SOURCE_CHROMA_RIGHT) api_mask |= Source_Chroma_Right;
492  if (mask & wire::SOURCE_CHROMA_AUX) api_mask |= Source_Chroma_Aux;
494  if (mask & wire::SOURCE_DISPARITY) api_mask |= Source_Disparity;
496  if (mask & wire::SOURCE_DISPARITY_AUX) api_mask |= Source_Disparity_Aux;
497  if (mask & wire::SOURCE_DISPARITY_COST) api_mask |= Source_Disparity_Cost;
498  if (mask & wire::SOURCE_JPEG_LEFT) api_mask |= Source_Jpeg_Left;
499  if (mask & wire::SOURCE_RGB_LEFT) api_mask |= Source_Rgb_Left;
500  if (mask & wire::SOURCE_LIDAR_SCAN) api_mask |= Source_Lidar_Scan;
501  if (mask & wire::SOURCE_IMU) api_mask |= Source_Imu;
502  if (mask & wire::SOURCE_PPS) api_mask |= Source_Pps;
510  if (mask & wire::SOURCE_COMPRESSED_AUX) api_mask |= Source_Compressed_Aux;
512 
513  return api_mask;
514 }
515 
516 uint32_t impl::hardwareApiToWire(uint32_t a)
517 {
518  switch(a) {
535  default:
536  CRL_DEBUG("unknown API hardware type \"%d\"\n", a);
537  return a; // pass through
538  }
539 }
540 uint32_t impl::hardwareWireToApi(uint32_t w)
541 {
542  switch(w) {
559  default:
560  CRL_DEBUG("unknown WIRE hardware type \"%d\"\n", w);
561  return w; // pass through
562  }
563 }
564 uint32_t impl::imagerApiToWire(uint32_t a)
565 {
566  switch(a) {
575  default:
576  CRL_DEBUG("unknown API imager type \"%d\"\n", a);
577  return a; // pass through
578  }
579 }
580 uint32_t impl::imagerWireToApi(uint32_t w)
581 {
582  switch(w) {
591  default:
592  CRL_DEBUG("unknown WIRE imager type \"%d\"\n", w);
593  return w; // pass through
594  }
595 }
596 
597 //
598 // Apply a time offset correction
599 
601 {
603 
604  //
605  // Reseed on startup or if there is a large jump in time
606  //
607  CRL_CONSTEXPR int TIME_SYNC_THRESH_SECONDS = 100;
608  const bool seed_offset = (false == m_timeOffsetInit) ||
609  (abs(m_timeOffset.getSeconds() - offset.getSeconds()) > TIME_SYNC_THRESH_SECONDS);
610 
611  if (seed_offset)
612  {
613  m_timeOffset = offset; // seed
614  m_timeOffsetInit = true;
615  return;
616  }
617 
618  //
619  // Use doubles to compute offsets to prevent overflow
620 
621  const double samples = static_cast<double>(TIME_SYNC_OFFSET_DECAY);
622 
623  const double currentOffset = m_timeOffset.getSeconds() + m_timeOffset.getMicroSeconds() * 1e-6;
624  const double measuredOffset = offset.getSeconds() + offset.getMicroSeconds() * 1e-6;
625 
626  const double newOffset = utility::decayedAverage(currentOffset, samples, measuredOffset);
627 
628  const int32_t newOffsetSeconds = static_cast<int32_t>(newOffset);
629  const int32_t newOffsetMicroSeconds = static_cast<int32_t>((newOffset - newOffsetSeconds) * 1e6);
630 
631  m_timeOffset = utility::TimeStamp(newOffsetSeconds, newOffsetMicroSeconds);
632 }
633 
634 //
635 // Return the corrected time
636 
638 {
640  return m_timeOffset + sensorTime;
641 }
642 
643 //
644 // Correct the time, populate seconds/microseconds
645 
647  uint32_t& seconds,
648  uint32_t& microseconds)
649 {
650  const utility::TimeStamp corrected = sensorToLocalTime(sensorTime);
651  seconds = corrected.getSeconds();
652  microseconds = corrected.getMicroSeconds();
653 }
654 
655 //
656 // An internal thread for status/time-synchronization
657 
658 #ifdef WIN32
659 DWORD impl::statusThread(void *userDataP)
660 #else
661 void *impl::statusThread(void *userDataP)
662 #endif
663 {
664  impl *selfP = reinterpret_cast<impl*>(userDataP);
665 
666  //
667  // Loop until shutdown
668 
669  while(selfP->m_threadsRunning) {
670 
671  try {
672 
673  //
674  // Setup handler for the status response
675 
677 
678  //
679  // Send the status request, recording the (approx) local time
680 
682  selfP->publish(wire::StatusRequest());
683 
684  //
685  // Wait for the response
686 
687  Status status;
688  if (ack.wait(status, 0.010)) {
689 
690  //
691  // Record (approx) time of response
692 
694 
695  //
696  // Extract the response payload
697 
699  selfP->m_messages.extract(msg);
700 
701 
702  //
703  // Estimate 'msg.uptime' capture using half of the round trip period
704 
705  const utility::TimeStamp latency((pong.getNanoSeconds() - ping.getNanoSeconds()) / 2);
706 
707  //
708  // Compute and apply the estimated time offset
709 
710  const utility::TimeStamp offset = ping + latency - msg.uptime;
711 
712  selfP->applySensorTimeOffset(offset);
713 
714  //
715  // Cache the status message
716 
717  selfP->m_statusResponseMessage = msg;
719  } else {
721  }
722 
723  } catch (const std::exception& e) {
724 
725  CRL_DEBUG("exception: %s\n", e.what());
726 
727  } catch (...) {
728 
729  CRL_DEBUG_RAW("unknown exception\n");
730  }
731 
732  //
733  // Recompute offset at ~1Hz
734 
735  usleep(static_cast<unsigned int> (1e6));
736  }
737 
738  return NULL;
739 }
740 
741 } // namespace details
742 
743 Channel* Channel::Create(const std::string& address)
744 {
745  try {
746 
747  return new details::impl(address, Remote_Head_VPB, "");
748 
749  } catch (const std::exception& e) {
750 
751  CRL_DEBUG("exception: %s\n", e.what());
752  return NULL;
753  }
754 }
755 
756 Channel* Channel::Create(const std::string& address, const RemoteHeadChannel &cameraId)
757 {
758  try {
759 
760  return new details::impl(address, cameraId, "");
761 
762  } catch (const std::exception& e) {
763 
764  CRL_DEBUG("exception: %s\n", e.what());
765  return NULL;
766  }
767 }
768 
769 Channel* Channel::Create(const std::string &address, const std::string& ifName)
770  {
771  try {
772  return new details::impl(address, Remote_Head_VPB, ifName);
773  } catch (const std::exception& e) {
774  CRL_DEBUG("exception: %s\n", e.what());
775  return NULL;
776  }
777  }
778 
779 Channel* Channel::Create(const std::string &address, const RemoteHeadChannel &cameraId, const std::string &ifName)
780  {
781  try {
782  return new details::impl(address, cameraId, ifName);
783  } catch (const std::exception& e) {
784  CRL_DEBUG("exception: %s\n", e.what());
785  return NULL;
786  }
787  }
788 
789 void Channel::Destroy(Channel *instanceP)
790 {
791  try {
792 
793  if (instanceP)
794  delete static_cast<details::impl*>(instanceP);
795 
796  } catch (const std::exception& e) {
797 
798  CRL_DEBUG("exception: %s\n", e.what());
799  }
800 }
801 
802 const char *Channel::statusString(Status status)
803 {
804  switch(status) {
805  case Status_Ok: return "Ok";
806  case Status_TimedOut: return "Timed out";
807  case Status_Error: return "Error";
808  case Status_Failed: return "Failed";
809  case Status_Unsupported: return "Unsupported";
810  case Status_Unknown: return "Unknown command";
811  case Status_Exception: return "Exception";
812  }
813 
814  return "Unknown Error";
815 }
816 
817 } // namespace multisense
818 } // namespace crl
static CRL_CONSTEXPR uint32_t HARDWARE_REV_MULTISENSE_KS21
static CRL_CONSTEXPR DataSource Source_Disparity_Cost
std::list< ImageListener * > m_imageListeners
Definition: channel.hh:458
static CRL_CONSTEXPR SourceType SOURCE_LUMA_RECT_AUX
Definition: Protocol.hh:262
static uint32_t imagerWireToApi(uint32_t h)
Definition: channel.cc:580
static CRL_CONSTEXPR uint32_t HARDWARE_REV_MULTISENSE_REMOTE_HEAD_VPB
static CRL_CONSTEXPR DataSource Source_Luma_Aux
static CRL_CONSTEXPR SourceType SOURCE_LUMA_AUX
Definition: Protocol.hh:261
#define CRL_EXCEPTION(fmt,...)
Definition: Exception.hh:85
static uint32_t hardwareWireToApi(uint32_t h)
Definition: channel.cc:540
#define CRL_DEBUG_RAW(fmt)
Definition: Exception.hh:78
static CRL_CONSTEXPR SourceType SOURCE_DISPARITY
Definition: Protocol.hh:247
static CRL_CONSTEXPR SourceType SOURCE_RAW_AUX
Definition: Protocol.hh:260
static CRL_CONSTEXPR DataSource Source_Disparity_Right
static CRL_CONSTEXPR DataSource Source_Compressed_Rectified_Right
static CRL_CONSTEXPR RemoteHeadChannel Remote_Head_VPB
static CRL_CONSTEXPR uint32_t HARDWARE_REV_MULTISENSE_SL
static CRL_CONSTEXPR SourceType SOURCE_DISPARITY_AUX
Definition: Protocol.hh:264
static CRL_CONSTEXPR DataSource Source_Jpeg_Left
static CRL_CONSTEXPR SourceType SOURCE_GROUND_SURFACE_SPLINE_DATA
Definition: Protocol.hh:253
static CRL_CONSTEXPR uint32_t IMAGER_TYPE_CMV4000_COLOR
static const char * statusString(Status status)
Definition: channel.cc:802
static CRL_CONSTEXPR DataSource Source_Disparity
static CRL_CONSTEXPR SourceType SOURCE_CHROMA_RECT_AUX
Definition: Protocol.hh:246
static CRL_CONSTEXPR uint32_t HARDWARE_REV_MULTISENSE_KS21
struct sockaddr_in m_sensorAddress
Definition: channel.hh:385
static CRL_CONSTEXPR uint32_t IMAGER_TYPE_CMV2000_GREY
static CRL_CONSTEXPR SourceType SOURCE_DISPARITY_RIGHT
Definition: Protocol.hh:249
void applySensorTimeOffset(const utility::TimeStamp &offset)
Definition: channel.cc:600
static CRL_CONSTEXPR DataSource Source_Chroma_Left
static CRL_CONSTEXPR uint32_t HARDWARE_REV_MULTISENSE_S21
static CRL_CONSTEXPR DataSource Source_Compressed_Aux
UdpAssemblerMap m_udpAssemblerMap
Definition: channel.hh:427
static CRL_CONSTEXPR SourceType SOURCE_GROUND_SURFACE_CLASS_IMAGE
Definition: Protocol.hh:254
static CRL_CONSTEXPR uint32_t HARDWARE_REV_MULTISENSE_ST21
static Channel * Create(const std::string &sensorAddress)
Definition: channel.cc:743
static CRL_CONSTEXPR Status Status_Unsupported
static CRL_CONSTEXPR DataSource Source_Ground_Surface_Class_Image
static CRL_CONSTEXPR DataSource Source_AprilTag_Detections
wire::StatusResponse m_statusResponseMessage
Definition: channel.hh:498
static wire::SourceType sourceApiToWire(DataSource mask)
Definition: channel.cc:438
static CRL_CONSTEXPR DataSource Source_Luma_Left
std::list< PpsListener * > m_ppsListeners
Definition: channel.hh:460
static CRL_CONSTEXPR SourceType SOURCE_APRILTAG_DETECTIONS
Definition: Protocol.hh:255
static CRL_CONSTEXPR uint32_t IMAGER_TYPE_AR0234_GREY
std_msgs::Header * header(M &m)
#define closesocket
Definition: Portability.hh:100
impl(const std::string &address, const RemoteHeadChannel &cameraId, const std::string &ifName)
Definition: channel.cc:65
static CRL_CONSTEXPR Status Status_Failed
static CRL_CONSTEXPR SourceType SOURCE_LUMA_LEFT
Definition: Protocol.hh:240
static CRL_CONSTEXPR uint32_t HARDWARE_REV_MULTISENSE_REMOTE_HEAD_MONOCAM
utility::Thread * m_rxThreadP
Definition: channel.hh:447
static CRL_CONSTEXPR uint16_t HEADER_VERSION
Definition: Protocol.hh:76
static CRL_CONSTEXPR uint32_t HARDWARE_REV_MULTISENSE_MONOCAM
static CRL_CONSTEXPR uint32_t HARDWARE_REV_MULTISENSE_S7
static CRL_CONSTEXPR SourceType SOURCE_CHROMA_RIGHT
Definition: Protocol.hh:245
static CRL_CONSTEXPR uint32_t RX_POOL_SMALL_BUFFER_COUNT
Definition: channel.hh:283
static CRL_CONSTEXPR uint32_t HARDWARE_REV_MULTISENSE_C6S2_S27
static CRL_CONSTEXPR DataSource Source_Luma_Rectified_Aux
static CRL_CONSTEXPR uint32_t RX_POOL_SMALL_BUFFER_SIZE
Definition: channel.hh:282
static CRL_CONSTEXPR uint32_t HARDWARE_REV_MULTISENSE_SL
static CRL_CONSTEXPR uint32_t IMAGER_TYPE_FLIR_TAU2
static CRL_CONSTEXPR SourceType SOURCE_LUMA_RECT_RIGHT
Definition: Protocol.hh:243
static CRL_CONSTEXPR DataSource Source_Lidar_Scan
static CRL_CONSTEXPR uint32_t HARDWARE_REV_MULTISENSE_M
static CRL_CONSTEXPR uint32_t HARDWARE_REV_MULTISENSE_REMOTE_HEAD_STEREO
static CRL_CONSTEXPR DataSource Source_Luma_Right
#define INVALID_SOCKET
Definition: channel.hh:66
static CRL_CONSTEXPR SourceType SOURCE_COMPRESSED_RIGHT
Definition: Protocol.hh:266
static CRL_CONSTEXPR uint32_t HARDWARE_REV_MONO
static CRL_CONSTEXPR uint32_t IMAGER_TYPE_AR0234_GREY
static CRL_CONSTEXPR uint32_t HARDWARE_REV_MULTISENSE_REMOTE_HEAD_STEREO
static CRL_CONSTEXPR DataSource Source_Imu
static CRL_CONSTEXPR uint32_t HARDWARE_REV_MULTISENSE_S30
static CRL_CONSTEXPR uint32_t IMAGER_TYPE_CMV4000_GREY
static CRL_CONSTEXPR uint32_t HARDWARE_REV_MULTISENSE_S7S
static CRL_CONSTEXPR uint32_t HARDWARE_REV_MULTISENSE_ST21
static CRL_CONSTEXPR uint16_t DEFAULT_SENSOR_TX_PORT
Definition: channel.hh:275
static CRL_CONSTEXPR uint32_t IMAGER_TYPE_IMX104_COLOR
static CRL_CONSTEXPR uint32_t HARDWARE_REV_MULTISENSE_S21
Definition: channel.cc:58
static CRL_CONSTEXPR DataSource Source_Ground_Surface_Spline_Data
static CRL_CONSTEXPR uint32_t MAX_BUFFER_ALLOCATION_RETRIES
Definition: channel.hh:284
static CRL_CONSTEXPR uint32_t HARDWARE_REV_MULTISENSE_MONOCAM
static CRL_CONSTEXPR SourceType SOURCE_CHROMA_LEFT
Definition: Protocol.hh:244
static CRL_CONSTEXPR Status Status_TimedOut
#define MSG_ID(x)
Definition: Protocol.hh:311
static CRL_CONSTEXPR uint32_t RX_POOL_LARGE_BUFFER_COUNT
Definition: channel.hh:281
static CRL_CONSTEXPR Status Status_Ok
void bind(const std::string &ifName)
Definition: channel.cc:300
static CRL_CONSTEXPR DataSource Source_Chroma_Aux
static CRL_CONSTEXPR SourceType SOURCE_RAW_RIGHT
Definition: Protocol.hh:239
static CRL_CONSTEXPR uint32_t HARDWARE_REV_MULTISENSE_REMOTE_HEAD_MONOCAM
static CRL_CONSTEXPR DataSource Source_Pps
static CRL_CONSTEXPR DataSource Source_Rgb_Left
wire::VersionResponse m_sensorVersion
Definition: channel.hh:493
std::list< CompressedImageListener * > m_compressedImageListeners
Definition: channel.hh:462
static CRL_CONSTEXPR uint32_t IMAGER_TYPE_AR0239_COLOR
static CRL_CONSTEXPR SourceType SOURCE_COMPRESSED_AUX
Definition: Protocol.hh:267
static CRL_CONSTEXPR uint32_t IMAGER_TYPE_CMV4000_GREY
static CRL_CONSTEXPR uint32_t HARDWARE_REV_MULTISENSE_S7S
static CRL_CONSTEXPR DataSource Source_Compressed_Rectified_Left
static CRL_CONSTEXPR SourceType SOURCE_IMU
Definition: Protocol.hh:258
static uint32_t imagerApiToWire(uint32_t h)
Definition: channel.cc:564
static CRL_CONSTEXPR uint32_t HARDWARE_REV_MULTISENSE_S30
static CRL_CONSTEXPR uint32_t HARDWARE_REV_BCAM
utility::TimeStamp m_timeOffset
Definition: channel.hh:486
static CRL_CONSTEXPR SourceType SOURCE_LUMA_RECT_LEFT
Definition: Protocol.hh:242
static CRL_CONSTEXPR uint16_t HEADER_MAGIC
Definition: Protocol.hh:75
static CRL_CONSTEXPR SourceType SOURCE_DISPARITY_COST
Definition: Protocol.hh:250
static CRL_CONSTEXPR uint32_t IMAGER_TYPE_AR0239_COLOR
static CRL_CONSTEXPR DataSource Source_Chroma_Rectified_Aux
static CRL_CONSTEXPR DataSource Source_Raw_Right
#define CRL_DEBUG(fmt,...)
Definition: Exception.hh:71
static CRL_CONSTEXPR uint32_t HARDWARE_REV_MULTISENSE_S7AR
static CRL_CONSTEXPR SourceType SOURCE_RGB_LEFT
Definition: Protocol.hh:252
static CRL_CONSTEXPR uint32_t RX_POOL_LARGE_BUFFER_SIZE
Definition: channel.hh:280
std::list< LidarListener * > m_lidarListeners
Definition: channel.hh:459
utility::TimeStamp sensorToLocalTime(const utility::TimeStamp &sensorTime)
Definition: channel.cc:637
static CRL_CONSTEXPR DataSource Source_Raw_Left
static CRL_CONSTEXPR uint32_t HARDWARE_REV_MULTISENSE_C6S2_S27
static CRL_CONSTEXPR SourceType SOURCE_COMPRESSED_RECTIFIED_LEFT
Definition: Protocol.hh:268
bool wait(Status &status, const double &timeout)
Definition: signal.hh:125
static uint32_t hardwareApiToWire(uint32_t h)
Definition: channel.cc:516
static void Destroy(Channel *instanceP)
Definition: channel.cc:789
static CRL_CONSTEXPR SourceType SOURCE_COMPRESSED_LEFT
Definition: Protocol.hh:265
static CRL_CONSTEXPR uint32_t HARDWARE_REV_MULTISENSE_S7AR
static CRL_CONSTEXPR uint32_t HARDWARE_REV_MULTISENSE_M
static CRL_CONSTEXPR uint16_t HEADER_GROUP
Definition: Protocol.hh:81
static void assembler(utility::BufferStreamWriter &stream, const uint8_t *dataP, uint32_t offset, uint32_t length)
static CRL_CONSTEXPR DataSource Source_Luma_Rectified_Right
void publish(const T &message)
Definition: query.hh:50
static CRL_CONSTEXPR SourceType SOURCE_RAW_LEFT
Definition: Protocol.hh:238
static CRL_CONSTEXPR uint32_t IMAGER_TYPE_CMV2000_GREY
static CRL_CONSTEXPR uint32_t IMAGER_TYPE_CMV4000_COLOR
static CRL_CONSTEXPR SourceType SOURCE_LIDAR_SCAN
Definition: Protocol.hh:257
static CRL_CONSTEXPR SourceType SOURCE_PPS
Definition: Protocol.hh:259
static void * rxThread(void *userDataP)
Definition: dispatch.cc:859
static CRL_CONSTEXPR DataSource Source_Compressed_Rectified_Aux
static CRL_CONSTEXPR SourceType SOURCE_LUMA_RIGHT
Definition: Protocol.hh:241
static CRL_CONSTEXPR DataSource Source_Compressed_Right
std::list< ImuListener * > m_imuListeners
Definition: channel.hh:461
static CRL_CONSTEXPR Status Status_Exception
Type decayedAverage(Type const &previous, Type const &samples, Type const &newest)
Definition: Functional.hh:67
static CRL_CONSTEXPR uint32_t IMAGER_TYPE_CMV2000_COLOR
static CRL_CONSTEXPR uint32_t TIME_SYNC_OFFSET_DECAY
Definition: channel.hh:290
static CRL_CONSTEXPR DataSource Source_Raw_Aux
static CRL_CONSTEXPR uint32_t IMAGER_TYPE_CMV2000_COLOR
static CRL_CONSTEXPR DataSource Source_Disparity_Aux
Status waitData(const T &command, U &data, const double &timeout=DEFAULT_ACK_TIMEOUT(), int32_t attempts=DEFAULT_ACK_ATTEMPTS)
Definition: query.hh:120
static void * statusThread(void *userDataP)
Definition: channel.cc:661
static CRL_CONSTEXPR Status Status_Error
static CRL_CONSTEXPR uint32_t IMAGER_TYPE_IMX104_COLOR
static CRL_CONSTEXPR SourceType SOURCE_COMPRESSED_RECTIFIED_RIGHT
Definition: Protocol.hh:269
#define CRL_CONSTEXPR
Definition: Portability.hh:49
static CRL_CONSTEXPR SourceType SOURCE_JPEG_LEFT
Definition: Protocol.hh:251
static CRL_CONSTEXPR SourceType SOURCE_COMPRESSED_RECTIFIED_AUX
Definition: Protocol.hh:270
static CRL_CONSTEXPR uint32_t HARDWARE_REV_MULTISENSE_REMOTE_HEAD_VPB
utility::Thread * m_statusThreadP
Definition: channel.hh:453
static DataSource sourceWireToApi(wire::SourceType mask)
Definition: channel.cc:477
static CRL_CONSTEXPR DataSource Source_Chroma_Right
static CRL_CONSTEXPR Status Status_Unknown
static CRL_CONSTEXPR SourceType SOURCE_CHROMA_AUX
Definition: Protocol.hh:263
static CRL_CONSTEXPR uint32_t HARDWARE_REV_MULTISENSE_S7
static CRL_CONSTEXPR DataSource Source_Compressed_Left
static CRL_CONSTEXPR DataSource Source_Luma_Rectified_Left


multisense_lib
Author(s):
autogenerated on Sat Jun 24 2023 03:01:21