Go to the documentation of this file.00001 #include "ueye_camera_driver_node.h"
00002
00003 using namespace std;
00004
00005 UeyeCameraDriverNode::UeyeCameraDriverNode(ros::NodeHandle &nh) :
00006 iri_base_driver::IriBaseNodeDriver<UeyeCameraDriver>(nh)
00007 {
00008
00009 this->loop_rate_ = 100;
00010
00011 this->public_node_handle_.param<int>("cameraid", this->driver_.cameraid_,0);
00012 this->public_node_handle_.param<int>("param_mode", this->driver_.param_mode_,1);
00013 this->public_node_handle_.param<int>("width", this->driver_.img_width_,752);
00014 this->public_node_handle_.param<int>("height", this->driver_.img_height_,480);
00015 this->public_node_handle_.param<int>("left", this->driver_.img_left_,-1);
00016 this->public_node_handle_.param<int>("top", this->driver_.img_top_,-1);
00017 this->public_node_handle_.param<int>("pixel_clock", this->driver_.pixel_clock_,20);
00018 this->public_node_handle_.param<int>("fps", this->driver_.fps_,80);
00019 this->public_node_handle_.param<double>("exposure", this->driver_.exposure_,0.1);
00020 this->public_node_handle_.param<bool>("mirror_updown", this->driver_.mirror_updown_,false);
00021 this->public_node_handle_.param<bool>("mirror_leftright", this->driver_.mirror_leftright_,false);
00022 this->public_node_handle_.param<string>("camera_frame_id", this->driver_.frame_id_, string("ueye_camera"));
00023 this->public_node_handle_.param("file_str",this->driver_.file_str_,string(""));
00024
00025
00026 this->public_node_handle_.getParam("K", this->driver_.double_list_);
00027 if ((this->driver_.double_list_.getType() == XmlRpc::XmlRpcValue::TypeArray) && (this->driver_.double_list_.size() == 9)) {
00028 for (int i=0; i<9; i++) {
00029 ROS_ASSERT(this->driver_.double_list_[0].getType() == XmlRpc::XmlRpcValue::TypeDouble);
00030 this->CameraInfo_msg_.K[i] = this->driver_.double_list_[i];
00031 }
00032 }
00033
00034 this->public_node_handle_.getParam("D", this->driver_.double_list_);
00035 if ((this->driver_.double_list_.getType() == XmlRpc::XmlRpcValue::TypeArray)) {
00036 this->CameraInfo_msg_.D.resize(this->driver_.double_list_.size());
00037 for (int i=0; i<this->driver_.double_list_.size(); i++) {
00038 ROS_ASSERT(this->driver_.double_list_[0].getType() == XmlRpc::XmlRpcValue::TypeDouble);
00039 this->CameraInfo_msg_.D[i] = this->driver_.double_list_[i];
00040 }
00041 }
00042
00043 this->public_node_handle_.getParam("R", this->driver_.double_list_);
00044 if ((this->driver_.double_list_.getType() == XmlRpc::XmlRpcValue::TypeArray) && (this->driver_.double_list_.size() == 9)) {
00045 for (int i=0; i<9; i++) {
00046 ROS_ASSERT(this->driver_.double_list_[0].getType() == XmlRpc::XmlRpcValue::TypeDouble);
00047 this->CameraInfo_msg_.R[i] = this->driver_.double_list_[i];
00048 }
00049 }
00050
00051 this->public_node_handle_.getParam("P", this->driver_.double_list_);
00052 if ((this->driver_.double_list_.getType() == XmlRpc::XmlRpcValue::TypeArray) && (this->driver_.double_list_.size() == 12)) {
00053 for (int i=0; i<12; i++) {
00054 ROS_ASSERT(this->driver_.double_list_[0].getType() == XmlRpc::XmlRpcValue::TypeDouble);
00055 this->CameraInfo_msg_.P[i] = this->driver_.double_list_[i];
00056 }
00057 }
00058
00059
00060 this->camera_info_publisher_ = this->public_node_handle_.advertise<sensor_msgs::CameraInfo>("camera_info", 10);
00061 this->image_publisher_ = this->public_node_handle_.advertise<sensor_msgs::Image>("image", 10);
00062
00063
00064
00065
00066
00067
00068
00069
00070
00071
00072 }
00073
00074 void UeyeCameraDriverNode::mainNodeThread(void)
00075 {
00076
00077
00078 this->driver_.lock();
00079
00080
00081 this->Image_msg_.header.stamp=ros::Time::now();
00082 this->Image_msg_.header.frame_id=this->driver_.frame_id_;
00083
00084 this->CameraInfo_msg_.header.stamp=this->Image_msg_.header.stamp;
00085 this->CameraInfo_msg_.header.frame_id = this->Image_msg_.header.frame_id;
00086
00087
00088 if(this->driver_.ueye_cam_.params_.img_bpp==8)
00089 this->Image_msg_.encoding="mono8";
00090 else if(this->driver_.ueye_cam_.params_.img_bpp==24)
00091 this->Image_msg_.encoding="bgr8";
00092 this->Image_msg_.height=this->driver_.ueye_cam_.params_.img_height;
00093 this->Image_msg_.width=this->driver_.ueye_cam_.params_.img_width;
00094 this->Image_msg_.step=this->driver_.ueye_cam_.img_step_;
00095 this->Image_msg_.is_bigendian=0;
00096 this->driver_.img_data_size_=this->driver_.ueye_cam_.params_.img_height*this->driver_.ueye_cam_.img_step_;
00097 this->Image_msg_.data.resize(this->driver_.img_data_size_);
00098
00099 this->CameraInfo_msg_.height = this->driver_.ueye_cam_.params_.img_height;
00100 this->CameraInfo_msg_.width = this->driver_.ueye_cam_.params_.img_width;
00101
00102
00103 if(this->driver_.get_image()){
00104
00105
00106 this->Image_msg_.data = this->driver_.ueye_cam_.image_data_;
00107
00108
00109 this->camera_info_publisher_.publish(this->CameraInfo_msg_);
00110 this->image_publisher_.publish(this->Image_msg_);
00111 }
00112
00113
00114
00115
00116
00117
00118 this->driver_.unlock();
00119 }
00120
00121
00122
00123
00124
00125
00126
00127
00128
00129 void UeyeCameraDriverNode::postNodeOpenHook(void)
00130 {
00131 }
00132
00133 void UeyeCameraDriverNode::addNodeDiagnostics(void)
00134 {
00135 }
00136
00137 void UeyeCameraDriverNode::addNodeOpenedTests(void)
00138 {
00139 }
00140
00141 void UeyeCameraDriverNode::addNodeStoppedTests(void)
00142 {
00143 }
00144
00145 void UeyeCameraDriverNode::addNodeRunningTests(void)
00146 {
00147 }
00148
00149 void UeyeCameraDriverNode::reconfigureNodeHook(int level)
00150 {
00151 }
00152
00153 UeyeCameraDriverNode::~UeyeCameraDriverNode(void)
00154 {
00155
00156 }
00157
00158
00159 int main(int argc,char *argv[])
00160 {
00161 return driver_base::main<UeyeCameraDriverNode>(argc, argv, "ueye_camera_driver_node");
00162 }