@@ -23,38 +23,27 @@ void getRPYFromQuaternionMSG(geometry_msgs::Quaternion orientation, double& roll
2323
2424
2525MoveitCustomApi::MoveitCustomApi () :
26- max_trials(5 ),
2726 user_prompts(true )
2827{
2928
3029}
3130
32- MoveitCustomApi::MoveitCustomApi (int max_trials, std::string user_prompts)
31+ MoveitCustomApi::MoveitCustomApi (std::string user_prompts)
3332{
34- this ->max_trials = max_trials;
3533 this ->user_prompts = (user_prompts==" True" || user_prompts==" true" )? true : false ;
36- ROS_INFO_STREAM (" User prompts : " << this ->user_prompts << " | Max planning trials : " << max_trials);
3734}
3835
3936MoveitCustomApi::~MoveitCustomApi () {}
4037
4138void MoveitCustomApi::printBasicInfo ()
4239{
43- // Getting Basic Information
44- // ^^^^^^^^^^^^^^^^^^^^^^^^^
45- //
46- // We can print the name of the reference frame for this robot.
47- ROS_INFO_NAMED (" tutorial" , " Planning frame: %s" , move_group->getPlanningFrame ().c_str ());
48-
49- // We can also print the name of the end-effector link for this group.
50- ROS_INFO_NAMED (" tutorial" , " End effector link: %s" , move_group->getEndEffectorLink ().c_str ());
51-
52- // We can get a list of all the groups in the robot:
53- ROS_INFO_NAMED (" tutorial" , " Available Planning Groups:" );
54- std::copy (move_group->getJointModelGroupNames ().begin (), move_group->getJointModelGroupNames ().end (),
55- std::ostream_iterator<std::string>(std::cout, " , " ));
56- std::cout << std::endl;
57-
40+ ROS_INFO (" ------------------------------------------------------" );
41+ ROS_INFO_STREAM (" Planning frame: " << move_group->getPlanningFrame ().c_str ());
42+ ROS_INFO_STREAM (" End effector link: " << move_group->getEndEffectorLink ().c_str ());
43+ ROS_INFO_STREAM (" User prompts : " << (this ->user_prompts ?" True" :" False" ));
44+ ROS_INFO_STREAM (" Max trials : " << this ->max_trials );
45+ ROS_INFO_STREAM (" Robot settle time : " << this ->robot_settle_time_ );
46+ ROS_INFO (" ------------------------------------------------------" );
5847}
5948
6049bool MoveitCustomApi::comparePoses (geometry_msgs::Pose pose1, geometry_msgs::Pose pose2, double delta_posistion, double delta_orientation)
@@ -94,7 +83,7 @@ void MoveitCustomApi::executeCartesianTrajForWaypoints(std::vector<geometry_msgs
9483 int iter=0 ;
9584 for (auto x: trajectory.joint_trajectory .points )
9685 {
97- ROS_INFO_STREAM (iter++ << " point_time_from_start: " << x.time_from_start );
86+ // ROS_INFO_STREAM(iter++ << " point_time_from_start: " << x.time_from_start);
9887 times_from_start.push_back (x.time_from_start );
9988 }
10089
@@ -173,7 +162,7 @@ void MoveitCustomApi::adjustTrajectoryToFixTimeSequencing(moveit_msgs::RobotTraj
173162 for (int i=0 ; i< times_from_start.size (); i++)
174163 {
175164 trajectory.joint_trajectory .points [i].time_from_start = times_from_start[i];
176- ROS_INFO_STREAM (" Recomputed time point " << i << " : " << trajectory.joint_trajectory .points [i].time_from_start );
165+ // ROS_INFO_STREAM("Recomputed time point " << i << " : " << trajectory.joint_trajectory.points[i].time_from_start );
177166 }
178167 }
179168
@@ -418,7 +407,7 @@ bool MoveitCustomApi::gripperOpen(ros::NodeHandle nh)
418407 if (client.call (io_msg))
419408 {
420409 ROS_INFO_STREAM (" Open gripper initialise : " << ((io_msg.response .success ==0 )?" Failed" :" Succeeded" ) );
421- sleepSafeFor (0.5 );
410+ sleepSafeFor (robot_settle_time_ );
422411 io_msg.request .state = 0 ;
423412 if (client.call (io_msg))
424413 {
@@ -449,7 +438,7 @@ bool MoveitCustomApi::gripperClose(ros::NodeHandle nh)
449438 if (client.call (io_msg))
450439 {
451440 ROS_INFO_STREAM (" Close gripper initialise : " << ((io_msg.response .success ==0 )?" Failed" :" Succeeded" ) );
452- sleepSafeFor (0.5 );
441+ sleepSafeFor (robot_settle_time_ );
453442 io_msg.request .state = 0 ;
454443 if (client.call (io_msg))
455444 {
@@ -472,8 +461,13 @@ bool MoveitCustomApi::gripperClose(ros::NodeHandle nh)
472461void MoveitCustomApi::initialiseMoveit (ros::NodeHandle nh)
473462{
474463 namespace rvt = rviz_visual_tools;
475- move_group = new moveit::planning_interface::MoveGroupInterface (GROUP_MANIP);
476- joint_model_group = move_group->getCurrentState ()->getJointModelGroup (GROUP_MANIP);
464+ nh.param <std::string>(" robot" ,robot_name_," robot" );
465+ nh.param <std::string>(" group_manip" ,group_manip_," manip" );
466+ nh.param <int >(" max_planning_attempts" ,max_trials,3 );
467+ nh.param <double >(" robot_settle_time" ,robot_settle_time_,0.5 );
468+
469+ move_group = new moveit::planning_interface::MoveGroupInterface (group_manip_);
470+ joint_model_group = move_group->getCurrentState ()->getJointModelGroup (group_manip_);
477471
478472 visual_tools = new moveit_visual_tools::MoveItVisualTools (move_group->getPlanningFrame ().c_str ());
479473 visual_tools->deleteAllMarkers ();
@@ -560,14 +554,14 @@ void MoveitCustomApi::pickAtPoseFromHeight(geometry_msgs::Pose target_pose, doub
560554 executeCartesianTrajtoPose (target_pose," Pre Pick Pose" );
561555 }
562556 ROS_INFO (" ---------------------------" );
563- sleepSafeFor (0.5 );
557+ sleepSafeFor (robot_settle_time_ );
564558
565559 // Go down to reach and grasp the object
566560 target_pose.position .z -=height;
567561 executeCartesianTrajtoPose (target_pose," Pick Pose" );
568562// moveGroupExecutePlan(getCartesianPathPlanToPose(target_pose, "Pick Pose"));
569563 if (do_gripper) gripperClose (nh);
570- sleepSafeFor (0.5 );
564+ sleepSafeFor (robot_settle_time_ );
571565// addOrRemoveTestPieceCollissionObjectWRTRobot(COMMAND_ADD);
572566 ROS_INFO (" ---------------------------" );
573567
@@ -591,14 +585,14 @@ void MoveitCustomApi::placeAtPoseFromHeight(geometry_msgs::Pose target_pose, dou
591585// moveGroupExecutePlan(getCartesianPathPlanToPose(target_pose, "Pre Place Pose"));
592586 executeCartesianTrajtoPose (target_pose," Pre Place Pose" );
593587 ROS_INFO (" ---------------------------" );
594- sleepSafeFor (0.5 );
588+ sleepSafeFor (robot_settle_time_ );
595589 // Go down and place the object
596590 target_pose.position .z -=height;
597591// moveGroupExecutePlan(getCartesianPathPlanToPose(target_pose, "Place Pose"));
598592 executeCartesianTrajtoPose (target_pose," Place Pose" );
599593 ROS_INFO (" ---------------------------" );
600594 if (do_gripper) gripperOpen (nh);
601- sleepSafeFor (0.5 );
595+ sleepSafeFor (robot_settle_time_ );
602596// addOrRemoveTestPieceCollissionObjectWRTRobot(COMMAND_REMOVE);
603597
604598 // Go back up
0 commit comments