SMACC2
Loading...
Searching...
No Matches
cb_detach_object.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
23
24namespace cl_moveit2z
25{
27{
28 RCLCPP_INFO_STREAM(getLogger(), "[" << getName() << "] requesting components");
29
30 cl_moveit2z::CpGraspingComponent * graspingComponent;
31 this->requiresComponent(graspingComponent);
32
33 cl_moveit2z::ClMoveit2z * moveGroupClient;
34 this->requiresClient(moveGroupClient);
35
36 auto & planningSceneInterface = moveGroupClient->planningSceneInterface;
37
38 RCLCPP_INFO_STREAM(getLogger(), "[" << getName() << "] requesting detach object");
39
40 auto res = moveGroupClient->moveGroupClientInterface->detachObject(
41 *(graspingComponent->currentAttachedObjectName));
42 planningSceneInterface->removeCollisionObjects({*(graspingComponent->currentAttachedObjectName)});
43
44 RCLCPP_INFO_STREAM(getLogger(), "[" << getName() << "] detach result: " << res);
45
46 if (res)
47 this->postSuccessEvent();
48 else
49 this->postFailureEvent();
50}
51
53} // namespace cl_moveit2z
virtual void onExit() override
virtual void onEntry() override
std::shared_ptr< moveit::planning_interface::MoveGroupInterface > moveGroupClientInterface
std::shared_ptr< moveit::planning_interface::PlanningSceneInterface > planningSceneInterface
std::optional< std::string > currentAttachedObjectName
virtual rclcpp::Logger getLogger() const
void requiresClient(SmaccClientType *&storage)
void requiresComponent(SmaccComponentType *&storage, bool throwExceptionIfNotExist=false)