utils.h
Go to the documentation of this file.
1 /*********************************************************************
2  * Software License Agreement (BSD License)
3  *
4  * Copyright (c) 2008, Willow Garage, Inc.
5  * All rights reserved.
6  *
7  * Redistribution and use in source and binary forms, with or without
8  * modification, are permitted provided that the following conditions
9  * are met:
10  *
11  * * Redistributions of source code must retain the above copyright
12  * notice, this list of conditions and the following disclaimer.
13  * * Redistributions in binary form must reproduce the above
14  * copyright notice, this list of conditions and the following
15  * disclaimer in the documentation and/or other materials provided
16  * with the distribution.
17  * * Neither the name of the Willow Garage nor the names of its
18  * contributors may be used to endorse or promote products derived
19  * from this software without specific prior written permission.
20  *
21  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
22  * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
23  * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
24  * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
25  * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
26  * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
27  * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
28  * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
29  * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
30  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
31  * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
32  * POSSIBILITY OF SUCH DAMAGE.
33  *********************************************************************/
34 #include <ros/ros.h>
35 #include <algorithm>
36 #include <arm_navigation_msgs/CollisionOperation.h>
37 #include <arm_navigation_msgs/SimplePoseConstraint.h>
39 #include <arm_navigation_msgs/MoveArmGoal.h>
40 
41 namespace arm_navigation_msgs
42 {
43 
48 void addGoalConstraintToMoveArmGoal(const arm_navigation_msgs::SimplePoseConstraint &pose_constraint, arm_navigation_msgs::MoveArmGoal &move_arm_goal)
49 {
50  arm_navigation_msgs::PositionConstraint position_constraint;
51  arm_navigation_msgs::OrientationConstraint orientation_constraint;
52  poseConstraintToPositionOrientationConstraints(pose_constraint,position_constraint,orientation_constraint);
53  move_arm_goal.motion_plan_request.goal_constraints.position_constraints.push_back(position_constraint);
54  move_arm_goal.motion_plan_request.goal_constraints.orientation_constraints.push_back(orientation_constraint);
55 }
56 
64 inline void generateDisableAllowedCollisionsWithExclusions(const std::vector<std::string>& all_names,
65  const std::vector<std::string>& exclude_names,
66  std::vector<arm_navigation_msgs::CollisionOperation>& collision_operations)
67 {
68  for(std::vector<std::string>::const_iterator it = all_names.begin();
69  it != all_names.end();
70  it++) {
71  if(std::find(exclude_names.begin(), exclude_names.end(), *it) == exclude_names.end()) {
72  arm_navigation_msgs::CollisionOperation coll;
73  coll.object1 = *it;
74  coll.object2 = coll.COLLISION_SET_OBJECTS;
75  coll.operation = coll.DISABLE;
76  collision_operations.insert(collision_operations.end(),coll);
77  coll.object2 = coll.COLLISION_SET_ATTACHED_OBJECTS;
78  collision_operations.insert(collision_operations.end(),coll);
79  for(std::vector<std::string>::const_iterator it2 = all_names.begin();
80  it2 != all_names.end();
81  it2++) {
82  if(*it != *it2 && std::find(exclude_names.begin(), exclude_names.end(), *it2) == exclude_names.end()) {
83  coll.object1 = *it;
84  coll.object2 = *it2;
85  collision_operations.insert(collision_operations.end(),coll);
86  }
87  }
88  }
89  }
90 }
91 }
void generateDisableAllowedCollisionsWithExclusions(const std::vector< std::string > &all_names, const std::vector< std::string > &exclude_names, std::vector< arm_navigation_msgs::CollisionOperation > &collision_operations)
Generate ordered collision operates that disable all collisions in a vector of names except for a spe...
Definition: utils.h:64
void poseConstraintToPositionOrientationConstraints(const arm_navigation_msgs::SimplePoseConstraint &pose_constraint, arm_navigation_msgs::PositionConstraint &position_constraint, arm_navigation_msgs::OrientationConstraint &orientation_constraint)
Convert a simple pose constraint into a position and orientation constraint.
void addGoalConstraintToMoveArmGoal(const arm_navigation_msgs::SimplePoseConstraint &pose_constraint, arm_navigation_msgs::MoveArmGoal &move_arm_goal)
Add a goal constraint to the move arm action goal.
Definition: utils.h:48


arm_navigation_msgs
Author(s): Gil Jones
autogenerated on Mon Jun 10 2019 14:26:17