9 #include "ifm_o3mxxx/IFMO3mxxx.h" 16 #include "sensor_msgs/Image.h" 18 #include "sensor_msgs/PointCloud2.h" 30 #define NUM_SENSOR_PIXELS (1024) 50 #define UDP_PACKET_BUF_LEN (2000) 100 int currentPacketSize,
125 if ((*pos) + Length > channelBufferSize)
128 printf(
"Channel buffer is too small.\n");
133 memcpy(channelBuffer+(*pos), currentPacketData+Start, Length);
319 printf(
"*** Unknown version *** \n\n");
326 int main(
int argc,
char **argv)
328 ros::init(argc, argv,
"ifm_o3mxxx_node");
333 string out_imf_depth_image =
"";
334 string out_imf_point_cloud =
"";
335 string out_imf_raw =
"";
336 string frame_id =
"";
339 string ip =
"255.255.255.255";
341 node_priv.
param(
"OutDepthImageTopic", out_imf_depth_image, std::string(
"ifm_o3mxxx_depth_image"));
342 node_priv.
param(
"PointCloudTopic", out_imf_point_cloud, std::string(
"ifm_o3mxxx_pc"));
343 node_priv.
param(
"RawTopic", out_imf_raw, std::string(
"ifm_o3mxxx_raw"));
344 node_priv.
param(
"Port", port, 4599);
345 node_priv.
param(
"IP", ip, std::string(
"255.255.255.255"));
346 node_priv.
param(
"FrameID", frame_id, std::string(
"ifm"));
353 receiver.
init(port, ip);
356 const uint32_t customerDataChannel = 8;
367 int8_t* channelBuf = NULL;
373 uint32_t previous_packet_counter = 0;
374 bool previous_packet_counter_valid =
false;
377 bool startOfChannelFound =
false;
386 if (previous_packet_counter_valid)
391 printf(
"Packet Counter jumped from %i to %i (missing packets; try to redirect output)\n", previous_packet_counter, ph->
PacketCounter);
395 startOfChannelFound =
false;
400 previous_packet_counter_valid =
true;
404 if (ph->
ChannelID == customerDataChannel)
410 startOfChannelFound =
true;
413 if (channel_buf_size == 0)
416 channelBuf = (
int8_t*) malloc(channel_buf_size);
420 memset(channelBuf, 0, channel_buf_size);
426 if (startOfChannelFound)
429 processPacket(udpPacketBuf, ret_val, channelBuf, channel_buf_size, &pos_in_channel);
439 sensor_msgs::Image img;
441 img.header.frame_id = frame_id;
448 memcpy(&(img.data.at(i*4)), &pixel,
sizeof(
float32_t) );
453 img.step = img.width*4;
457 pcl::PointCloud<pcl::PointXYZI> pcl_cloud;
458 sensor_msgs::PointCloud2 cloud;
460 pcl::PointXYZI point;
468 pcl_cloud.push_back(point);
472 cloud.header.frame_id = frame_id;
473 cloud.header.stamp = img.header.stamp;
474 pub_pc.publish(cloud);
ifm_o3m_uint16_t sensorWidth
ifm_o3m_float32_t amplitude_normalization[4]
struct ifm_o3m_AlgoIFOutput_DIA1_1_2::@17::@19 cameraCalibration
ifm_o3m_uint16_t distanceData[1024]
ifm_o3m_uint16_t sensorHeight
void publish(const boost::shared_ptr< M > &message) const
ifm_o3m_uint16_t distanceData[1024]
#define NUM_SENSOR_PIXELS
ifm_o3m_float32_t Y[1024]
ifm_o3mxxx::IFMO3mxxx ifm_ros_msg
const uint16_t confidence1
ifm_o3m_uint16_t sensorWidth
ifm_o3m_float32_t X[1024]
const uint16_t confidence512
ROSCPP_DECL void init(int &argc, char **argv, const std::string &name, uint32_t options=0)
ifm_o3m_float32_t Z[1024]
const uint16_t confidence32
ifm_o3m_AlgoIFOutput_DIA1_1_2 * ifm_o3m_ConvertBufferToLittleEndian_DIA1_1_2(void *buffer, ifm_o3m_uint32_t bufferSize)
ifm_o3m_uint16_t sensorWidth
ifm_o3m_uint32_t available
struct ifm_o3m_AlgoIFOutput_DIA1_1_0::@0 distanceImageResult
bool init(int port, std::string localInterface)
ifm_o3m_uint16_t confidence[1024]
ifm_o3m_uint16_t sensorHeight
ifm_o3m_uint16_t confidence[1024]
ifm_o3m_uint16_t confidence[1024]
struct ifm_o3m_AlgoIFOutput_DIA1_1_0::@0::@2 cameraCalibration
ifm_o3m_AlgoIFOutput_DIA1_1_1 * ifm_o3m_ConvertBufferToLittleEndian_DIA1_1_1(void *buffer, ifm_o3m_uint32_t bufferSize)
struct ifm_o3m_AlgoIFOutput_DIA1_1_3::@28 distanceImageResult
const uint16_t confidence8
ifm_o3m_float32_t Y[1024]
ifm_o3m_uint16_t sensorWidth
#define UDP_PACKET_BUF_LEN
struct ifm_o3m_AlgoIFOutput_DIA1_1_2::@17 distanceImageResult
ifm_o3m_float32_t X[1024]
ifm_o3m_uint32_t available
ifm_o3m_uint16_t sensorHeight
bool param(const std::string ¶m_name, T ¶m_val, const T &default_val) const
const std::string TYPE_32FC1
ifm_o3m_float32_t Z[1024]
const uint16_t confidence4096
ifm_o3m_uint32_t available
ifm_o3m_uint16_t amplitude[1024]
Publisher advertise(const std::string &topic, uint32_t queue_size, bool latch=false)
ifm_o3m_float32_t Z[1024]
ifm_o3m_float32_t amplitude_normalization[4]
ifm_o3m_float32_t Z[1024]
const uint16_t confidence1024
ifm_o3m_float32_t Y[1024]
ifm_o3m_AlgoIFOutput_DIA1_1_3 * ifm_o3m_ConvertBufferToLittleEndian_DIA1_1_3(void *buffer, ifm_o3m_uint32_t bufferSize)
struct ifm_o3m_AlgoIFOutput_DIA1_1_3::@28::@31 cameraCalibration
const uint16_t confidence4
int processChannel8(void *buf, uint32_t size)
ifm_o3m_uint16_t sensorHeight
ifm_o3m_uint16_t distanceData[1024]
ifm_o3m_uint16_t confidence[1024]
int copyChannel8_DIA1_1_0(ifm_o3m_AlgoIFOutput_DIA1_1_0 *p)
int main(int argc, char **argv)
struct ifm_o3m_AlgoIFOutput_DIA1_1_1::@6 distanceImageResult
ifm_o3m_uint16_t amplitude[1024]
const uint16_t confidence2
void toROSMsg(const sensor_msgs::PointCloud2 &cloud, sensor_msgs::Image &image)
ifm_o3m_uint16_t amplitude[1024]
int copyChannel8_DIA1_1_2(ifm_o3m_AlgoIFOutput_DIA1_1_2 *p)
const uint16_t confidence64
struct ifm_o3m_AlgoIFOutput_DIA1_1_1::@6::@8 cameraCalibration
ifm_o3m_float32_t Y[1024]
ifm_o3m_uint16_t amplitude[1024]
ifm_o3m_float32_t X[1024]
int processPacket(int8_t *currentPacketData, int currentPacketSize, int8_t *channelBuffer, uint32_t channelBufferSize, uint32_t *pos)
ifm_o3m_float32_t amplitude_normalization[4]
const uint16_t confidence256
const uint16_t confidence128
ifm_o3m_float32_t amplitude_normalization[4]
ROSCPP_DECL void spinOnce()
int copyChannel8_DIA1_1_1(ifm_o3m_AlgoIFOutput_DIA1_1_1 *p)
const uint16_t confidence16
ifm_o3m_AlgoIFOutput_DIA1_1_0 * ifm_o3m_ConvertBufferToLittleEndian_DIA1_1_0(void *buffer, ifm_o3m_uint32_t bufferSize)
ifm_o3m_uint16_t distanceData[1024]
struct PacketHeader __attribute__((packed))
const uint16_t confidence2048
int copyChannel8_DIA1_1_3(ifm_o3m_AlgoIFOutput_DIA1_1_3 *p)
ifm_o3m_float32_t X[1024]
ifm_o3m_uint32_t available