moveit2
The MoveIt Motion Planning Framework for ROS 2.
Loading...
Searching...
No Matches
plan_components_builder.h
Go to the documentation of this file.
1/*********************************************************************
2 * Software License Agreement (BSD License)
3 *
4 * Copyright (c) 2019 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#include <string>
39
43
48
50{
51using TipFrameFunc_t = std::function<const std::string&(const std::string&)>;
52
53// List of exceptions which can be thrown by the PlanComponentsBuilder class.
54CREATE_MOVEIT_ERROR_CODE_EXCEPTION(NoBlenderSetException, moveit_msgs::msg::MoveItErrorCodes::FAILURE);
55CREATE_MOVEIT_ERROR_CODE_EXCEPTION(NoTipFrameFunctionSetException, moveit_msgs::msg::MoveItErrorCodes::FAILURE);
56CREATE_MOVEIT_ERROR_CODE_EXCEPTION(NoRobotModelSetException, moveit_msgs::msg::MoveItErrorCodes::FAILURE);
57CREATE_MOVEIT_ERROR_CODE_EXCEPTION(BlendingFailedException, moveit_msgs::msg::MoveItErrorCodes::FAILURE);
58
64{
65public:
69 void setBlender(std::unique_ptr<pilz_industrial_motion_planner::TrajectoryBlender> blender);
70
74 void setModel(const moveit::core::RobotModelConstPtr& model);
75
99 void append(const planning_scene::PlanningSceneConstPtr& planning_scene,
100 const robot_trajectory::RobotTrajectoryPtr& other, const double blend_radius);
101
105 void reset();
106
110 std::vector<robot_trajectory::RobotTrajectoryPtr> build() const;
111
112private:
113 void blend(const planning_scene::PlanningSceneConstPtr& planning_scene,
114 const robot_trajectory::RobotTrajectoryPtr& other, const double blend_radius);
115
116private:
126 static void appendWithStrictTimeIncrease(robot_trajectory::RobotTrajectory& result,
128
129private:
131 std::unique_ptr<pilz_industrial_motion_planner::TrajectoryBlender> blender_;
132
134 moveit::core::RobotModelConstPtr model_;
135
137 robot_trajectory::RobotTrajectoryPtr traj_tail_;
138
140 std::vector<robot_trajectory::RobotTrajectoryPtr> traj_cont_;
141
142private:
144 static constexpr double ROBOT_STATE_EQUALITY_EPSILON = 1e-4;
145};
146
147inline void PlanComponentsBuilder::setBlender(std::unique_ptr<pilz_industrial_motion_planner::TrajectoryBlender> blender)
148{
149 blender_ = std::move(blender);
150}
151
152inline void PlanComponentsBuilder::setModel(const moveit::core::RobotModelConstPtr& model)
153{
154 model_ = model;
155}
156
158{
159 traj_tail_ = nullptr;
160 traj_cont_.clear();
161}
162
163} // namespace pilz_industrial_motion_planner
Helper class to encapsulate the merge and blend process of trajectories.
std::vector< robot_trajectory::RobotTrajectoryPtr > build() const
void reset()
Clears the trajectory container under construction.
void setModel(const moveit::core::RobotModelConstPtr &model)
Sets the robot model needed to create new trajectory elements.
void setBlender(std::unique_ptr< pilz_industrial_motion_planner::TrajectoryBlender > blender)
Sets the blender used to blend two trajectories.
void append(const planning_scene::PlanningSceneConstPtr &planning_scene, const robot_trajectory::RobotTrajectoryPtr &other, const double blend_radius)
Appends the specified trajectory to the trajectory container under construction.
Maintain a sequence of waypoints and the time durations between these waypoints.
std::function< const std::string &(const std::string &)> TipFrameFunc_t
This namespace includes the central class for representing planning contexts.
#define CREATE_MOVEIT_ERROR_CODE_EXCEPTION(EXCEPTION_CLASS_NAME, ERROR_CODE)