SMACC2
Loading...
Searching...
No Matches
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 <tf2_geometry_msgs/tf2_geometry_msgs.h>
31#include <geometry_msgs/msg/transform.hpp>
32#include <geometry_msgs/msg/vector3.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 ClMoveGroup(const moveit::planning_interface::MoveGroupInterface::Options & options);
91
92 virtual ~ClMoveGroup();
93
94 void onInitialize() override;
95
97
99
100 template <typename TOrthogonal, typename TSourceObject>
102 {
104 {
105 this->onSucceded_();
106 this->postEvent<EvMoveGroupMotionExecutionSucceded<TSourceObject, TOrthogonal>>();
107 };
108
110 {
111 this->onFailed_();
112 this->postEvent<EvMoveGroupMotionExecutionFailed<TSourceObject, TOrthogonal>>();
113 };
114 }
115
116 template <typename TCallback, typename T>
117 boost::signals2::connection onMotionExecutionSuccedded(TCallback callback, T * object)
118 {
119 return this->getStateMachine()->createSignalConnection(onSucceded_, callback, object);
120 }
121
122 template <typename TCallback, typename T>
123 boost::signals2::connection onMotionExecutionFailed(TCallback callback, T * object)
124 {
125 return this->getStateMachine()->createSignalConnection(onFailed_, callback, object);
126 }
127
128 const moveit::planning_interface::MoveGroupInterface::Options & getOptions() const;
129
130private:
132 std::function<void()> postEventMotionExecutionFailed_;
133
136
137 // std::string groupName_;
138 moveit::planning_interface::MoveGroupInterface::Options options_;
139};
140} // namespace cl_move_group_interface
std::function< void()> postEventMotionExecutionSucceded_
std::shared_ptr< moveit::planning_interface::MoveGroupInterface > moveGroupClientInterface
const moveit::planning_interface::MoveGroupInterface::Options & getOptions() const
moveit::planning_interface::MoveGroupInterface::Options options_
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
std::function< void()> postEventMotionExecutionFailed_
smacc2::SmaccSignal< void()> onFailed_
ISmaccStateMachine * getStateMachine()
boost::signals2::connection createSignalConnection(TSmaccSignal &signal, TMemberFunctionPrototype callback, TSmaccObjectType *object)