door_detector_actions_alg_node.cpp
Go to the documentation of this file.
00001 #include "door_detector_actions_alg_node.h"
00002 
00003 
00004 DoorDetectorActionsAlgNode::DoorDetectorActionsAlgNode(void) :
00005   algorithm_base::IriBaseAlgorithm<DoorDetectorActionsAlgorithm>(),
00006   find_a_door_aserver_(public_node_handle_, "find_a_door")
00007 {
00008   //init class attributes if necessary
00009   //this->loop_rate_ = 2;//in [Hz]
00010 
00011   // [init publishers]
00012   this->arm_poses_marker_publisher_ = this->public_node_handle_.advertise<visualization_msgs::Marker>("arm_poses_marker", 1);
00013   this->door_action_start_publisher_ = this->public_node_handle_.advertise<std_msgs::Int8>("door_action_start", 1);
00014   
00015   // [init subscribers]
00016   this->door_handle_subscriber_ = this->public_node_handle_.subscribe("/iri_door_detector/door_cloud/door_handle", 1, &DoorDetectorActionsAlgNode::door_handle_callback, this);
00017   this->door_centroid_subscriber_ = this->public_node_handle_.subscribe("/iri_door_detector/door_cloud/door_centroid", 1, &DoorDetectorActionsAlgNode::door_centroid_callback, this);
00018   
00019   // [init services]
00020   
00021   // [init clients]
00022   
00023   // [init action servers]
00024   find_a_door_aserver_.registerStartCallback(boost::bind(&DoorDetectorActionsAlgNode::find_a_doorStartCallback, this, _1)); 
00025   find_a_door_aserver_.registerStopCallback(boost::bind(&DoorDetectorActionsAlgNode::find_a_doorStopCallback, this)); 
00026   find_a_door_aserver_.registerIsFinishedCallback(boost::bind(&DoorDetectorActionsAlgNode::find_a_doorIsFinishedCallback, this)); 
00027   find_a_door_aserver_.registerHasSucceedCallback(boost::bind(&DoorDetectorActionsAlgNode::find_a_doorHasSucceedCallback, this)); 
00028   find_a_door_aserver_.registerGetResultCallback(boost::bind(&DoorDetectorActionsAlgNode::find_a_doorGetResultCallback, this, _1)); 
00029   find_a_door_aserver_.registerGetFeedbackCallback(boost::bind(&DoorDetectorActionsAlgNode::find_a_doorGetFeedbackCallback, this, _1)); 
00030   find_a_door_aserver_.start();
00031   
00032   // [init action clients]
00033 
00034   // [init variables]
00035   // --- tf_original_frame = "/kinect_depth_optical_frame";
00036   tf_target_frame = "/base_link";
00037   tf_target_frame_2 = "/right_hand_base_link";
00038   current_planner = "ompl_planning/plan_kinematic_path";
00039   closed_door=0;
00040   open_door=0;
00041   start=0;
00042   side_open=0.0;
00043   side_closed=0.0;
00044   voting_rule_approval=3;
00045 }
00046 
00047 DoorDetectorActionsAlgNode::~DoorDetectorActionsAlgNode(void)
00048 {
00049   // [free dynamic memory]
00050 }
00051 
00052 void DoorDetectorActionsAlgNode::mainNodeThread(void)
00053 {
00054   // [fill msg structures]
00055   //this->Marker_msg_.data = my_var;
00056   //this->Int8_msg_.data = my_var;
00057   
00058   // [fill srv structure and make request to the server]
00059   
00060   // [fill action structure and make request to the action server]
00061 
00062   // [publish messages]
00063 }
00064 
00065 /*  [subscriber callbacks] */
00066 void DoorDetectorActionsAlgNode::door_handle_callback(const geometry_msgs::PoseStamped::ConstPtr& handle_location) 
00067 { 
00068   ROS_INFO("DoorDetectorActionsAlgNode::door_handle_callback: New Message Received"); 
00069 
00070   //use appropiate mutex to shared variables if necessary 
00071   //this->alg_.lock(); 
00072   this->door_handle_mutex_.enter(); 
00073 
00074   bool tf_exists = false;
00075   bool tf_2_exists = false;
00076 
00077   if((start==1 || no_simulator) && closed_door<voting_rule_approval)
00078   {
00079           closed_door++; 
00080                 ROS_ERROR("closed door counter: %d", closed_door);
00081 
00082           if(closed_door==voting_rule_approval)
00083           {
00084                   side_closed=handle_location->pose.orientation.w;
00085                   if (side_closed < 0)
00086                         ROS_ERROR("Result: handle located on the left side, the door is closed!");
00087                   if (side_closed > 0)
00088                         ROS_ERROR("Result: handle located on the right side, the door is closed!");
00089                 
00090                   //Re-start counter, or send commands to robot 
00091                   if(no_simulator)
00092                                 closed_door=0;
00093  
00094                   if(!no_simulator)
00095                   {
00096                           tf_exists = tf_listener.waitForTransform(tf_target_frame, 
00097                                 handle_location->header.frame_id, handle_location->header.stamp, ros::Duration(100));
00098                           tf_2_exists = tf_listener.waitForTransform(tf_target_frame_2, 
00099                                 handle_location->header.frame_id, handle_location->header.stamp, ros::Duration(100));
00100 
00101                           if(tf_exists)
00102                           {
00103                                 base_door_handle=transformGoalBase(*handle_location, tf_target_frame);
00104 
00105                                   if(tf_2_exists)
00106                                   {
00107                                         if(side_closed > 0)
00108                                         {
00109                                                 arm_door_handle=transformGoalArm(*handle_location, tf_target_frame_2);
00110                                                 marker.header.frame_id=tf_target_frame_2;
00111                                         }
00112                                         if(side_closed < 0)
00113                                         {
00114                                                 arm_door_handle=transformGoalArm(*handle_location, tf_target_frame);
00115                                                 marker.header.frame_id=tf_target_frame;
00116                                         }
00117 
00118                                         marker.pose.position = arm_door_handle.goal_constraints.position_constraints[0].position;
00119                                         marker.pose.orientation = arm_door_handle.goal_constraints.orientation_constraints[0].orientation;
00120                                         marker = ArrowMarker(handle_location->header, marker.pose, 1, 1, "arm_poses_marker");
00121                                         arm_poses_marker_publisher_.publish(marker);
00122                                   }
00123                           }
00124                   }
00125           }
00126   }
00127 
00128   //unlock previously blocked shared variables 
00129   //this->alg_.unlock(); 
00130   this->door_handle_mutex_.exit(); 
00131 }
00132 void DoorDetectorActionsAlgNode::door_centroid_callback(const geometry_msgs::PoseStamped::ConstPtr& door_centroid) 
00133 { 
00134   ROS_INFO("DoorDetectorActionsAlgNode::door_centroid_callback: New Message Received"); 
00135 
00136   //use appropiate mutex to shared variables if necessary 
00137   //this->alg_.lock(); 
00138   this->door_centroid_mutex_.enter(); 
00139 
00140   bool tf_exists = false;
00141   bool tf_2_exists = false;
00142 
00143   if((start==1 || no_simulator) && open_door<voting_rule_approval)
00144   {
00145           open_door++; 
00146           ROS_ERROR("open door counter: %d", open_door);
00147 
00148           if(open_door==voting_rule_approval)
00149           {
00150                   side_open=door_centroid->pose.orientation.w;
00151                   //Print result
00152                   if (side_open == 0)
00153                         ROS_ERROR("Result: the door is fully open!");
00154                   if (side_open < 0)
00155                         ROS_ERROR("Result: door ajar on the left side!");
00156                   if (side_open > 0)
00157                         ROS_ERROR("Result: door ajar on the right side!");
00158 
00159                   //Re-start counter, or send commands to robot
00160                   if(no_simulator)
00161                                 open_door=0;
00162 
00163                   if(!no_simulator)
00164                   {
00165                           tf_exists = tf_listener.waitForTransform(tf_target_frame, 
00166                                 door_centroid->header.frame_id, door_centroid->header.stamp, ros::Duration(100));
00167                           tf_2_exists = tf_listener.waitForTransform(tf_target_frame_2, 
00168                                 door_centroid->header.frame_id, door_centroid->header.stamp, ros::Duration(100));
00169 
00170                           if(tf_exists)
00171                           {
00172                                 base_door_centroid=transformGoalBase(*door_centroid, tf_target_frame);
00173                           
00174                                   if(tf_2_exists)
00175                                   {
00176                                         if (side_open > 0)
00177                                         {
00178                                                 arm_door_centroid=liftArm(*door_centroid, tf_target_frame_2);
00179                                                 marker.header.frame_id=tf_target_frame_2;
00180                                         }
00181                                         if (side_open < 0)
00182                                         {
00183                                                 arm_door_centroid=liftArm(*door_centroid, tf_target_frame);
00184                                                 marker.header.frame_id=tf_target_frame; 
00185                                         }
00186                                         if (side_open != 0)
00187                                         {
00188                                                 marker.pose.position = arm_door_centroid.goal_constraints.position_constraints[0].position;
00189                                                 marker.pose.orientation = arm_door_centroid.goal_constraints.orientation_constraints[0].orientation;
00190                                                 marker = ArrowMarker(door_centroid->header, marker.pose, 1, 1, "arm_poses_marker");
00191 
00192                                                 arm_poses_marker_publisher_.publish(marker);
00193                                         }
00194                                   }
00195                           }
00196                   }
00197           }
00198   }
00199 
00200   //unlock previously blocked shared variables 
00201   //this->alg_.unlock(); 
00202   this->door_centroid_mutex_.exit(); 
00203 }
00204 
00205 /*  [service callbacks] */
00206 
00207 /*  [action callbacks] */
00208 void DoorDetectorActionsAlgNode::find_a_doorStartCallback(const iri_door_detector::FindADoorGoalConstPtr& goal)
00209 { 
00210   alg_.lock(); 
00211     start=goal->start;
00212     if (start==1)
00213     {
00214         action_start.data=1;
00215         ROS_ERROR("Goal acknowledged, currently looking for a door!");
00216         closed_door=0;
00217         open_door=0;
00218         this->door_action_start_publisher_.publish(action_start);
00219     }
00220   alg_.unlock(); 
00221 } 
00222 
00223 void DoorDetectorActionsAlgNode::find_a_doorStopCallback(void) 
00224 { 
00225   alg_.lock(); 
00226     if(open_door==voting_rule_approval || closed_door==voting_rule_approval)
00227     {
00228         start = 0;
00229         action_start.data=0;
00230     } 
00231   alg_.unlock(); 
00232 } 
00233 
00234 bool DoorDetectorActionsAlgNode::find_a_doorIsFinishedCallback(void) 
00235 { 
00236   bool ret = false; 
00237 
00238   alg_.lock(); 
00239     if(open_door==voting_rule_approval || closed_door==voting_rule_approval)
00240     {
00241         ret = true;
00242         start = 0;
00243         action_start.data=0;
00244     }
00245   alg_.unlock(); 
00246 
00247   return ret; 
00248 } 
00249 
00250 bool DoorDetectorActionsAlgNode::find_a_doorHasSucceedCallback(void) 
00251 { 
00252   bool ret = false; 
00253 
00254   alg_.lock(); 
00255     if(open_door==voting_rule_approval || closed_door==voting_rule_approval)
00256     {
00257         ret = true;
00258         start = 0;
00259         action_start.data=0;
00260         this->door_action_start_publisher_.publish(action_start);
00261     }
00262   alg_.unlock(); 
00263 
00264   return ret; 
00265 } 
00266 
00267 void DoorDetectorActionsAlgNode::find_a_doorGetResultCallback(iri_door_detector::FindADoorResultPtr& result) 
00268 { 
00269   alg_.lock(); 
00270     //update result data to be sent to client 
00271     if(open_door==voting_rule_approval)
00272     {
00273         result->base_poses = base_door_centroid;
00274         result->arm_poses = arm_door_centroid;
00275         result->planner_service_name = current_planner;
00276         if(side_open>0)
00277                 result->state = "open_right"; 
00278         if(side_open<0)
00279                 result->state = "open_left";
00280         if(side_open==0)
00281                 result->state = "fully_open";
00282         start=0;
00283         action_start.data=0;
00284     }
00285     if(closed_door==voting_rule_approval)
00286     {
00287         result->base_poses = base_door_handle;
00288         result->arm_poses = arm_door_handle;
00289         result->planner_service_name = current_planner; 
00290         if(side_closed>0)
00291                 result->state = "closed_right";
00292         if(side_closed<0)
00293                 result->state = "closed_left";
00294         start=0;
00295         action_start.data=0;
00296     } 
00297   alg_.unlock(); 
00298 } 
00299 
00300 void DoorDetectorActionsAlgNode::find_a_doorGetFeedbackCallback(iri_door_detector::FindADoorFeedbackPtr& feedback) 
00301 { 
00302   alg_.lock(); 
00303     //keep track of feedback 
00304     //ROS_INFO("feedback: %s", feedback->data.c_str()); 
00305   alg_.unlock(); 
00306 }
00307 
00308 /*  [action requests] */
00309 
00310 void DoorDetectorActionsAlgNode::node_config_update(Config &config, uint32_t level)
00311 {
00312   this->alg_.lock();
00313         
00314         this->base_distance_before_closed_door = config.base_distance_before_closed_door;
00315         this->base_distance_after_open_door = config.base_distance_after_open_door;
00316         this->arm_distance_before_closed_door = config.arm_distance_before_closed_door;
00317         this->z_arm_offset = config.z_arm_offset;
00318         this->y_offset = config.y_offset;
00319         this->no_simulator = config.no_simulator;
00320 
00321   this->alg_.unlock();
00322 }
00323 
00324 void DoorDetectorActionsAlgNode::addNodeDiagnostics(void)
00325 {
00326 }
00327 
00328 /* main function */
00329 int main(int argc,char *argv[])
00330 {
00331   return algorithm_base::main<DoorDetectorActionsAlgNode>(argc, argv, "door_detector_alg_node");
00332 }
00333 
00334 /* algorithm functions */
00335 geometry_msgs::PoseStamped DoorDetectorActionsAlgNode::transformGoalBase (geometry_msgs::PoseStamped pose, std::string target_frame)
00336 {       
00337 
00338         geometry_msgs::PoseStamped target_pose;
00339         geometry_msgs::PoseStamped p1;
00340         geometry_msgs::PoseStamped p2;
00341         geometry_msgs::Quaternion orient;
00342         float side = pose.pose.orientation.w;
00343         
00344         pose.pose.orientation.w=0;      
00345 
00346         if(side==1.0 || side==-1.0)
00347         {
00348                 //send base 0.5m before the door to avoid collision
00349                 pose.pose.position.x -= (base_distance_before_closed_door * pose.pose.orientation.x);
00350                 pose.pose.position.y -= (base_distance_before_closed_door * pose.pose.orientation.y);
00351                 pose.pose.position.z -= (base_distance_before_closed_door * pose.pose.orientation.z);
00352         }
00353 
00354         if(side==0.0 || side==-2.0 || side==2.0)
00355         {
00356                 //if the door is fully open, send base 0.5m beyond the door
00357                 pose.pose.position.x += (base_distance_after_open_door * pose.pose.orientation.x);
00358                 pose.pose.position.y += (base_distance_after_open_door * pose.pose.orientation.y);
00359                 pose.pose.position.z += (base_distance_after_open_door * pose.pose.orientation.z);
00360         }
00361 
00362         tf_listener.transformPose(target_frame, pose, target_pose);
00363 
00364         //transform orientation vector origin
00365         tf_listener.transformPose(target_frame, pose, p1); 
00366         
00367         //compute orientation vector end
00368         pose.pose.position.x=pose.pose.position.x+pose.pose.orientation.x;
00369         pose.pose.position.y=pose.pose.position.y+pose.pose.orientation.y;
00370         pose.pose.position.z=pose.pose.position.z+pose.pose.orientation.z;
00371 
00372         //transform orientation vector end
00373         tf_listener.transformPose(target_frame, pose, p2);
00374 
00375         tf::Vector3 initial_position = tf::Vector3(1.0,0.0,0.0);//align to x axis
00376         tf::Vector3 plane_norm = tf::Vector3(p2.pose.position.x-p1.pose.position.x, 
00377                                              p2.pose.position.y-p1.pose.position.y, 
00378                                              0);
00379         initial_position = initial_position.normalize();
00380         plane_norm = plane_norm.normalize();
00381         float rot_ang = acos(initial_position.dot(plane_norm));
00382         tf::Vector3 rot_axis = initial_position.cross(plane_norm);
00383         //orient = tf::createQuaternionMsgFromYaw(rot_ang);
00384         tf::Quaternion q = tf::Quaternion(rot_axis,rot_ang);
00385         tf::quaternionTFToMsg (q, orient);
00386 
00387         target_pose.pose.position.z=0;
00388         if(side_closed == 1.0)
00389                 target_pose.pose.position.y=target_pose.pose.position.y+y_offset+0.2;
00390         if(side_closed == -1.0)
00391                 target_pose.pose.position.y=target_pose.pose.position.y+y_offset-0.2;
00392         target_pose.pose.orientation=orient;
00393         
00394         return target_pose;
00395 }
00396 
00397 arm_navigation_msgs::MotionPlanRequest DoorDetectorActionsAlgNode::transformGoalArm (geometry_msgs::PoseStamped pose, std::string target_frame)
00398 {       
00399 
00400         geometry_msgs::PoseStamped target_pose;
00401         geometry_msgs::PoseStamped p1;
00402         geometry_msgs::PoseStamped p2;
00403         geometry_msgs::Quaternion orient;
00404         std::string group_name;
00405         std::string link_name;
00406         tf::Vector3 plane_norm;
00407         tf::Vector3 initial_position;
00408         float side = pose.pose.orientation.w;
00409 
00410         //send arm 0.1m before the door to avoid collision
00411         pose.pose.position.x -= (arm_distance_before_closed_door * pose.pose.orientation.x);
00412         pose.pose.position.y -= (arm_distance_before_closed_door * pose.pose.orientation.y);
00413         pose.pose.position.z -= (arm_distance_before_closed_door * pose.pose.orientation.z);
00414 
00415         
00416         
00417         pose.pose.orientation.w=0;      
00418 
00419         tf_listener.transformPose(target_frame, pose, target_pose);
00420 
00421         //transform orientation vector origin
00422         tf_listener.transformPose(target_frame, pose, p1); 
00423 
00424         //compute orientation vector end
00425         pose.pose.position.x=pose.pose.position.x+pose.pose.orientation.x;
00426         pose.pose.position.y=pose.pose.position.y+pose.pose.orientation.y;
00427         pose.pose.position.z=pose.pose.position.z+pose.pose.orientation.z;
00428 
00429         //transform orientation vector end
00430         tf_listener.transformPose(target_frame, pose, p2);
00431 
00432         if (side > 0)
00433         {
00434                 initial_position = tf::Vector3(0.2,0.0,1.0);
00435                 initial_position = initial_position.normalize();
00436                 //target_pose.pose.position.x=target_pose.pose.position.x-0.37;
00437                 //target_pose.pose.position.y=target_pose.pose.position.y+0.1;
00438                 //target_pose.pose.position.z=target_pose.pose.position.z+0.15;
00439                 group_name = "right_arm_torso";
00440                 link_name = "arm_right_7_link";
00441                 plane_norm = tf::Vector3(p2.pose.position.x-p1.pose.position.x, 
00442                                          p2.pose.position.y-p1.pose.position.y, 
00443                                          p2.pose.position.z-p1.pose.position.z);
00444                 plane_norm = plane_norm.normalize();
00445         }
00446 
00447         if (side < 0)
00448         {
00449                 initial_position = tf::Vector3(-0.2,0.0,1.0);
00450                 initial_position = initial_position.normalize();
00451                 //target_pose.pose.position.x=target_pose.pose.position.x+0.37;
00452                 //target_pose.pose.position.y=target_pose.pose.position.y-0.1;
00453                 //target_pose.pose.position.z=target_pose.pose.position.z+0.15;
00454                 group_name = "left_arm";
00455                 link_name = "arm_left_7_link";
00456                 plane_norm = tf::Vector3(-p2.pose.position.x+p1.pose.position.x, 
00457                                          -p2.pose.position.y+p1.pose.position.y, 
00458                                          -p2.pose.position.z+p1.pose.position.z);
00459                 plane_norm = plane_norm.normalize();
00460         }
00461 
00462         float rot_ang = acos(initial_position.dot(plane_norm));
00463         tf::Vector3 rot_axis = initial_position.cross(plane_norm);      
00464         tf::Quaternion q = tf::Quaternion(rot_axis,rot_ang);
00465         tf::quaternionTFToMsg (q, orient);
00466 
00467 
00468         target_pose.pose.orientation=orient;
00469         target_pose.pose.position.z=target_pose.pose.position.z+z_arm_offset;
00470         target_pose.pose.position.y=target_pose.pose.position.y+y_offset;
00471 
00472         arm_navigation_msgs::MotionPlanRequest motion_plan_request;
00473 
00474         motion_plan_request.group_name = group_name;
00475         motion_plan_request.num_planning_attempts = 10;
00476         motion_plan_request.planner_id = std::string("");
00477         motion_plan_request.allowed_planning_time = ros::Duration(10.0);
00478         //goalA.motion_plan_request.expected_path_dt = ros::Duration(3.0);
00479 
00480         motion_plan_request.goal_constraints.position_constraints.resize(1);
00481         motion_plan_request.goal_constraints.position_constraints[0].header.frame_id = target_frame;
00482         motion_plan_request.goal_constraints.position_constraints[0].link_name = link_name;
00483         motion_plan_request.goal_constraints.position_constraints[0].position=target_pose.pose.position;
00484 
00485         motion_plan_request.goal_constraints.position_constraints[0].constraint_region_shape.type = arm_navigation_msgs::Shape::BOX;
00486         motion_plan_request.goal_constraints.position_constraints[0].constraint_region_shape.dimensions.push_back(0.1);
00487         motion_plan_request.goal_constraints.position_constraints[0].constraint_region_shape.dimensions.push_back(0.1);
00488         motion_plan_request.goal_constraints.position_constraints[0].constraint_region_shape.dimensions.push_back(0.1);
00489         motion_plan_request.goal_constraints.position_constraints[0].constraint_region_orientation.x = 0.0;
00490         motion_plan_request.goal_constraints.position_constraints[0].constraint_region_orientation.y = 0.0;
00491         motion_plan_request.goal_constraints.position_constraints[0].constraint_region_orientation.z = 0.0;
00492         motion_plan_request.goal_constraints.position_constraints[0].constraint_region_orientation.w = 1.0;
00493         motion_plan_request.goal_constraints.position_constraints[0].weight = 1.0; 
00494 
00495         motion_plan_request.goal_constraints.orientation_constraints.resize(1);
00496         motion_plan_request.goal_constraints.orientation_constraints[0].header.frame_id = target_frame;
00497         motion_plan_request.goal_constraints.orientation_constraints[0].link_name = link_name;
00498         motion_plan_request.goal_constraints.orientation_constraints[0].orientation=target_pose.pose.orientation;
00499 
00500         motion_plan_request.goal_constraints.orientation_constraints[0].absolute_roll_tolerance = 2.0;
00501         motion_plan_request.goal_constraints.orientation_constraints[0].absolute_pitch_tolerance = 2.0;
00502         motion_plan_request.goal_constraints.orientation_constraints[0].absolute_yaw_tolerance = 2.0;
00503 
00504         motion_plan_request.goal_constraints.position_constraints[0].position.z=target_pose.pose.position.z + 0.05;
00505 
00506         return motion_plan_request;
00507 }
00508 
00509 arm_navigation_msgs::MotionPlanRequest DoorDetectorActionsAlgNode::liftArm (geometry_msgs::PoseStamped pose, std::string target_frame)
00510 {       
00511 
00512         geometry_msgs::PoseStamped target_pose;
00513         geometry_msgs::PoseStamped p1;
00514         geometry_msgs::PoseStamped p2;
00515         geometry_msgs::Quaternion orient;
00516         std::string group_name;
00517         std::string link_name;
00518         tf::Vector3 plane_norm;
00519         tf::Vector3 initial_position;
00520         float side = pose.pose.orientation.w;
00521 
00522         arm_navigation_msgs::MotionPlanRequest motion_plan_request;
00523         motion_plan_request.goal_constraints.position_constraints.resize(1);
00524         motion_plan_request.goal_constraints.orientation_constraints.resize(1);
00525         
00526         if (side > 0)
00527         {
00528                 group_name = "right_arm_torso";
00529                 link_name = "arm_right_7_link"; 
00530                 motion_plan_request.goal_constraints.position_constraints[0].position.x=-0.3;
00531                 motion_plan_request.goal_constraints.position_constraints[0].position.y=0.191835;
00532                 motion_plan_request.goal_constraints.position_constraints[0].position.z=1.094355;
00533 
00534                 motion_plan_request.goal_constraints.orientation_constraints[0].orientation.x=-0.436727;
00535                 motion_plan_request.goal_constraints.orientation_constraints[0].orientation.y=-0.526269;
00536                 motion_plan_request.goal_constraints.orientation_constraints[0].orientation.z=0.377467;
00537                 motion_plan_request.goal_constraints.orientation_constraints[0].orientation.w=0.624364;
00538         }
00539 
00540         if (side < 0)
00541         {
00542                 group_name = "left_arm";
00543                 link_name = "arm_left_7_link";
00544                 motion_plan_request.goal_constraints.position_constraints[0].position.x=0.318141;
00545                 motion_plan_request.goal_constraints.position_constraints[0].position.y=0.313599;
00546                 motion_plan_request.goal_constraints.position_constraints[0].position.z=1.205298;
00547 
00548                 motion_plan_request.goal_constraints.orientation_constraints[0].orientation.x=-0.264641;
00549                 motion_plan_request.goal_constraints.orientation_constraints[0].orientation.y=-0.714832;
00550                 motion_plan_request.goal_constraints.orientation_constraints[0].orientation.z=0.057748;
00551                 motion_plan_request.goal_constraints.orientation_constraints[0].orientation.w=0.644705;
00552         }
00553 
00554         motion_plan_request.group_name = group_name;
00555         motion_plan_request.num_planning_attempts = 10;
00556         motion_plan_request.planner_id = std::string("");
00557         motion_plan_request.allowed_planning_time = ros::Duration(10.0);
00558         //goalA.motion_plan_request.expected_path_dt = ros::Duration(3.0);
00559 
00560         motion_plan_request.goal_constraints.position_constraints[0].header.frame_id = target_frame;
00561         motion_plan_request.goal_constraints.position_constraints[0].link_name = link_name;
00562 
00563         motion_plan_request.goal_constraints.position_constraints[0].constraint_region_shape.type = arm_navigation_msgs::Shape::BOX;
00564         motion_plan_request.goal_constraints.position_constraints[0].constraint_region_shape.dimensions.push_back(0.1);
00565         motion_plan_request.goal_constraints.position_constraints[0].constraint_region_shape.dimensions.push_back(0.1);
00566         motion_plan_request.goal_constraints.position_constraints[0].constraint_region_shape.dimensions.push_back(0.1);
00567         motion_plan_request.goal_constraints.position_constraints[0].constraint_region_orientation.x = 0.0;
00568         motion_plan_request.goal_constraints.position_constraints[0].constraint_region_orientation.y = 0.0;
00569         motion_plan_request.goal_constraints.position_constraints[0].constraint_region_orientation.z = 0.0;
00570         motion_plan_request.goal_constraints.position_constraints[0].constraint_region_orientation.w = 1.0;
00571         motion_plan_request.goal_constraints.position_constraints[0].weight = 1.0; 
00572 
00573         motion_plan_request.goal_constraints.orientation_constraints[0].header.frame_id = target_frame;
00574         motion_plan_request.goal_constraints.orientation_constraints[0].link_name = link_name;
00575 
00576         motion_plan_request.goal_constraints.orientation_constraints[0].absolute_roll_tolerance = 2.0;
00577         motion_plan_request.goal_constraints.orientation_constraints[0].absolute_pitch_tolerance = 2.0;
00578         motion_plan_request.goal_constraints.orientation_constraints[0].absolute_yaw_tolerance = 2.0;
00579 
00580         return motion_plan_request;
00581 }
00582 
00583 visualization_msgs::Marker DoorDetectorActionsAlgNode::ArrowMarker(std_msgs::Header header, geometry_msgs::Pose pose, int alpha, int color,  const char arrow_tag[])
00584 {       
00585 
00586         marker.header.stamp = header.stamp;
00587         marker.ns = arrow_tag;
00588         marker.id = 0;
00589         marker.type = visualization_msgs::Marker::ARROW;
00590         marker.action = visualization_msgs::Marker::ADD;
00591         marker.pose = pose;
00592 
00593         // scale
00594         marker.scale.x = 0.7;
00595         marker.scale.y = 0.7;
00596         marker.scale.z = 0.7;
00597 
00598         // color
00599         marker.color.a = alpha;
00600         marker.color.r = 0.0;
00601         marker.color.g = 0.0;
00602         marker.color.b = 0.0;
00603 
00604         if(color==1)
00605                 marker.color.r = 1.0;
00606         if(color==2)
00607                 marker.color.g = 1.0;
00608         if(color==3)
00609                 marker.color.b = 1.0;
00610 
00611         return marker;
00612 }


iri_door_detector
Author(s): Jose Rodriguez
autogenerated on Fri Dec 6 2013 23:57:16