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
00027
00028
00029
00030
00031
00032
00033
00034
00035
00036
00037 #include "../include/CParam.h"
00038
00039 using namespace iav_depthimage_to_laserscan;
00040
00041 CParam::CParam() {
00042 }
00043
00044 CParam::~CParam() {
00045 }
00046
00047
00048
00049
00050
00051
00052
00053
00054 void CParam::createTF(std::string header, std::string child) {
00055
00056 geometry_msgs::TransformStamped* tf = new geometry_msgs::TransformStamped();
00057
00058
00059 tf->header.frame_id = header;
00060 tf->child_frame_id = child;
00061
00062
00063
00064 tf->transform.translation.x = cam_offset*cos(cam_yaw);
00065 tf->transform.translation.y = cam_offset*sin(cam_yaw);
00066 tf->transform.translation.z = 0.0;
00067
00068
00069
00070 tf->transform.rotation = tf::createQuaternionMsgFromRollPitchYaw(0.0, cam_pitch, cam_yaw);
00071
00072
00073 m_tf = tf;
00074 }
00075
00076
00077
00078
00079
00080
00081
00082
00083 void CParam::init_parameter(CParam& Param, LSParam& laserParam, float height_max, float height_min) {
00084
00085
00086 Param.cam_max_distances = (float*) malloc (Param.cam_image_height*sizeof(float));
00087 Param.cam_min_distances = (float*) malloc (Param.cam_image_height*sizeof(float));
00088
00089 Param.cam_sin_v = (float*) malloc (Param.cam_image_height*sizeof(float));
00090 Param.cam_cos_v = (float*) malloc (Param.cam_image_height*sizeof(float));
00091 Param.cam_cos_h = (float*) malloc (Param.cam_image_width*sizeof(float));
00092 Param.cam_index = (int*) malloc (Param.cam_image_width*sizeof(int));
00093
00094
00095 float increment_v = Param.cam_AOV_v / Param.cam_image_height;
00096 float distance_a;
00097 float distance_b;
00098 float longer;
00099 float shorter;
00100 float angle;
00101
00102
00103 double th;
00104 double angle_min = laserParam.laser_min_angle;
00105 double angle_increment = (laserParam.laser_max_angle - laserParam.laser_min_angle)/(laserParam.laser_rays - 1);
00106
00107
00108 float center_x = Param.cam_image_width/2;
00109 float center_y = Param.cam_image_height/2;
00110
00111
00112 double unit_scaling = 0.001f;
00113 float constant_x = unit_scaling / Param.cam_focal_length_x;
00114 float constant_y = unit_scaling / Param.cam_focal_length_y;
00115
00116
00117 for(int u = 0; u < Param.cam_image_width; u++) {
00118 th = atan2((double)(center_x - u) * constant_x, unit_scaling);
00119
00120 if((th - angle_min + cam_yaw) / angle_increment > laserParam.laser_rays - 1) cam_index[u] = laserParam.laser_rays - 1;
00121 else if((th - angle_min + cam_yaw) / angle_increment < 0) cam_index[u] = 0;
00122 else cam_index[u] = (th - angle_min + cam_yaw) / angle_increment;
00123
00124 Param.cam_cos_h[u] = cos (th);
00125 }
00126
00127
00128 for (int j = 0; j < Param.cam_image_height; j++) {
00129 angle = atan2((double)(center_y - j) * constant_y, unit_scaling) - Param.cam_pitch;
00130
00131 Param.cam_sin_v[j] = sin (angle);
00132 Param.cam_cos_v[j] = cos (angle);
00133
00134
00135 if (Param.cam_sin_v [j] != 0.0) {
00136 distance_a = (height_max) / Param.cam_sin_v[j];
00137 distance_b = (height_min) / Param.cam_sin_v[j];
00138
00139 if (distance_a < 0.0) {
00140 distance_a = laserParam.laser_min_range;
00141 }
00142
00143 if (distance_b < 0.0){
00144 distance_b = laserParam.laser_min_range;
00145 }
00146
00147 longer = std::max ( distance_a, distance_b );
00148 shorter = std::min ( distance_a, distance_b );
00149
00150 Param.cam_max_distances[j] = std::min(longer,(float) laserParam.laser_max_range);
00151 Param.cam_min_distances[j] = std::max(shorter,(float) laserParam.laser_min_range);
00152 }
00153
00154 else
00155 {
00156 Param.cam_max_distances[j] = laserParam.laser_max_range;
00157 Param.cam_min_distances[j] = laserParam.laser_min_range;
00158 }
00159 }
00160 }