SMACC2
cl_movegroup.hpp
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
21#pragma once
22
23//#include <smacc2/smacc_client.h>
24//#include <smacc2/smacc_signal.h>
25#include <smacc2/smacc.hpp>
26
27#include <moveit/move_group_interface/move_group_interface.h>
28#include <moveit/planning_scene_interface/planning_scene_interface.h>
29
30#include <geometry_msgs/msg/transform.hpp>
31#include <geometry_msgs/msg/vector3.hpp>
32#include <tf2_geometry_msgs/tf2_geometry_msgs.hpp>
33
35{
36template <typename TSource, typename TOrthogonal>
38: sc::event<EvMoveGroupMotionExecutionSucceded<TSource, TOrthogonal>>
39{
40};
41
42template <typename TSource, typename TOrthogonal>
44: sc::event<EvMoveGroupMotionExecutionFailed<TSource, TOrthogonal>>
45{
46};
47
48/*
49moveit_msgs/MoveItErrorCodes
50----------------------------
51int32 SUCCESS=1
52int32 FAILURE=99999
53int32 PLANNING_FAILED=-1
54int32 INVALID_MOTION_PLAN=-2
55int32 MOTION_PLAN_INVALIDATED_BY_ENVIRONMENT_CHANGE=-3
56int32 CONTROL_FAILED=-4
57int32 UNABLE_TO_AQUIRE_SENSOR_DATA=-5
58int32 TIMED_OUT=-6
59int32 PREEMPTED=-7
60int32 START_STATE_IN_COLLISION=-10
61int32 START_STATE_VIOLATES_PATH_CONSTRAINTS=-11
62int32 GOAL_IN_COLLISION=-12
63int32 GOAL_VIOLATES_PATH_CONSTRAINTS=-13
64int32 GOAL_CONSTRAINTS_VIOLATED=-14
65int32 INVALID_GROUP_NAME=-15
66int32 INVALID_GOAL_CONSTRAINTS=-16
67int32 INVALID_ROBOT_STATE=-17
68int32 INVALID_LINK_NAME=-18
69int32 INVALID_OBJECT_NAME=-19
70int32 FRAME_TRANSFORM_FAILURE=-21
71int32 COLLISION_CHECKING_UNAVAILABLE=-22
72int32 ROBOT_STATE_STALE=-23
73int32 SENSOR_INFO_STALE=-24
74int32 NO_IK_SOLUTION=-31
75int32 val
76*/
77
79{
80public:
81 // this structure contains the default move_group configuration for any arm motion through move_group
82 // the client behavior will override these default values in a copy of this object so that their changes
83 // are not persinstent. In the other hand, if you change this client configuration, the parameters will be persistent.
84 std::shared_ptr<moveit::planning_interface::MoveGroupInterface> moveGroupClientInterface;
85
86 std::shared_ptr<moveit::planning_interface::PlanningSceneInterface> planningSceneInterface;
87
88 ClMoveGroup(std::string groupName);
89
90 virtual ~ClMoveGroup();
91
92 void onInitialize() override;
93
95
97
98 template <typename TOrthogonal, typename TSourceObject>
100 {
102 this->onSucceded_();
103 this->postEvent<EvMoveGroupMotionExecutionSucceded<TSourceObject, TOrthogonal>>();
104 };
105
107 this->onFailed_();
108 this->postEvent<EvMoveGroupMotionExecutionFailed<TSourceObject, TOrthogonal>>();
109 };
110 }
111
112 template <typename TCallback, typename T>
113 boost::signals2::connection onMotionExecutionSuccedded(TCallback callback, T * object)
114 {
115 return this->getStateMachine()->createSignalConnection(onSucceded_, callback, object);
116 }
117
118 template <typename TCallback, typename T>
119 boost::signals2::connection onMotionExecutionFailed(TCallback callback, T * object)
120 {
121 return this->getStateMachine()->createSignalConnection(onFailed_, callback, object);
122 }
123
124private:
126 std::function<void()> postEventMotionExecutionFailed_;
127
130
131 std::string groupName_;
132};
133} // namespace cl_move_group_interface
std::function< void()> postEventMotionExecutionSucceded_
std::shared_ptr< moveit::planning_interface::MoveGroupInterface > moveGroupClientInterface
boost::signals2::connection onMotionExecutionFailed(TCallback callback, T *object)
boost::signals2::connection onMotionExecutionSuccedded(TCallback callback, T *object)
smacc2::SmaccSignal< void()> onSucceded_
std::shared_ptr< moveit::planning_interface::PlanningSceneInterface > planningSceneInterface
ClMoveGroup(std::string groupName)
std::function< void()> postEventMotionExecutionFailed_
smacc2::SmaccSignal< void()> onFailed_
ISmaccStateMachine * getStateMachine()
boost::signals2::connection createSignalConnection(TSmaccSignal &signal, TMemberFunctionPrototype callback, TSmaccObjectType *object)
void callback(const image_tools::ROSCvMatContainer &img)