66 #include "pcl/io/io.h" 67 #include "pcl/point_types.h" 68 #include "pcl/point_cloud.h" 69 #include "pcl/registration/ia_ransac.h" 70 #include <pcl/point_types.h> 71 #include <pcl/io/pcd_io.h> 76 #include "std_msgs/String.h" 77 #include "sensor_msgs/PointCloud2.h" 78 #include "geometry_msgs/Vector3.h" 79 #include <visualization_msgs/Marker.h> 80 #include <visualization_msgs/MarkerArray.h> 83 #include <haf_grasping/CalcGraspPointsServerAction.h> 94 #define PI 3.141592653 95 #define ROLL_STEPS_DEGREE 15 //define in degree how different the tested rolls should be 96 #define TILT_STEPS_DEGREE 40 //define in degree the angle for one tilt step 97 #define TILT_STEPS 1 //define the number of tilt steps [not used anymore] 101 #define ROLL_MAX_DEGREE 190//190 117 haf_grasping::CalcGraspPointsServerResult
result_;
166 void print_heights(
int nr_roll,
int nr_tilt);
167 void read_pc_cb(
const haf_grasping::CalcGraspPointsServerGoalConstPtr &goal);
168 void loop_control(pcl::PointCloud<pcl::PointXYZ> pcl_cloud_in);
169 void generate_grid(
int roll,
int tilt, pcl::PointCloud<pcl::PointXYZ> pcl_cloud_in);
170 void publish_transformed_pcl_cloud(
int roll,
int tilt, pcl::PointCloud<pcl::PointXYZ> pcl_cloud_in);
171 void calc_intimage(
int roll,
int tilt);
172 void calc_featurevectors(
int roll,
int tilt);
173 void pnt_in_box(
int nr_roll,
int nr_tilt);
174 void predict_bestgp_withsvm(
bool svm_with_probability=
false);
175 void show_predicted_gps(
int nr_roll,
int tilt,
bool svm_with_probability=
false);
176 void transform_gp_in_wcs_and_publish(
int id_row_top_all,
int id_col_top_all,
int nr_roll_top_all,
int nr_tilt_top_all,
int scaled_gp_eval);
177 void publish_grasp_grid(
int nr_roll,
int tilt,
float graspsgrid[][
WIDTH],
int gripperwidth);
178 void gp_to_marker(visualization_msgs::Marker *marker,
float x,
float y,
float z,
float green,
bool pubmarker,
int gripperwidth,
int nr_roll,
bool pub_grip_open_dir,
bool pub_grid);
179 void grasp_area_to_marker(visualization_msgs::Marker *marker,
float x,
float y,
float z,
int gripperwidth,
int nr_roll,
int param_id,
bool top_grasp);
185 this->pubGraspPointsEval = nh_.
advertise<std_msgs::String>(
"/haf_grasping/grasp_hypothesis_with_eval", 1);
186 this->vis_pub = nh_.
advertise<visualization_msgs::Marker>(
"visualization_marker", 1 );
187 this->vis_pub_ma = nh_.
advertise<visualization_msgs::MarkerArray>(
"visualization_marker_array", 1 );
188 this->vis_pub_ma_params = nh_.
advertise<visualization_msgs::MarkerArray>(
"visualization_marker_array_grasp_params", 1 );
189 this->pubInputPCROS = nh_.
advertise<sensor_msgs::PointCloud2>(
"/haf_grasping/calc_gp_as_inputpcROS", 1);
190 this->pubTransformedPCROS = nh_.
advertise<sensor_msgs::PointCloud2>(
"/haf_grasping/transformed_point_cloud",1);
191 this->graspsearchcenter.x = 0;
192 this->graspsearchcenter.y = 0;
193 this->graspsearchcenter.z = 0;
194 this->grasp_search_area_size_x_dir = 32;
195 this->grasp_search_area_size_y_dir = 44;
196 this->approach_vector.x = 0;
197 this->approach_vector.y = 0;
198 this->approach_vector.z = 1;
199 this->max_duration_for_grasp_calc = 50;
200 outputpath_full =
"/tmp/features.txt";
201 this->return_only_best_gp =
false;
204 graspval_max_diff_for_pub = 80;
205 id_row_top_overall = -1;
206 id_col_top_overall = -1;
207 nr_roll_top_overall = -1;
208 nr_tilt_top_overall = -1;
209 topval_gp_overall = -1000;
211 this->visualization =
true;
212 this->print_heights_bool =
false;
213 this->av_trans_mat = Eigen::Matrix4f::Identity();;
214 this->trans_z_after_pc_transform = 0.15;
215 this->gripper_opening_width = 1;
218 this->feature_file_path =
"";
219 nh_.
param(
"feature_file_path", this->feature_file_path, this->feature_file_path);
220 this->range_file_path =
"";
221 nh_.
param(
"range_file_path", this->range_file_path, this->range_file_path);
222 this->svmmodel_file_path =
"";
223 nh_.
param(
"svmmodel_file_path", this->svmmodel_file_path, this->svmmodel_file_path);
224 this->nr_features_without_shaf = 302;
225 nh_.
param(
"nr_features_without_shaf", this->nr_features_without_shaf, this->nr_features_without_shaf);
237 cout <<
"\n CCalc_Grasppoints::print_heights: print heights matrix for roll number : " << nr_roll <<
"\t and tilt nr: "<< nr_tilt << endl;
238 for (
int i = 0; i <
HEIGHT; i++){
239 for (
int j = 0; j <
WIDTH; j++){
240 cout << setw(5) << setprecision(2) << this->heightsgridroll[nr_roll][nr_tilt][HEIGHT-i-1][WIDTH-j-1];
252 ROS_INFO(
"\n ==> calc_grasppoints_action_server.cpp: read_pc_cb() --> GRASP GOAL RECEIVED (incl. point cloud)");
254 pcl::PointCloud<pcl::PointXYZ> pcl_cloud_in;
255 pcl::PointCloud<pcl::PointXYZ> pc_new_cs;
258 this->graspsearchcenter.x = goal->graspinput.grasp_area_center.x;
259 this->graspsearchcenter.y = goal->graspinput.grasp_area_center.y;
260 this->graspsearchcenter.z = goal->graspinput.grasp_area_center.z;
262 cout <<
"************************************************************************************************************" << endl;
263 cout <<
" --> SET NEW GRASP SEARCH CENTER: [x,y,z] = [" << this->graspsearchcenter.x <<
"," << this->graspsearchcenter.y <<
"," << this->graspsearchcenter.z <<
"]" << endl;
266 this->grasp_search_area_size_x_dir = goal->graspinput.grasp_area_length_x;
267 this->grasp_search_area_size_y_dir = goal->graspinput.grasp_area_length_y;
270 float vector_length = sqrt(goal->graspinput.approach_vector.x*goal->graspinput.approach_vector.x+goal->graspinput.approach_vector.y*goal->graspinput.approach_vector.y+goal->graspinput.approach_vector.z*goal->graspinput.approach_vector.z);
271 this->approach_vector.x = goal->graspinput.approach_vector.x/vector_length;
272 this->approach_vector.y = goal->graspinput.approach_vector.y/vector_length;
273 this->approach_vector.z = goal->graspinput.approach_vector.z/vector_length;
274 cout <<
" --> SET APPROACH VECTOR TO: " <<
" [x,y,z] = [" << this->approach_vector.x <<
"," << this->approach_vector.y <<
"," << this->approach_vector.z <<
"]" << endl;
277 this->max_duration_for_grasp_calc = (float) goal->graspinput.max_calculation_time.toSec();
278 cout <<
" --> SET MAX. CALCULATION TIME TO: " << this->max_duration_for_grasp_calc << endl;
281 this->gripper_opening_width = (float) goal->graspinput.gripper_opening_width;
284 this->return_only_best_gp = (
bool) goal->graspinput.show_only_best_grasp;
285 cout <<
" --> SET show_only_best_grasp TO: " << this->return_only_best_gp << endl;
288 string orig_tf = (string) goal->graspinput.input_pc.header.frame_id;
289 cout <<
" --> FRAME_ID ORIGINAL Point Cloud: " << orig_tf << endl;
291 cout <<
"Fixed by now: this->trans_z_after_pc_transform: " << this->trans_z_after_pc_transform << endl;
294 if (!goal->graspinput.goal_frame_id.empty())
296 this->base_frame_id = goal->graspinput.goal_frame_id;
300 this->base_frame_id =
"/base_link";
302 cout <<
" --> BASE_FRAME_ID: " << this->base_frame_id << endl;
304 cout <<
"************************************************************************************************************" << endl;
307 bool foundTransform = tf_listener.waitForTransform(this->base_frame_id, orig_tf, goal->graspinput.input_pc.header.stamp,
ros::Duration(1.0));
310 ROS_WARN(
" ==> calc_grasppoints_action_server.cpp: read_pc_cb(): NO TRANSFORM FOR POINT CLOUD FOUND");
313 pcl::PointCloud<pcl::PointXYZ> pcl_cloud_in_old_cs;
319 this->pubInputPCROS.publish(goal->graspinput.input_pc);
322 id_row_top_overall = -1;
323 id_col_top_overall = -1;
324 nr_roll_top_overall = -1;
325 nr_tilt_top_overall = -1;
326 topval_gp_overall = -1000;
328 loop_control(pc_new_cs);
337 int time_for_calc_in_secs = this->max_duration_for_grasp_calc;
348 feedback_.feedback.data =
"this->topval_gp_overall";
350 if (as_.isPreemptRequested() || !
ros::ok() || success ==
false)
352 ROS_INFO(
"%s: Preempted", action_name_.c_str());
359 as_.publishFeedback(feedback_);
362 if (this->return_only_best_gp and (this->topval_gp_overall >= this->graspval_top)){
363 cout <<
"Top grasp already found\n";
369 timedif = difftime (end,start);
370 cout <<
"\n ===> TEST ROTATION: " << roll*
ROLL_STEPS_DEGREE <<
"\nRuntime so far (in sec): " << timedif << endl;
371 if (timedif > time_for_calc_in_secs) {
372 cout <<
"\n Calculation time is over, stop calculation of grasp points!!\n";
376 generate_grid(roll, tilt, pcl_cloud_in);
377 if (this->print_heights_bool){
378 print_heights(roll,tilt);
380 calc_intimage(roll, tilt);
381 calc_featurevectors(roll, tilt);
383 bool svm_with_probability =
false;
384 predict_bestgp_withsvm(svm_with_probability);
385 show_predicted_gps(roll, tilt, svm_with_probability);
389 publish_transformed_pcl_cloud(0, 0, pcl_cloud_in);
390 transform_gp_in_wcs_and_publish(this->id_row_top_overall, this->id_col_top_overall, this->nr_roll_top_overall,this->nr_tilt_top_overall, this->topval_gp_overall-20);
393 timedif = difftime (end,start);
394 cout <<
"\n Gesamtzeit fuer Loop: " << timedif << endl;
398 result_.graspOutput = this->gp_result;
400 as_.setSucceeded(result_);
408 pcl::PointCloud<pcl::PointXYZ> pcl_cloud_transformed;
410 float r_col_m = (0.5 * (float)nr_cols)/100.0;
411 float r_row_m = (0.5 * (float)nr_rows)/100.0;
413 float rot_about_x = 0;
415 pcl::PointXYZ *av =
new pcl::PointXYZ(0,0,-1);
418 av->x = this->approach_vector.x;
419 av->y = this->approach_vector.y;
420 av->z = this->approach_vector.z;
423 Eigen::Matrix4f mat_sh_to_orig = Eigen::Matrix4f::Identity();
424 Eigen::Matrix4f mat_rot_z_axis = Eigen::Matrix4f::Identity();
425 Eigen::Matrix4f mat_rot_x_axis = Eigen::Matrix4f::Identity();
426 Eigen::Matrix4f mat_sh_from_orig = Eigen::Matrix4f::Identity();
427 Eigen::Matrix4f mat_rot = Eigen::Matrix4f::Identity();
428 Eigen::Matrix4f mat_scale_x_dir = Eigen::Matrix4f::Identity();
430 Eigen::Matrix4f mat_transform = Eigen::Matrix4f::Identity();
433 mat_scale_x_dir(0,0) = this->gripper_opening_width;
435 mat_sh_to_orig(0,3) = -this->graspsearchcenter.x;
436 mat_sh_to_orig(1,3) = -this->graspsearchcenter.y;
437 mat_sh_to_orig(2,3) = -this->graspsearchcenter.z;
439 mat_sh_from_orig(0,3) = 0;
440 mat_sh_from_orig(1,3) = 0;
441 mat_sh_from_orig(2,3) = 0 + this->trans_z_after_pc_transform;
444 if (av->y == 0 and av->x == 0){
452 rot_about_z = 90*
PI/180.0 - atan2(av->y, av->x);
453 rot_about_x = 90*
PI/180.0 - atan2( av->z, sqrt(av->y*av->y + av->x*av->x) );
463 mat_rot(0,0) = cos(angle);
464 mat_rot(0,1) = -sin(angle);
465 mat_rot(1,0) = sin(angle);
466 mat_rot(1,1) = cos(angle);
469 mat_rot_z_axis(0,0) = cos(rot_about_z);
470 mat_rot_z_axis(0,1) = -sin(rot_about_z);
471 mat_rot_z_axis(1,0) = sin(rot_about_z);
472 mat_rot_z_axis(1,1) = cos(rot_about_z);
476 mat_rot_x_axis(1,1) = cos(rot_about_x);
477 mat_rot_x_axis(1,2) = -sin(rot_about_x);
478 mat_rot_x_axis(2,1) = sin(rot_about_x);
479 mat_rot_x_axis(2,2) = cos(rot_about_x);
483 mat_transform = mat_scale_x_dir * mat_rot* mat_sh_from_orig * mat_rot_x_axis * mat_rot_z_axis * mat_sh_to_orig;
484 this->av_trans_mat = mat_transform;
487 pcl::copyPointCloud(pcl_cloud_in, pcl_cloud_transformed);
488 pcl::transformPointCloud(pcl_cloud_in, pcl_cloud_transformed, mat_transform);
492 if (this->visualization)
494 cout <<
"Publish transformed point cloud! \n";
495 this->pubTransformedPCROS.publish(pcl_cloud_transformed);
499 for (
int i = 0; i < nr_rows; i++)
500 for (
int j = 0; j < nr_cols; j++)
501 this->heightsgridroll[roll][tilt][i][j]= -1.0;
504 for (
size_t i = 0; i < pcl_cloud_transformed.points.size(); ++i)
508 int idx_x = -1, idx_y = -1;
509 pnt = pcl_cloud_transformed.points[i];
510 if ((pnt.x > -r_row_m) and (pnt.x < r_row_m) and
511 (pnt.y > -r_col_m) and (pnt.y < r_col_m))
513 idx_x = (int) (floor (100*(pnt.x - ( - r_row_m))));
514 idx_y = (int) (floor (100*(pnt.y - ( - r_col_m))));;
515 if (heightsgridroll[roll][tilt][idx_x][idx_y] < pnt.z)
517 heightsgridroll[roll][tilt][idx_x][idx_y] = pnt.z;
522 for (
int i = 0; i < nr_rows; i++){
523 for (
int j = 0; j < nr_cols; j++){
524 if (this->heightsgridroll[roll][tilt][i][j] < -0.99){
525 this->heightsgridroll[roll][tilt][i][j] = 0;
535 pcl::PointCloud<pcl::PointXYZ> pcl_cloud_transformed;
537 Eigen::Matrix4f mat_sh_orig = Eigen::Matrix4f::Identity();
538 Eigen::Matrix4f mat_rot = Eigen::Matrix4f::Identity();
539 Eigen::Matrix4f mat_tilt = Eigen::Matrix4f::Identity();
540 Eigen::Matrix4f mat_sh_from_orig = Eigen::Matrix4f::Identity();
541 Eigen::Matrix4f mat_transform = Eigen::Matrix4f::Identity();
543 mat_sh_orig(0,3) = -this->graspsearchcenter.x;
544 mat_sh_orig(1,3) = -this->graspsearchcenter.y;
545 mat_sh_from_orig(0,3) = this->graspsearchcenter.x;
546 mat_sh_from_orig(1,3) = this->graspsearchcenter.y;
552 mat_rot(0,0) = cos(angle);
553 mat_rot(0,1) = -sin(angle);
554 mat_rot(1,0) = sin(angle);
555 mat_rot(1,1) = cos(angle);
558 mat_tilt(0,0) = cos(beta);
559 mat_tilt(0,2) = -sin(beta);
560 mat_tilt(2,0) = sin(beta);
561 mat_tilt(2,2) = cos(beta);
563 mat_transform = mat_sh_from_orig*mat_tilt*mat_rot*mat_sh_orig;
565 pcl::copyPointCloud(pcl_cloud_in, pcl_cloud_transformed);
566 pcl::transformPointCloud(pcl_cloud_in, pcl_cloud_transformed, mat_transform);
570 this->pubTransformedPCROS.publish(pcl_cloud_transformed);
579 cv::Mat heightsIntegral;
580 heightsIntegral = cv::Mat(
HEIGHT+1,
WIDTH+1, CV_64FC1);
583 double *TempHeights = (
double *)malloc(
HEIGHT *
WIDTH *
sizeof(
double));
586 for(
int i = 0; i <
HEIGHT; i++ )
587 for(
int j = 0; j <
WIDTH; j++ )
589 TempHeights[k] = this->heightsgridroll[roll][tilt][i][j];
593 cv::Mat
const cvheightsmat = cv::Mat(HEIGHT, WIDTH, CV_64FC1, TempHeights);
595 integral(cvheightsmat, heightsIntegral,CV_64FC1);
599 for (
int row = 0; row < 1+
HEIGHT; row++)
600 for (
int col = 0; col < 1+
WIDTH; col++)
601 this->integralimageroll[roll][tilt][row][col] = ((
double*)(heightsIntegral.ptr() + heightsIntegral.step*row))[col];
626 if (this->feature_file_path ==
""){
627 this->feature_file_path = pkg_path +
"/data/Features.txt";
632 ofstream output_fv_file(outputpath_full.c_str());
635 pnt_in_box(roll, tilt);
637 for (
int row = 0; row <
HEIGHT - 14; row++){
638 for (
int col = 0; col <
WIDTH -14; col++)
641 if (!this->point_inside_box_grid[roll][tilt][row+7][col+7]){
646 for (
int i = 0; i < 15; i++){
647 for (
int j = 0; j < 15; j++){
648 ii_to_fv->
intimagemat[i][j] = this->integralimageroll[roll][tilt][row+i][col+j];
668 bool print_pnt_in_box =
false;
680 float alpha = alpha_deg*
PI/180;
683 float cx1,cy1,cx2,cy2,cx3,cy3,cx4,cy4;
687 float height_r = this->grasp_search_area_size_x_dir/2 - boarder;
688 float width_r = this->grasp_search_area_size_y_dir/2 - boarder;
689 cx1 = cx - sin(alpha)*height_r;
690 cy1 = cy + cos(alpha)*height_r;
691 cx2 = cx + sin(alpha)*height_r;
692 cy2 = cy - cos(alpha)*height_r;
693 cx3 = cx - sin(alpha+
PI/2)*width_r;
694 cy3 = cy + cos(alpha+
PI/2)*width_r;
695 cx4 = cx + sin(alpha+
PI/2)*width_r;
696 cy4 = cy - cos(alpha+
PI/2)*width_r;
698 if (print_pnt_in_box)
699 cout << cx1 <<
"\t" << cy1 <<
"\n" << cx2 <<
"\t" << cy2 <<
"\n" << cx3 <<
"\t" << cy3 <<
"\n" << cx4 <<
"\t" << cy4 <<
"\n\n";
704 for (
int i = 0; i <
HEIGHT; i++){
705 for (
int j = 0; j <
HEIGHT; j++){
710 float ii_th_in_r = 0.03;
713 if ((i>6 and i < HEIGHT-7 and j>6 and j<HEIGHT-7) and
714 (this->integralimageroll[nr_roll][nr_tilt][i+th_empty_r][j+th_empty_r]-
715 this->integralimageroll[nr_roll][nr_tilt][i-th_empty_r-1][j+th_empty_r]-
716 this->integralimageroll[nr_roll][nr_tilt][i+th_empty_r][j-th_empty_r-1]+
717 this->integralimageroll[nr_roll][nr_tilt][i-th_empty_r-1][j-th_empty_r-1] > ii_th_in_r) and
718 (-sin(alpha)*(-cx1+j) + cos(alpha)*(-cy1+i) < 0.00001) and
719 (-sin(alpha)*(-cx2+j) + cos(alpha)*(-cy2+i) > -0.00001) and
720 ( cos(alpha)*(-cx3+j) + sin(alpha)*(-cy3+i) > -0.00001) and
721 ( cos(alpha)*(-cx4+j) + sin(alpha)*(-cy4+i) < 0.00001)){
724 this->point_inside_box_grid[nr_roll][nr_tilt][i][j] =
true;
729 this->point_inside_box_grid[nr_roll][nr_tilt][i][j] =
false;
736 if (print_pnt_in_box){
737 cout <<
"points_all: " << cnt_all <<
" points in: " << cnt_in <<
" and points out: " << cnt_out << endl;
738 for (
int i = HEIGHT-1; i >= 0; i--){
739 for (
int j = HEIGHT-1; j >= 0; j--){
740 if (this->point_inside_box_grid[nr_roll][nr_tilt][i][j] ==
true){
763 stringstream ss, ss2;
767 if (this->range_file_path ==
""){
768 this->range_file_path = pkg_path +
"/data/range21062012_allfeatures";
771 if (this->svmmodel_file_path ==
""){
772 this->svmmodel_file_path = pkg_path +
"/data/all_features.txt.scale.model";
775 ss << pkg_path <<
"/libsvm-3.12/svm-scale -r " << this->range_file_path <<
" /tmp/features.txt > /tmp/features.txt.scale";
777 int i = system(command.c_str());
779 ROS_WARN(
" CCalc_Grasppoints::predict_bestgp_withsvm() SCALING OF FEATURES WAS NOT EXECUTED AS IT SHOULD (Was SVM code compiled?) ");
780 cout <<
"===> CCalc_Grasppoints::predict_bestgp_withsvm: System return value for scaling features is: " << i << endl;
784 if (!svm_with_probability){
786 ss2 << pkg_path <<
"/libsvm-3.12/svm-predict /tmp/features.txt.scale " << this->svmmodel_file_path <<
" /tmp/output_calc_gp.txt";
787 string command2 = ss2.str();
788 i = system(command2.c_str());
791 i = system(
"/usr/lib/libsvm/libsvm-3.1/svm-predict -b 1 /tmp/features.txt.scale /usr/lib/libsvm/libsvm-3.1/tools/allmanualfeatures.txt.scale.p.model /tmp/output_calc_gp.txt");
794 ROS_WARN(
" CCalc_Grasppoints::predict_bestgp_withsvm() GRASP PREDICTION FROM FEATURES WAS NOT EXECUTED AS IT SHOULD (Was SVM code compiled?) ");
795 cout <<
"===> CCalc_Grasppoints::predict_bestgp_withsvm: System return value for execution of grasp prediction with SVM: " << i << endl;
798 cerr <<
"ERROR in calc_grasppoints.cpp: predict_bestgp_withsvm()" << endl;
805 string path_svm_output =
"/tmp/output_calc_gp.txt";
808 ifstream file_in(path_svm_output.c_str());
811 int id_row_top_all = -1;
812 int id_col_top_all = -1;
813 int nr_roll_top_all = -1;
814 int nr_tilt_top_all = -1;
815 int topval_gp_all = -1000;
818 getline(file_in, line);
820 bool printgraspsgrid =
false;
821 bool printgraspseval =
false;
825 for (
int row = 0; row <
HEIGHT; row++){
826 for (
int col = 0; col <
WIDTH; col++){
828 if (this->point_inside_box_grid[nr_roll][tilt][row][col] ==
false){
829 graspsgrid[row][col] = -1;
831 if (svm_with_probability){
832 int start=0,end=0, res;
833 res = atof(line.substr(0,2).c_str());
834 start = line.find(
" ",0);
835 end = line.find(
" ",start+1);
838 end = line.find(
" ", start+1);
840 float prob = atof(line.substr(start,end).c_str());
841 graspsgrid[row][col] = res*
prob;
843 graspsgrid[row][col] = atoi(line.substr(0,2).c_str());
846 getline(file_in, line);
852 if (printgraspsgrid){
853 cout <<
"\n Graspsgrid: intuitiv! \n";
854 for (
int row = HEIGHT-1; row >= 0; row--){
855 cout << row <<
") \t";
856 for (
int col =
WIDTH-1; col >= 0; col--){
857 cout << graspsgrid[row][col] <<
"\t";
864 if (printgraspseval) cout <<
"graspseval[row][col]" <<
"\n\n";
865 int w1=1, w2=2,w3=3,w4=4,w5=55;
866 int topval_gp = -1000;
867 int id_row_top = -1, id_col_top = -1;
868 for (
int row = 0; row <
HEIGHT; row++){
869 for (
int col = 0; col <
WIDTH; col++){
870 if ( graspsgrid[row][col] < 0 ){
871 graspseval[row][col] = 0;
873 graspseval[row][col] =
874 w1*graspsgrid[row-2][col-2]+w2*graspsgrid[row-2][col-1]+w3*graspsgrid[row-2][col]+w2*graspsgrid[row-2][col+1]+w1*graspsgrid[row-2][col+2]+
875 w2*graspsgrid[row-1][col-2]+w3*graspsgrid[row-1][col-1]+w4*graspsgrid[row-1][col]+w3*graspsgrid[row-1][col+1]+w2*graspsgrid[row-1][col+2]+
876 w2*graspsgrid[row][col-4] + w2*graspsgrid[row][col-3] + w3*graspsgrid[row][col-2] + w4*graspsgrid[row][col-1] + w5*graspsgrid[row][col] + w4*graspsgrid[row][col+1] + w3*graspsgrid[row][col+2] + w2*graspsgrid[row][col+3] +w2*graspsgrid[row][col+4] +
877 w2*graspsgrid[row+1][col-2]+w3*graspsgrid[row+1][col-1]+w4*graspsgrid[row+1][col]+w3*graspsgrid[row+1][col+1]+w2*graspsgrid[row+1][col+2]+
878 w1*graspsgrid[row+2][col-2]+w2*graspsgrid[row+2][col-1]+w3*graspsgrid[row+2][col]+w2*graspsgrid[row+2][col+1]+w1*graspsgrid[row+2][col+2];
881 if (printgraspseval) cout << graspseval[row][col] <<
"\t";
882 if (graspseval[row][col] > topval_gp){
883 topval_gp = graspseval[row][col];
886 if (topval_gp > topval_gp_all){
887 cout <<
"New overall grasp evaluation with value: " << topval_gp <<
" in row,col: [" << id_row_top <<
", " << id_col_top <<
"] and rotation: " << nr_roll*
ROLL_STEPS_DEGREE << endl;
888 id_row_top_all = id_row_top;
889 id_col_top_all = id_col_top;
890 nr_roll_top_all = nr_roll;
891 nr_tilt_top_all = tilt;
892 topval_gp_all = topval_gp;
896 if (printgraspseval) cout <<
"\n";
902 publish_grasp_grid(nr_roll, tilt, graspseval, 1);
905 int best_topval_row = -1, best_topval_col = -1;
906 int longest_topval_len = 0;
907 int cur_topval_len = 0;
908 bool count_topval_len =
false;
909 for (
int row = 0; row <
HEIGHT; row++){
911 count_topval_len =
false;
912 for (
int col = 0; col <
WIDTH; col++){
913 if (graspseval[row][col] == topval_gp){
914 count_topval_len =
true;
916 if (cur_topval_len > longest_topval_len){
917 longest_topval_len = cur_topval_len;
918 best_topval_row = row;
919 best_topval_col = col - cur_topval_len/2;
920 if (topval_gp == topval_gp_all){
921 cout <<
"Better topval gp still with topval: " << topval_gp <<
" in row,col: [" << best_topval_row <<
", " << best_topval_col <<
"] and rotation: " << nr_roll*
ROLL_STEPS_DEGREE << endl;
922 id_row_top_all = best_topval_row;
923 id_col_top_all = best_topval_col;
928 count_topval_len =
false;
936 if (printgraspseval) {
937 cout <<
"\n Grasps predicted more intuitively: \n";
938 for (
int row = HEIGHT-1; row >= 0; row--){
939 for (
int col =
WIDTH-1; col >= 0; col--){
940 cout << setw(3) << setprecision(3) <<graspseval[row][col];
941 if (col > 6 and col <
WIDTH-7 )
944 if (row > 7 and row < HEIGHT - 7)
949 cout <<
"\n Best grasp value for currently tested roll: " << topval_gp_all << endl;
953 if (topval_gp_all > this->topval_gp_overall){
954 cout <<
"\n New overall (overall!) grasp evaluation with value: " << topval_gp_all <<
" in row,col: [" << id_row_top_all <<
", " << id_col_top_all <<
"] and rotation: " << nr_roll*
ROLL_STEPS_DEGREE << endl;
955 this->id_row_top_overall = id_row_top_all;
956 this->id_col_top_overall = id_col_top_all;
957 this->nr_roll_top_overall = nr_roll_top_all;
958 this->nr_tilt_top_overall = nr_tilt_top_all;
959 this->topval_gp_overall = topval_gp_all;
962 if (this->return_only_best_gp){
963 cout <<
"\n Grasp detection for one roll finished. Only best grasp is published after full gp calculation! \n";
964 }
else if ((topval_gp_all > this->graspval_th) ){
967 int scaled_gp_eval = topval_gp_all-20;
968 if (scaled_gp_eval < 10) scaled_gp_eval = 10;
969 transform_gp_in_wcs_and_publish(id_row_top_all, id_col_top_all,nr_roll_top_all, nr_tilt_top_all, scaled_gp_eval);
971 cout <<
"\n For current roll no grasp point had an evaluation above threshold for publishing! \n";
980 visualization_msgs::MarkerArray ma;
981 visualization_msgs::MarkerArray ma_params;
982 visualization_msgs::Marker marker;
983 visualization_msgs::Marker marker_graps_params;
984 cout <<
"publish_grasp_grid: input parameter gripperwidth: " << gripperwidth << endl;
986 x = this->graspsearchcenter.x - 0.01*
HEIGHT/2/gripperwidth;
987 y = this->graspsearchcenter.y - 0.01*WIDTH/2;
988 z = this->graspsearchcenter.z + this->trans_z_after_pc_transform;
992 for (
int row = 0; row <=
HEIGHT-1; row++){
993 for (
int col = 0; col <= WIDTH-1; col++){
994 if (this->point_inside_box_grid[nr_roll][tilt][row][col] ==
true){
995 gp_to_marker(&marker, x+0.01/gripperwidth*row,y+0.01*col,z, graspsgrid[row][col],
false, gripperwidth, nr_roll,
false,
true);
996 ma.markers.push_back(marker);
1003 for (
int i = 1; i <= 3; i++){
1004 grasp_area_to_marker(&marker_graps_params, this->graspsearchcenter.x,this->graspsearchcenter.y, z, gripperwidth, nr_roll, i ,
false );
1005 ma_params.markers.push_back(marker_graps_params);
1010 gp_to_marker(&marker, this->graspsearchcenter.x,this->graspsearchcenter.y,z, graspsgrid[0][0],
false, gripperwidth, nr_roll,
true,
true);
1011 ma.markers.push_back(marker);
1013 vis_pub_ma.publish(ma);
1014 vis_pub_ma_params.publish(ma_params);
1020 void CCalc_Grasppoints::gp_to_marker(visualization_msgs::Marker *marker,
float x,
float y,
float z,
float green,
bool pubmarker,
int gripperwidth=1,
int nr_roll=0,
bool pub_grip_open_dir=
false,
bool pub_grid=
true){
1023 string tmp_tf_help =
"tf_help";
1029 if (this->approach_vector.y == 0 and this->approach_vector.x == 0){
1031 if (this->approach_vector.z >= 0) {
1037 rot_z = 90*
PI/180.0 - atan2(this->approach_vector.y, this->approach_vector.x);
1038 rot_x = 90*
PI/180.0 - atan2( this->approach_vector.z, sqrt(this->approach_vector.y*this->approach_vector.y + this->approach_vector.x*this->approach_vector.x) );
1046 Eigen::Matrix4f mat_sh_to_orig = Eigen::Matrix4f::Identity();
1047 Eigen::Matrix4f mat_rot = Eigen::Matrix4f::Identity();
1048 Eigen::Matrix4f mat_sh_from_orig = Eigen::Matrix4f::Identity();
1049 Eigen::Matrix4f mat_transform = Eigen::Matrix4f::Identity();
1050 Eigen::Matrix3f mat_rot_for_appr_vec = Eigen::Matrix3f::Identity();
1052 Eigen::Matrix4f mat_rot_z_axis = Eigen::Matrix4f::Identity();
1053 Eigen::Matrix4f mat_rot_x_axis = Eigen::Matrix4f::Identity();
1056 mat_sh_to_orig(0,3) = -this->graspsearchcenter.x;
1057 mat_sh_to_orig(1,3) = -this->graspsearchcenter.y;
1058 mat_sh_to_orig(2,3) = -this->graspsearchcenter.z;
1059 mat_sh_from_orig(0,3) = 0;
1060 mat_sh_from_orig(1,3) = 0;
1061 mat_sh_from_orig(2,3) = 0 + this->trans_z_after_pc_transform;
1067 mat_rot(0,0) = cos(angle);
1068 mat_rot(0,1) = -sin(angle);
1069 mat_rot(1,0) = sin(angle);
1070 mat_rot(1,1) = cos(angle);
1073 mat_rot_z_axis(0,0) = cos(rot_z);
1074 mat_rot_z_axis(0,1) = -sin(rot_z);
1075 mat_rot_z_axis(1,0) = sin(rot_z);
1076 mat_rot_z_axis(1,1) = cos(rot_z);
1080 mat_rot_x_axis(1,1) = cos(rot_x);
1081 mat_rot_x_axis(1,2) = -sin(rot_x);
1082 mat_rot_x_axis(2,1) = sin(rot_x);
1083 mat_rot_x_axis(2,2) = cos(rot_x);
1086 mat_transform = mat_rot*mat_sh_from_orig*mat_rot_x_axis*mat_rot_z_axis*mat_sh_to_orig;
1091 Tm = mat_transform.inverse();
1093 origin.
setValue(static_cast<double>(Tm(0,3)),static_cast<double>(Tm(1,3)),static_cast<double>(Tm(2,3)));
1095 tf3d.
setValue(static_cast<double>(Tm(0,0)), static_cast<double>(Tm(0,1)), static_cast<double>(Tm(0,2)),
1096 static_cast<double>(Tm(1,0)), static_cast<double>(Tm(1,1)), static_cast<double>(Tm(1,2)),
1097 static_cast<double>(Tm(2,0)), static_cast<double>(Tm(2,1)), static_cast<double>(Tm(2,2)));
1101 this->quat_tf_to_tf_help = tfqt;
1109 std::stringstream ss;
1111 (*marker).header.frame_id = ss.str();
1113 (*marker).ns =
"my_namespace";
1114 (*marker).id = marker_cnt++;
1115 (*marker).type = visualization_msgs::Marker::SPHERE;
1116 (*marker).action = visualization_msgs::Marker::ADD;
1117 (*marker).pose.position.x = x-this->graspsearchcenter.x;
1118 (*marker).pose.position.y = y-this->graspsearchcenter.y;
1119 (*marker).pose.position.z = z;
1120 (*marker).pose.orientation.x = 0.0;
1121 (*marker).pose.orientation.y = 0.0;
1122 (*marker).pose.orientation.z = 0.0;
1123 (*marker).pose.orientation.w = 1.0;
1124 (*marker).scale.x = 0.002;
1126 (*marker).scale.y = 0.002;
1127 (*marker).scale.z = 0.002;
1128 (*marker).color.a = 1.0;
1130 (*marker).color.r = 0.0;
1131 (*marker).color.g = 1.0;
1132 (*marker).scale.x = 0.005;
1133 (*marker).scale.y = 0.005;
1134 (*marker).scale.z = 0.001*green;
1135 (*marker).pose.position.z = z+(*marker).scale.z/2;
1137 (*marker).color.r = 1.0;
1138 (*marker).color.g = 0.0;
1140 (*marker).color.b = 0.0;
1147 int fix_marker_id_gripper_dir = 10000;
1148 int fix_marker_id_gripper_appr_dir = 10001;
1149 int fix_marker_id_grasp_search_area = 10002;
1150 int fix_marker_id_grasp_search_area2 = 10003;
1152 (*marker).header.frame_id =
"tf_help";
1154 (*marker).ns =
"haf_grasping_parameters";
1159 (*marker).id = fix_marker_id_grasp_search_area;
1160 (*marker).type = visualization_msgs::Marker::CUBE;
1161 (*marker).action = visualization_msgs::Marker::ADD;
1162 (*marker).color.a = 0.05;
1163 (*marker).color.r = 0.4;
1164 (*marker).color.g = 0.4;
1165 (*marker).color.b = 0.4;
1166 (*marker).pose.position.x = 0;
1167 (*marker).pose.position.y = 0;
1168 (*marker).pose.position.z = z;
1172 geometry_msgs::Quaternion quat_msg_compensate_rot;
1174 (*marker).pose.orientation = quat_msg_compensate_rot;
1175 (*marker).scale.x = 0.01*this->grasp_search_area_size_x_dir/ gripperwidth;
1176 (*marker).scale.y = 0.01*this->grasp_search_area_size_y_dir;
1177 (*marker).scale.z = 0.001;
1183 (*marker).id = fix_marker_id_grasp_search_area2;
1184 (*marker).type = visualization_msgs::Marker::CUBE;
1185 (*marker).action = visualization_msgs::Marker::ADD;
1186 (*marker).color.a = 0.4;
1187 (*marker).color.r = 0.2;
1188 (*marker).color.g = 0.2;
1189 (*marker).color.b = 0.2;
1190 (*marker).pose.position.x = 0;
1191 (*marker).pose.position.y = 0;
1192 (*marker).pose.position.z = z;
1196 geometry_msgs::Quaternion quat_msg_compensate_rot;
1198 (*marker).pose.orientation = quat_msg_compensate_rot;
1200 (*marker).scale.x = 0.01*(this->grasp_search_area_size_x_dir-14)/ gripperwidth;
1201 (*marker).scale.y = 0.01*(this->grasp_search_area_size_y_dir-14);
1202 (*marker).scale.z = 0.001;
1207 (*marker).id = fix_marker_id_gripper_dir;
1208 (*marker).type = visualization_msgs::Marker::CUBE;
1209 (*marker).action = visualization_msgs::Marker::ADD;
1210 (*marker).color.a = 0.8;
1211 (*marker).color.r = 1.0;
1212 (*marker).color.g = 0.0;
1213 (*marker).color.b = 0.0;
1215 (*marker).pose.position.x =
x;
1216 (*marker).pose.position.y = y;
1217 (*marker).pose.position.z = z;
1218 (*marker).scale.x = 0.5 * 1 / gripperwidth;
1219 (*marker).scale.y = 0.002;
1220 (*marker).scale.z = 0.002;
1223 visualization_msgs::Marker markerdummy;
1224 gp_to_marker(&markerdummy, this->graspsearchcenter.x,this->graspsearchcenter.y,this->graspsearchcenter.z, 1,
false, 1, nr_roll,
false,
false);
1226 (*marker).pose.position.x = 0;
1227 (*marker).pose.position.y = 0;
1228 (*marker).pose.position.z = z;
1229 (*marker).scale.x = 0.5 * 1 / gripperwidth;
1230 (*marker).scale.y = 0.002;
1231 (*marker).scale.z = 0.002;
1233 tf::Vector3 marker_gripper_open_dir_axis(0, 0, 1);
1235 geometry_msgs::Quaternion quat_msg_gripper_open_dir;
1237 (*marker).pose.orientation = quat_msg_gripper_open_dir;
1243 (*marker).header.frame_id = this->base_frame_id;
1244 (*marker).id = fix_marker_id_gripper_appr_dir;
1245 (*marker).type = visualization_msgs::Marker::ARROW;
1246 (*marker).action = visualization_msgs::Marker::ADD;
1247 (*marker).color.a = 0.8;
1248 (*marker).color.r = 0.0;
1249 (*marker).color.g = 0.0;
1250 (*marker).color.b = 0.0;
1251 float markerlength = 0.1;
1252 (*marker).pose.position.x = x + markerlength*this->approach_vector.x;
1253 (*marker).pose.position.y = y + markerlength*this->approach_vector.y;
1254 (*marker).pose.position.z = z + markerlength*this->approach_vector.z;
1255 (*marker).scale.x = markerlength;
1256 (*marker).scale.y = 0.003;
1257 (*marker).scale.z = 0.003;
1261 geometry_msgs::Quaternion quat_msg;
1263 (*marker).pose.orientation = quat_msg;
1267 default: cout <<
"CCalc_Grasppoints::grasp_area_to_marker: WRONG INPUT FOR param_id " << endl;
1275 cout <<
"\n ===> transform_gp_in_wcs_and_publish(): TRANSFORM FOUND GRASP" << endl;
1276 Eigen::Matrix4f mat_sh_to_orig = Eigen::Matrix4f::Identity();
1277 Eigen::Matrix4f mat_rot_z_axis = Eigen::Matrix4f::Identity();
1278 Eigen::Matrix4f mat_rot_x_axis = Eigen::Matrix4f::Identity();
1279 Eigen::Matrix4f mat_sh_from_orig = Eigen::Matrix4f::Identity();
1280 Eigen::Matrix4f mat_rot = Eigen::Matrix4f::Identity();
1281 Eigen::Matrix4f mat_scale_x_dir = Eigen::Matrix4f::Identity();
1283 Eigen::Matrix4f mat_transform = Eigen::Matrix4f::Identity();
1285 Eigen::Matrix3f mat_rot_for_appr_vec = Eigen::Matrix3f::Identity();
1288 float rot_about_x = 0;
1290 mat_scale_x_dir(0,0) = this->gripper_opening_width;
1292 mat_sh_to_orig(0,3) = -this->graspsearchcenter.x;
1293 mat_sh_to_orig(1,3) = -this->graspsearchcenter.y;
1294 mat_sh_to_orig(2,3) = -this->graspsearchcenter.z;
1296 mat_sh_from_orig(0,3) = 0;
1297 mat_sh_from_orig(1,3) = 0;
1298 mat_sh_from_orig(2,3) = 0 + this->trans_z_after_pc_transform;
1300 if (this->approach_vector.y == 0 and this->approach_vector.x == 0){
1302 if (this->approach_vector.z >= 0) {
1308 rot_about_z = 90*
PI/180.0 - atan2(this->approach_vector.y, this->approach_vector.x);
1309 rot_about_x = 90*
PI/180.0 - atan2( this->approach_vector.z, sqrt(this->approach_vector.y*this->approach_vector.y + this->approach_vector.x*this->approach_vector.x) );
1316 mat_rot(0,0) = cos(angle);
1317 mat_rot(0,1) = -sin(angle);
1318 mat_rot(1,0) = sin(angle);
1319 mat_rot(1,1) = cos(angle);
1322 mat_rot_z_axis(0,0) = cos(rot_about_z);
1323 mat_rot_z_axis(0,1) = -sin(rot_about_z);
1324 mat_rot_z_axis(1,0) = sin(rot_about_z);
1325 mat_rot_z_axis(1,1) = cos(rot_about_z);
1328 mat_rot_x_axis(1,1) = cos(rot_about_x);
1329 mat_rot_x_axis(1,2) = -sin(rot_about_x);
1330 mat_rot_x_axis(2,1) = sin(rot_about_x);
1331 mat_rot_x_axis(2,2) = cos(rot_about_x);
1334 mat_transform = mat_scale_x_dir * mat_rot * mat_sh_from_orig * mat_rot_x_axis * mat_rot_z_axis * mat_sh_to_orig;
1337 cout <<
" ---> id_row_top_all: " << id_row_top_all <<
"\t" <<
"id_col_top_all: " << id_col_top_all <<
"\t and rotation: " << nr_roll_top_all*
ROLL_STEPS_DEGREE <<
" tilt_top: " << nr_tilt_top_all <<endl;
1339 float x_gp_roll = - ((float)(
HEIGHT/2 - id_row_top_all))/100;
1340 float y_gp_roll = - ((float)(
WIDTH/2 - id_col_top_all))/100;
1342 float h_locmax_roll = -10;
1343 for (
int row_z = -4; row_z < 5; row_z++){
1344 for (
int col_z = -4; col_z < 4; col_z++){
1346 if (id_row_top_all+row_z >= 0 and id_col_top_all+col_z>=0 and h_locmax_roll < this->heightsgridroll[nr_roll_top_all][nr_tilt_top_all][id_row_top_all+row_z][id_col_top_all+col_z]){
1347 h_locmax_roll = this->heightsgridroll[nr_roll_top_all][nr_tilt_top_all][id_row_top_all+row_z][id_col_top_all+col_z];
1354 h_locmax_roll -= 0.01;
1355 float z_gp_roll = h_locmax_roll;
1356 cout <<
" ---> x_roll: "<< x_gp_roll <<
"\t y_roll: " << y_gp_roll <<
"\t z_gp_roll: " << z_gp_roll << endl;
1360 float x_gp_dis = 0.03;
1362 Eigen::Vector4f gp1(x_gp_roll-x_gp_dis, y_gp_roll,z_gp_roll,1.0);
1363 Eigen::Vector4f gp2(x_gp_roll+x_gp_dis, y_gp_roll,z_gp_roll,1.0);
1364 Eigen::Vector4f gp1_wcs, gp2_wcs;
1365 Eigen::Vector3f appr_vec(0,0,1);
1367 gp1_wcs = mat_transform.inverse()*gp1;
1368 gp2_wcs = mat_transform.inverse()*gp2;
1370 mat_rot_for_appr_vec << this->av_trans_mat(0,0),this->av_trans_mat(1,0),this->av_trans_mat(2,0),
1371 this->av_trans_mat(0,1),this->av_trans_mat(1,1),this->av_trans_mat(2,1),
1372 this->av_trans_mat(0,2),this->av_trans_mat(1,2),this->av_trans_mat(2,2);
1374 appr_vec = mat_rot_for_appr_vec*appr_vec;
1376 cout <<
" ---> GP_1: x_roll_wcs: "<< gp1_wcs[0] <<
"\t y_roll_wcs: " << gp1_wcs[1] <<
"\t z_roll_wcs: " << gp1_wcs[2] << endl;
1377 cout <<
" ---> GP_2: x_roll_wcs: "<< gp2_wcs[0] <<
"\t y_roll_wcs: " << gp2_wcs[1] <<
"\t z_roll_wcs: " << gp2_wcs[2] << endl;
1381 std_msgs::String msgStrPoints;
1382 std::stringstream ss;
1384 ss << scaled_gp_eval <<
" " << gp1_wcs[0] <<
" "<< gp1_wcs[1] <<
" "<< gp1_wcs[2] <<
" "<< gp2_wcs[0] <<
" " << gp2_wcs[1] <<
" " << gp2_wcs[2] <<
" "<< appr_vec(0) <<
" "<< appr_vec(1) <<
" "<< appr_vec(2) <<
" " << (gp1_wcs[0]+gp2_wcs[0])/2.0 <<
" " << (gp1_wcs[1]+gp2_wcs[1])/2.0 <<
" " << (gp1_wcs[2]+gp2_wcs[2])/2.0 <<
" " << nr_roll_top_all*
ROLL_STEPS_DEGREE;
1385 msgStrPoints.data = ss.str();
1387 this->gp_result.header.frame_id = this->base_frame_id;
1388 this->gp_result.eval = scaled_gp_eval;
1389 this->gp_result.graspPoint1.x = gp1_wcs[0];
1390 this->gp_result.graspPoint1.y = gp1_wcs[1];
1391 this->gp_result.graspPoint1.z = gp1_wcs[2];
1392 this->gp_result.graspPoint2.x = gp2_wcs[0];
1393 this->gp_result.graspPoint2.y = gp2_wcs[1];
1394 this->gp_result.graspPoint2.z = gp2_wcs[2];
1395 this->gp_result.averagedGraspPoint.x = (gp1_wcs[0]+gp2_wcs[0])/2.0;
1396 this->gp_result.averagedGraspPoint.y = (gp1_wcs[1]+gp2_wcs[1])/2.0;
1397 this->gp_result.averagedGraspPoint.z = (gp1_wcs[2]+gp2_wcs[2])/2.0;
1398 this->gp_result.approachVector.x = appr_vec(0);
1399 this->gp_result.approachVector.y = appr_vec(1);
1400 this->gp_result.approachVector.z = appr_vec(2);
1404 visualization_msgs::Marker marker_best_params;
1405 visualization_msgs::MarkerArray ma_best_params;
1407 for (
int i = 3; i <= 3; i++){
1408 grasp_area_to_marker(&marker_best_params, (gp1[0]+gp2[0])/2,(gp1[1]+gp2[1])/2,(gp1[2]+gp2[2])/2, this->gripper_opening_width , nr_roll_top_all, i ,
true );
1409 ma_best_params.markers.push_back(marker_best_params);
1411 for (
int i = 4; i <= 4; i++){
1412 grasp_area_to_marker(&marker_best_params, (gp1_wcs[0]+gp2_wcs[0])/2,(gp1_wcs[1]+gp2_wcs[1])/2,(gp1_wcs[2]+gp2_wcs[2])/2, this->gripper_opening_width , nr_roll_top_all, i ,
true );
1413 ma_best_params.markers.push_back(marker_best_params);
1415 vis_pub_ma_params.publish(ma_best_params);
1418 cout <<
" ---> Scaled GP Evaluation (-20-99) [-20 <=> no GP found]: " << scaled_gp_eval << endl;
1419 pubGraspPointsEval.publish(msgStrPoints);
1427 ROS_INFO(
"ROS NODE calc_grasppoints_svm_action_server (from package haf_grasping) started");
1428 ros::init(argc, argv,
"calc_grasppoints_svm_action_server");
void gp_to_marker(visualization_msgs::Marker *marker, float x, float y, float z, float green, bool pubmarker, int gripperwidth, int nr_roll, bool pub_grip_open_dir, bool pub_grid)
ros::Publisher vis_pub_ma_params
void pnt_in_box(int nr_roll, int nr_tilt)
int gripper_opening_width
void generate_grid(int roll, int tilt, pcl::PointCloud< pcl::PointXYZ > pcl_cloud_in)
void publish_transformed_pcl_cloud(int roll, int tilt, pcl::PointCloud< pcl::PointXYZ > pcl_cloud_in)
void read_features(string featurespath)
#define ROLL_STEPS_DEGREE
#define TILT_STEPS_DEGREE
ros::Publisher pubGraspPointsEval
int grasp_search_area_size_x_dir
void read_pc_cb(const haf_grasping::CalcGraspPointsServerGoalConstPtr &goal)
ROSCPP_DECL void init(int &argc, char **argv, const std::string &name, uint32_t options=0)
ROSCPP_DECL const std::string & getName()
void publish_grasp_grid(int nr_roll, int tilt, float graspsgrid[][WIDTH], int gripperwidth)
void fromROSMsg(const sensor_msgs::PointCloud2 &cloud, pcl::PointCloud< T > &pcl_cloud)
void setValue(const tfScalar &xx, const tfScalar &xy, const tfScalar &xz, const tfScalar &yx, const tfScalar &yy, const tfScalar &yz, const tfScalar &zx, const tfScalar &zy, const tfScalar &zz)
void calc_intimage(int roll, int tilt)
ros::Publisher pubGraspPoints
TFSIMD_FORCE_INLINE const tfScalar & y() const
geometry_msgs::Point graspsearchcenter
TFSIMD_FORCE_INLINE void setValue(const tfScalar &x, const tfScalar &y, const tfScalar &z)
ros::Publisher pubInputPCROS
void getRotation(Quaternion &q) const
TFSIMD_FORCE_INLINE tfScalar angle(const Quaternion &q1, const Quaternion &q2)
int nr_features_without_shaf
ROSCPP_DECL void spin(Spinner &spinner)
int main(int argc, char **argv)
haf_grasping::CalcGraspPointsServerFeedback feedback_
ROSLIB_DECL std::string command(const std::string &cmd)
bool param(const std::string ¶m_name, T ¶m_val, const T &default_val) const
static void quaternionTFToMsg(const Quaternion &bt, geometry_msgs::Quaternion &msg)
CCalc_Grasppoints(string name)
int graspval_max_diff_for_pub
Publisher advertise(const std::string &topic, uint32_t queue_size, bool latch=false)
ros::Publisher vis_pub_ma
ROSLIB_DECL std::string getPath(const std::string &package_name)
tf::TransformListener tf_listener
TFSIMD_FORCE_INLINE const tfScalar & z() const
void write_featurevector(string outputpath, int nr_features_without_shaf)
void grasp_area_to_marker(visualization_msgs::Marker *marker, float x, float y, float z, int gripperwidth, int nr_roll, int param_id, bool top_grasp)
ros::Subscriber box_position_sub
float intimagemat[HEIGHTFEATURES][WIDTHFEATURES]
void calc_featurevectors(int roll, int tilt)
ros::Publisher pubTransformedPCROS
#define ROS_INFO_STREAM(args)
float trans_z_after_pc_transform
void transformPointCloud(const pcl::PointCloud< PointT > &cloud_in, pcl::PointCloud< PointT > &cloud_out, const tf::Transform &transform)
void loop_control(pcl::PointCloud< pcl::PointXYZ > pcl_cloud_in)
Eigen::Matrix4f av_trans_mat
actionlib::SimpleActionServer< haf_grasping::CalcGraspPointsServerAction > as_
void predict_bestgp_withsvm(bool svm_with_probability=false)
string svmmodel_file_path
tf::Quaternion quat_tf_to_tf_help
void transform_gp_in_wcs_and_publish(int id_row_top_all, int id_col_top_all, int nr_roll_top_all, int nr_tilt_top_all, int scaled_gp_eval)
int grasp_search_area_size_y_dir
haf_grasping::CalcGraspPointsServerResult result_
float max_duration_for_grasp_calc
haf_grasping::GraspOutput gp_result
void show_predicted_gps(int nr_roll, int tilt, bool svm_with_probability=false)
void print_heights(int nr_roll, int nr_tilt)
geometry_msgs::Vector3 approach_vector