moveit2
The MoveIt Motion Planning Framework for ROS 2.
move_group_sequence_action.h
Go to the documentation of this file.
1 /*********************************************************************
2  * Software License Agreement (BSD License)
3  *
4  * Copyright (c) 2018 Pilz GmbH & Co. KG
5  * All rights reserved.
6  *
7  * Redistribution and use in source and binary forms, with or without
8  * modification, are permitted provided that the following conditions
9  * are met:
10  *
11  * * Redistributions of source code must retain the above copyright
12  * notice, this list of conditions and the following disclaimer.
13  * * Redistributions in binary form must reproduce the above
14  * copyright notice, this list of conditions and the following
15  * disclaimer in the documentation and/or other materials provided
16  * with the distribution.
17  * * Neither the name of Pilz GmbH & Co. KG nor the names of its
18  * contributors may be used to endorse or promote products derived
19  * from this software without specific prior written permission.
20  *
21  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
22  * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
23  * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
24  * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
25  * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
26  * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
27  * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
28  * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
29  * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
30  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
31  * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
32  * POSSIBILITY OF SUCH DAMAGE.
33  *********************************************************************/
34 
35 #pragma once
36 
37 #include <memory>
38 
39 #include <rclcpp_action/rclcpp_action.hpp>
41 
42 #include <moveit_msgs/action/move_group_sequence.hpp>
43 
45 {
46 class CommandListManager;
47 using MoveGroupSequenceGoalHandle = rclcpp_action::ServerGoalHandle<moveit_msgs::action::MoveGroupSequence>;
48 
54 {
55 public:
57 
58  void initialize() override;
59 
60 private:
61  using ExecutableTrajs = std::vector<plan_execution::ExecutableTrajectory>;
62 
63  using StartStateMsg = moveit_msgs::msg::MotionSequenceResponse::_sequence_start_type;
64  using StartStatesMsg = std::vector<moveit_msgs::msg::MotionSequenceResponse::_sequence_start_type>;
65  using PlannedTrajMsgs = moveit_msgs::msg::MotionSequenceResponse::_planned_trajectories_type;
66 
67 private:
68  void executeSequenceCallback(const std::shared_ptr<MoveGroupSequenceGoalHandle>& goal_handle);
69  void
70  executeSequenceCallbackPlanAndExecute(const moveit_msgs::action::MoveGroupSequence::Goal::ConstSharedPtr& goal,
71  const moveit_msgs::action::MoveGroupSequence::Result::SharedPtr& action_res);
72  void executeMoveCallbackPlanOnly(const moveit_msgs::action::MoveGroupSequence::Goal::ConstSharedPtr& goal,
73  const moveit_msgs::action::MoveGroupSequence::Result::SharedPtr& res);
74  void startMoveExecutionCallback();
75  void startMoveLookCallback();
76  void preemptMoveCallback();
77  void setMoveState(move_group::MoveGroupState state);
78  bool planUsingSequenceManager(const moveit_msgs::msg::MotionSequenceRequest& req,
80 
81 private:
82  static void convertToMsg(const ExecutableTrajs& trajs, StartStatesMsg& startStatesMsg,
83  PlannedTrajMsgs& plannedTrajsMsgs);
84 
85 private:
86  rclcpp::CallbackGroup::SharedPtr action_callback_group_;
87  std::shared_ptr<rclcpp_action::Server<moveit_msgs::action::MoveGroupSequence>> move_action_server_;
88  std::shared_ptr<MoveGroupSequenceGoalHandle> goal_handle_;
89  moveit_msgs::action::MoveGroupSequence::Feedback::SharedPtr move_feedback_;
90 
92  std::unique_ptr<pilz_industrial_motion_planner::CommandListManager> command_list_manager_;
93 };
94 } // namespace pilz_industrial_motion_planner
Provide action to handle multiple trajectories and execute the result in the form of a MoveGroup capa...
rclcpp_action::ServerGoalHandle< moveit_msgs::action::MoveGroupSequence > MoveGroupSequenceGoalHandle
Definition: plan.py:1
A generic representation on what a computed motion plan looks like.