input.h
Go to the documentation of this file.
1 /* -*- mode: C++ -*-
2  *
3  * License: Modified BSD Software License Agreement
4  *
5  * $Id$
6  */
7 
28 #ifndef __O3M151_INPUT_H
29 #define __O3M151_INPUT_H
30 
31 #include <unistd.h>
32 #include <stdio.h>
33 #include <pcap.h>
34 
35 #include <ros/ros.h>
37 
38 namespace o3m151_driver
39 {
40  class PacketHeader;
41  static uint16_t UDP_PORT_NUMBER = 42000;
42 
44  class Input
45  {
46  public:
47  Input();
48 
57  virtual int getPacket(pcl::PointCloud<pcl::PointXYZI> &pc) = 0;
58 
59  protected:
60  int processPacket( int8_t* currentPacketData, // payload of the udp packet (without ethernet/IP/UDP header)
61  uint32_t currentPacketSize, // size of the udp packet payload
62  int8_t* channelBuffer, // buffer for a complete channel
63  uint32_t channelBufferSize, // size of the buffer for the complete channel
64  uint32_t* pos); // the current pos in the channel buffer
65 
66  double slope(const std::vector<double>& x, const std::vector<double>& y);
67  void processChannel8(int8_t* buf, uint32_t size, pcl::PointCloud<pcl::PointXYZI> &pc);
68  int process(int8_t *udpPacketBuf, const ssize_t rc, pcl::PointCloud<pcl::PointXYZI> & pc);
69 
70  // the size of the channel may change so the size will be taken from the packet
72  int8_t* channelBuf;
73 
74  // As there is no offset in the packet header we have to remember where the next part should go
75  uint32_t pos_in_channel_;
76 
77  // remember the counter of the previous packet so we know when we loose packets
80  // the receiption of the data may start at any time. So we wait til we find the beginning of our channel
82  };
83 
85  class InputSocket: public Input
86  {
87  public:
88  InputSocket(ros::NodeHandle private_nh,
89  uint16_t udp_port = UDP_PORT_NUMBER);
90  ~InputSocket();
91  virtual int getPacket(pcl::PointCloud<pcl::PointXYZI> &pc);
92 
93  private:
94 
95  int sockfd_;
96  };
97 
98 
104  class InputPCAP: public Input
105  {
106  public:
107  InputPCAP(ros::NodeHandle private_nh,
108  double packet_rate,
109  std::string filename="",
110  bool read_once=false,
111  bool read_fast=false,
112  double repeat_delay=0.0);
113  ~InputPCAP();
114 
115  virtual int getPacket(pcl::PointCloud<pcl::PointXYZI> &pc);
116 
117  private:
118 
119  std::string filename_;
120  FILE *fp_;
121  pcap_t *pcap_;
122  char errbuf_[PCAP_ERRBUF_SIZE];
123  bool empty_;
128  };
129 
130 } // o3m151_driver namespace
131 
132 #endif // __O3M151_INPUT_H
filename
int8_t * channelBuf
Definition: input.h:72
int processPacket(int8_t *currentPacketData, uint32_t currentPacketSize, int8_t *channelBuffer, uint32_t channelBufferSize, uint32_t *pos)
Definition: input.cc:82
static uint16_t UDP_PORT_NUMBER
Definition: input.h:41
double slope(const std::vector< double > &x, const std::vector< double > &y)
Definition: input.cc:124
TFSIMD_FORCE_INLINE const tfScalar & y() const
void processChannel8(int8_t *buf, uint32_t size, pcl::PointCloud< pcl::PointXYZI > &pc)
Definition: input.cc:135
std::string filename_
Definition: input.h:119
uint32_t previous_packet_counter_
Definition: input.h:78
bool startOfChannelFound_
Definition: input.h:81
uint32_t pos_in_channel_
Definition: input.h:75
TFSIMD_FORCE_INLINE const tfScalar & x() const
int process(int8_t *udpPacketBuf, const ssize_t rc, pcl::PointCloud< pcl::PointXYZI > &pc)
Definition: input.cc:234
uint32_t channel_buf_size_
Definition: input.h:71
ros::Rate packet_rate_
Definition: input.h:127
Live O3M151 input from socket.
Definition: input.h:85
O3M151 input from PCAP dump file.
Definition: input.h:104
bool previous_packet_counter_valid_
Definition: input.h:79
Pure virtual O3M151 input base class.
Definition: input.h:44
virtual int getPacket(pcl::PointCloud< pcl::PointXYZI > &pc)=0
Read one O3M151 packet.


o3m151_driver
Author(s): Vincent Rousseau
autogenerated on Mon Jun 10 2019 14:07:55