SMACC2
Loading...
Searching...
No Matches
cp_move_group_interface.hpp
Go to the documentation of this file.
1// Copyright 2025 Robosoft 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
21#pragma once
22
23#include <smacc2/smacc.hpp>
24
25#include <moveit/move_group_interface/move_group_interface.hpp>
26#include <moveit/planning_scene_interface/planning_scene_interface.hpp>
27
28#include <geometry_msgs/msg/transform.hpp>
29#include <geometry_msgs/msg/vector3.hpp>
30#include <tf2_geometry_msgs/tf2_geometry_msgs.hpp>
31
32namespace cl_moveit2z
33{
34template <typename TSource, typename TOrthogonal>
36: sc::event<EvMoveGroupMotionExecutionSucceeded<TSource, TOrthogonal>>
37{
38};
39
40template <typename TSource, typename TOrthogonal>
42: sc::event<EvMoveGroupMotionExecutionFailed<TSource, TOrthogonal>>
43{
44};
45
47{
48public:
49 std::shared_ptr<moveit::planning_interface::MoveGroupInterface> moveGroupClientInterface;
50 std::shared_ptr<moveit::planning_interface::PlanningSceneInterface> planningSceneInterface;
51
53 const moveit::planning_interface::MoveGroupInterface::Options & options)
54 : options_(options)
55 {
56 }
57
58 inline void onInitialize() override
59 {
61 std::make_shared<moveit::planning_interface::MoveGroupInterface>(getNode(), options_);
62 planningSceneInterface = std::make_shared<moveit::planning_interface::PlanningSceneInterface>(
63 options_.move_group_namespace);
64 RCLCPP_INFO(getLogger(), "[CpMoveGroupInterface] MoveGroupInterface initialized");
65 }
66
67 template <typename TOrthogonal, typename TSourceObject>
82
84 {
85 RCLCPP_INFO(getLogger(), "[CpMoveGroupInterface] Post Motion Success Event");
87 }
88
90 {
91 RCLCPP_INFO(getLogger(), "[CpMoveGroupInterface] Post Motion Failure Event");
93 }
94
95 template <typename TCallback, typename T>
97 {
98 return this->getStateMachine()->createSignalConnection(onSucceeded_, callback, object);
99 }
100
101 template <typename TCallback, typename T>
103 {
104 return this->getStateMachine()->createSignalConnection(onFailed_, callback, object);
105 }
106
107private:
109 std::function<void()> postEventMotionExecutionFailed_;
110
113
114 moveit::planning_interface::MoveGroupInterface::Options options_;
115};
116
117} // namespace cl_moveit2z
std::function< void()> postEventMotionExecutionFailed_
smacc2::SmaccSignalConnection onMotionExecutionSucceeded(TCallback callback, T *object)
smacc2::SmaccSignal< void()> onSucceeded_
std::shared_ptr< moveit::planning_interface::MoveGroupInterface > moveGroupClientInterface
std::function< void()> postEventMotionExecutionSucceeded_
moveit::planning_interface::MoveGroupInterface::Options options_
std::shared_ptr< moveit::planning_interface::PlanningSceneInterface > planningSceneInterface
smacc2::SmaccSignalConnection onMotionExecutionFailed(TCallback callback, T *object)
CpMoveGroupInterface(const moveit::planning_interface::MoveGroupInterface::Options &options)
ISmaccStateMachine * getStateMachine()
rclcpp::Logger getLogger() const
rclcpp::Node::SharedPtr getNode()
smacc2::SmaccSignalConnection createSignalConnection(TSmaccSignal &signal, TMemberFunctionPrototype callback, TSmaccObjectType *object)
boost::signals2::connection SmaccSignalConnection