SMACC2
Loading...
Searching...
No Matches
cp_grasping_objects.cpp
Go to the documentation of this file.
1// Copyright 2021 RobosoftAI Inc.
2//
3// Licensed under the Apache License, Version 2.0 (the "License");
4// you may not use this file except in compliance with the License.
5// You may obtain a copy of the License at
6//
7// http://www.apache.org/licenses/LICENSE-2.0
8//
9// Unless required by applicable law or agreed to in writing, software
10// distributed under the License is distributed on an "AS IS" BASIS,
11// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12// See the License for the specific language governing permissions and
13// limitations under the License.
14
15/*****************************************************************************************************************
16 *
17 * Authors: Pablo Inigo Blasco, Brett Aldrich
18 *
19 ******************************************************************************************************************/
20
22
23namespace cl_moveit2z
24{
26 std::string name, moveit_msgs::msg::CollisionObject & object)
27{
28 if (this->graspingObjects.count(name))
29 {
30 object = this->graspingObjects[name];
31 return true;
32 }
33 else
34 {
35 return false;
36 }
37}
38
40 std::string frameid, float x, float y, float z, float xl, float yl, float zl)
41{
42 RCLCPP_INFO_STREAM(
43 getLogger(), "[" << getName() << "] creating grasping object in planning scene: " << frameid);
44 moveit_msgs::msg::CollisionObject collision;
45 auto boxname = frameid;
46 ;
47 collision.id = boxname;
48 collision.header.frame_id = frameid;
49
50 collision.primitives.resize(1);
51 collision.primitives[0].type = collision.primitives[0].BOX;
52 collision.primitives[0].dimensions.resize(3);
53
54 collision.primitives[0].dimensions[0] = xl;
55 collision.primitives[0].dimensions[1] = yl;
56 collision.primitives[0].dimensions[2] = zl;
57
58 collision.primitive_poses.resize(1);
59 collision.primitive_poses[0].position.x = x;
60 collision.primitive_poses[0].position.y = y;
61 collision.primitive_poses[0].position.z = z;
62 collision.primitive_poses[0].orientation.w = 1.0;
63
64 graspingObjects[boxname] = collision;
65}
66} // namespace cl_moveit2z
void createGraspableBox(std::string frameid, float x, float y, float z, float xl, float yl, float zl)
std::map< std::string, moveit_msgs::msg::CollisionObject > graspingObjects
bool getGraspingObject(std::string name, moveit_msgs::msg::CollisionObject &object)
virtual std::string getName() const
rclcpp::Logger getLogger() const