Go to the documentation of this file.00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00043 #ifndef _BTA_TOF_DRIVER_HPP_
00044 #define _BTA_TOF_DRIVER_HPP_
00045
00046 #include <bta.h>
00047
00048
00049 #include <ros/ros.h>
00050 #include <image_transport/image_transport.h>
00051 #include <camera_info_manager/camera_info_manager.h>
00052 #include <sensor_msgs/Image.h>
00053 #include <sensor_msgs/CameraInfo.h>
00054 #include <sensor_msgs/SetCameraInfo.h>
00055 #include <sensor_msgs/image_encodings.h>
00056 #include <sensor_msgs/PointCloud2.h>
00057 #include <sensor_msgs/point_cloud2_iterator.h>
00058 #include <tf2_ros/static_transform_broadcaster.h>
00059 #include <geometry_msgs/TransformStamped.h>
00060
00061 #include <ros/console.h>
00062 #include <tf/transform_listener.h>
00063
00064
00065 #include <pcl_ros/point_cloud.h>
00066 #include <pcl/point_types.h>
00067 #include <pcl/conversions.h>
00068
00069
00070 #include <stdio.h>
00071 #include <time.h>
00072 #include <sstream>
00073 #include <string>
00074
00075
00076 #include <bta_tof_driver/bta_tof_driverConfig.h>
00077 #include <dynamic_reconfigure/server.h>
00078
00079
00080
00081 namespace bta_tof_driver {
00082
00083 class BtaRos
00084 {
00085
00086 typedef bta_tof_driver::bta_tof_driverConfig Config;
00087 typedef dynamic_reconfigure::Server<Config> ReconfigureServer;
00088
00089 public:
00090
00100 BtaRos(ros::NodeHandle nh_camera, ros::NodeHandle nh_private, std::string nodeName);
00101
00107 virtual ~BtaRos();
00108
00114 int initialize();
00115
00121 int connectCamera();
00122
00128 void close();
00129
00130
00136 void publishData();
00137
00138
00139
00140
00141
00142 static void BTA_CALLCONV infoEventCb(BTA_EventId eventId, int8_t *msg) {
00143 ROS_DEBUG(" Callback: infoEvent (%d) %s\n", eventId, msg);
00144 }
00145
00146 private:
00147 ros::NodeHandle nh_, nh_private_;
00148 std::string nodeName_;
00149 camera_info_manager::CameraInfoManager cim_tof_;
00150 image_transport::ImageTransport it_;
00151 image_transport::CameraPublisher pub_amp_, pub_dis_;
00152 tf2_ros::StaticTransformBroadcaster pub_tf;
00153 geometry_msgs::TransformStamped transformStamped;
00154 ros::Publisher pub_xyz_;
00155
00156 boost::shared_ptr<ReconfigureServer> reconfigure_server_;
00157 bool config_init_;
00158
00159 boost::mutex connect_mutex_;
00160
00161
00162 uint8_t udpDataIpAddr_[6], udpControlOutIpAddr_[6],
00163 udpControlInIpAddr_[6], tcpDeviceIpAddr_[6];
00164 std::string uartPortName_, calibFileName_;
00165
00166 sensor_msgs::PointCloud2Ptr _xyz;
00167
00168 BTA_Handle handle_;
00169 BTA_Config config_;
00170
00180 void callback(bta_tof_driver::bta_tof_driverConfig &config, uint32_t level);
00181
00187 void parseConfig();
00188
00194 size_t getDataSize(BTA_DataFormat dataFormat);
00195
00201 std::string getDataType(BTA_DataFormat dataFormat);
00202
00208 float getUnit2Meters(BTA_Unit unit);
00209
00210
00211
00212
00213
00214
00215
00216
00217
00218
00219
00220
00221
00222
00223
00224
00225
00226
00227
00228
00229
00230
00231
00232
00233
00234
00235
00236
00237
00238
00239
00240
00241
00242
00243
00244
00245
00246
00247
00248
00249
00250
00251
00252
00253
00254
00255
00256
00257
00258
00259
00260
00261
00262
00263
00264
00265 };
00266 }
00267
00268 #endif //_BTA_TOF_DRIVER_HPP_
00269