Go to the documentation of this file.
6 #ifndef ADI_3DTOF_ADTF31XX__H
7 #define ADI_3DTOF_ADTF31XX__H
15 #include <sensor_msgs/Image.h>
16 #include <sensor_msgs/PointCloud2.h>
21 #include <compressed_depth_image_transport/rvl_codec.h>
23 #include <dynamic_reconfigure/server.h>
25 #include <adi_3dtof_adtf31xx/ADTF31xxSensorParamsConfig.h>
53 std::string camera_link;
54 nh.param<std::string>(
"param_camera_link", camera_link,
"adi_camera_link");
57 int input_sensor_mode;
58 nh.param<
int>(
"param_input_sensor_mode", input_sensor_mode, 0);
60 std::string input_file_name;
61 nh.param<std::string>(
"param_input_file_name", input_file_name,
"no name");
63 int enable_depth_ab_compression;
64 nh.param<
int>(
"param_enable_depth_ab_compression", enable_depth_ab_compression, 0);
67 nh.param<
int>(
"param_ab_threshold", ab_threshold, 10);
69 int confidence_threshold;
70 nh.param<
int>(
"param_confidence_threshold", confidence_threshold, 10);
73 int jblf_filter_state;
74 nh.param<
int>(
"param_jblf_filter_state", jblf_filter_state, 1);
78 nh.param<
int>(
"param_jblf_filter_size", jblf_filter_size, 7);
81 int radial_filter_min_threshold;
82 nh.param<
int>(
"param_radial_filter_min_threshold", radial_filter_min_threshold, 100);
85 int radial_filter_max_threshold;
86 nh.param<
int>(
"param_radial_filter_max_threshold", radial_filter_max_threshold, 10000);
88 std::string config_file_name_of_tof_sdk;
89 nh.param<std::string>(
"param_config_file_name_of_tof_sdk", config_file_name_of_tof_sdk,
"no name");
92 nh.param<
int>(
"param_camera_mode", camera_mode, 3);
94 std::string input_sensor_ip;
95 nh.param<std::string>(
"param_input_sensor_ip", input_sensor_ip,
"no name");
97 int enable_point_cloud_publish;
98 nh.param<
int>(
"param_enable_point_cloud_publish", enable_point_cloud_publish, 0);
100 std::string encoding_type;
101 nh.param<std::string>(
"param_encoding_type", encoding_type,
"mono16");
159 depth_image_publisher_ = this->advertise<sensor_msgs::CompressedImage>(
"depth_image/compressedDepth", 10);
160 ab_image_publisher_ = this->advertise<sensor_msgs::CompressedImage>(
"ab_image/compressedDepth", 10);
161 conf_image_publisher_ = this->advertise<sensor_msgs::CompressedImage>(
"conf_image/compressedDepth", 10);
188 "Configuration variables: ab_threshold: %d, confidence_threshold: %d, jblf_filter_state: %d, jblf_filter_size: "
189 "%d, radial_filter_min_threshold: %d, radial_filter_max_threshold: %d",
203 int status = system(
"rosnode kill -a");
282 dynamic_reconfigure::Server<adi_3dtof_adtf31xx::ADTF31xxSensorParamsConfig>
server_;
283 dynamic_reconfigure::Server<adi_3dtof_adtf31xx::ADTF31xxSensorParamsConfig>::CallbackType
338 for (
int i = 0; i < 9; i++)
367 cv_ptr->encoding = encoding_type;
370 cv_ptr->header.frame_id = std::move(frame_id);
371 cv_ptr->image = std::move(img);
373 publisher.
publish(cv_ptr->toImageMsg());
385 sensor_msgs::PointCloud2::Ptr pointcloud_msg(
new sensor_msgs::PointCloud2);
392 pointcloud_msg->is_dense =
false;
393 pointcloud_msg->is_bigendian =
false;
397 short* xyz_sensor_buf = xyz_frame;
400 pcd_modifier.setPointCloud2FieldsByString(1,
"xyz");
409 *iter_x = (float)(*xyz_sensor_buf++) / 1000.0f;
410 *iter_y = (float)(*xyz_sensor_buf++) / 1000.0f;
411 *iter_z = (float)(*xyz_sensor_buf++) / 1000.0f;
452 cv::Mat m_disp_image_depth, m_disp_image_ab, m_disp_image_conf;
482 const std::string& encoding_type, std::string frame_id,
486 sensor_msgs::CompressedImage::Ptr compressed_payload_ptr(
new sensor_msgs::CompressedImage());
488 compressed_payload_ptr->format = encoding_type +
";compressedDepth rvl";
491 compressed_payload_ptr->header.frame_id = std::move(frame_id);
492 compressed_payload_ptr->data.resize(compressed_img_size + 8 +
499 float depthQuantization = 0;
500 float maximumDepth = 1;
503 float depthQuantizationA = depthQuantization * (depthQuantization + 1.0f);
504 float depthQuantizationB = 1.0f - depthQuantizationA / maximumDepth;
505 compressionConfiguration.depthParam[0] = depthQuantizationA;
506 compressionConfiguration.depthParam[1] = depthQuantizationB;
508 memcpy(&compressed_payload_ptr->data[0], &compressionConfiguration,
516 compressed_img_size);
518 publisher.
publish(compressed_payload_ptr);
This is the class for adtf31xx sensor node output information.
const std::string RATIONAL_POLYNOMIAL
sensor_msgs::CameraInfo cam_info_msg_
void initSettingsForDynamicReconfigure()
Dynamic reconfigure initialization.
CameraExtrinsics depth_extrinsics_external_
int compressed_ab_frame_size_
int compressed_conf_frame_size_
bool enable_depth_ab_compression_
void publishImageAsRosMsg(cv::Mat img, const std::string &encoding_type, std::string frame_id, const ros::Publisher &publisher)
This function publishes images as Ros messages.
int confidence_threshold_
ros::Publisher depth_image_publisher_
ros::Time curr_frame_timestamp_
void readInputAbort()
Function to read Abort flag, this function will be called by the main function to exit the thread.
unsigned char * compressed_ab_frame_
void processOutput()
The output process function, this is running a loop which reads the frame from the putput queue,...
ROSCPP_DECL void shutdown()
boost::mutex output_thread_mtx_
This is the class for adtf31xx sensor frame.
int radial_filter_max_threshold_
int compressed_depth_frame_size_
ros::Publisher depth_info_publisher_
void publishPointCloud(short *xyz_frame)
This function publishes the point cloud.
void publishRVLCompressedImageAsRosMsg(unsigned char *compressed_img, int compressed_img_size, const std::string &encoding_type, std::string frame_id, const ros::Publisher &publisher)
This function publishes a compressed image as Ros message.
float camera_matrix[9]
Camera matrix = [fx, 0, cx, 0, fy, cy, 0, 0, 1] fx, fy : Camera focal lengths (pixels) cx,...
bool read_input_thread_abort_
#define PROFILE_FUNCTION_END(ID)
void publish(const boost::shared_ptr< M > &message) const
~ADI3DToFADTF31xx()
Destroy the ADI3DToFADTF31xx object.
int processing_scale_
This is the scale factor to scale the input image. The processing will happen on the scaled down imag...
This class has image processing utilities.
bool enable_point_cloud_publish_
bool error_in_frame_read_
bool process_output_thread_abort_
dynamic_reconfigure::Server< adi_3dtof_adtf31xx::ADTF31xxSensorParamsConfig >::CallbackType dynamic_reconfigure_callbacktype_
IInputSensor * input_sensor_
void adtf31xxSensorPushOutputNode(ADI3DToFADTF31xxOutputInfo *new_output_node)
This function pushes the debug node to the output queue. If the queue is full, then the last item in ...
std::string input_file_name_
boost::mutex input_thread_mtx_
void updateDynamicReconfigureVariablesInputThread()
updates the parameter of input image based on dynamic reconfigure.
unsigned short * conf_frame_
void dynamicallyReconfigureVariables(adi_3dtof_adtf31xx::ADTF31xxSensorParamsConfig &config, uint32_t level)
new values from dynamic reconfigure are copied to a structure variable here, actual update to individ...
adi_3dtof_adtf31xx::ADTF31xxSensorParamsConfig dynamic_reconfigure_config_
CameraExtrinsics depth_extrinsics_
ADI3DToFADTF31xxFrameInfo * adtf31xxSensorGetNextFrame()
Function to read the next frame from the input Queue.
std::queue< ADI3DToFADTF31xxFrameInfo * > input_frames_queue_
void processOutputAbort()
This function sets the abort flag for the output thread, the function is normally called by the main ...
ros::Publisher xyz_image_publisher_
bool readNextFrame()
This function is the entry point to the sensor node.
unsigned short * ab_frame_
float rotation_matrix[9]
Camera rotation parameters.
int radial_filter_min_threshold_
#define ROS_INFO_STREAM(args)
void readInput()
This function reads the frmae from the sensor. This runs in a loop, reading the frames and adding the...
dynamic_reconfigure::Server< adi_3dtof_adtf31xx::ADTF31xxSensorParamsConfig > server_
ImageProcUtils * image_proc_utils_
std::string encoding_type_
float translation_matrix[3]
Camera translation matrix : [Tx,Ty,Tz].
CameraIntrinsics depth_intrinsics_
#define PROFILE_FUNCTION_START(ID)
ros::Publisher ab_image_publisher_
std::string input_sensor_ip_
int max_debug_queue_length_
int max_input_queue_length_
void shutDownAllNodes()
This function shuts down all the nodes running in a roscore.
unsigned short * depth_frame_
Extrinsic parameters of the camera.
unsigned short * conf_frame_
This is main class for this package.
ros::Publisher conf_image_publisher_
Intrinsic parameters of the camera.
unsigned short * ab_frame_
ADI3DToFADTF31xx()
Construct a new ADI3DToFADTF31xx object.
unsigned short * depth_frame_
unsigned char * compressed_depth_frame_
float distortion_coeffs[8]
Distortion vector = [k1, k2, p1, p2, k3, k4, k5, k6] k1, k2, k3, k4, k5, k6 : Camera radial distortio...
void fillAndPublishCameraInfo(std::string frame_id, const ros::Publisher &publisher)
This image fills and publishes the camera information.
void publishImageAndCameraInfo(ADI3DToFADTF31xxOutputInfo *out_frame)
Publishes the image and camera information. This function publishes the camera information and depth,...
std::queue< ADI3DToFADTF31xxOutputInfo * > output_node_queue_
unsigned char * compressed_conf_frame_