moveit2
The MoveIt Motion Planning Framework for ROS 2.
Loading...
Searching...
No Matches
path_polyline_generator.hpp
Go to the documentation of this file.
1/*********************************************************************
2 * Software License Agreement (BSD License)
3 *
4 * Copyright (c) 2018 Pilz GmbH & Co. KG
5 * Copyright (c) 2025 Aiman Haidar
6 * All rights reserved.
7 *
8 * Redistribution and use in source and binary forms, with or without
9 * modification, are permitted provided that the following conditions
10 * are met:
11 *
12 * * Redistributions of source code must retain the above copyright
13 * notice, this list of conditions and the following disclaimer.
14 * * Redistributions in binary form must reproduce the above
15 * copyright notice, this list of conditions and the following
16 * disclaimer in the documentation and/or other materials provided
17 * with the distribution.
18 * * Neither the name of Pilz GmbH & Co. KG nor the names of its
19 * contributors may be used to endorse or promote products derived
20 * from this software without specific prior written permission.
21 *
22 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
23 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
24 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
25 * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
26 * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
27 * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
28 * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
29 * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
30 * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
31 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
32 * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
33 * POSSIBILITY OF SUCH DAMAGE.
34 *********************************************************************/
35
36#pragma once
37
38#include <kdl/path.hpp>
39#include <kdl/path_roundedcomposite.hpp>
40#include <kdl/rotational_interpolation_sa.hpp>
41#include <kdl/utilities/error.h>
42
43#include <memory>
44
46{
51class PathPolylineGenerator
52{
53public:
58 static std::unique_ptr<KDL::Path> polylineFromWaypoints(const KDL::Frame& start_pose,
59 const std::vector<KDL::Frame>& waypoints,
60 KDL::RotationalInterpolation* rot_interpo, double smoothness,
61 double eqradius);
62
69 static std::vector<KDL::Frame> filterWaypoints(const KDL::Frame& start_pose, const std::vector<KDL::Frame>& waypoints);
70 static double computeBlendRadius(const std::vector<KDL::Frame>& waypoints_, double smoothness);
71 static void checkConsecutiveColinearWaypoints(const KDL::Frame& p1, const KDL::Frame& p2, const KDL::Frame& p3);
72
73private:
74 PathPolylineGenerator(){}; // no instantiation of this helper class!
75
76 static constexpr double MIN_SEGMENT_LENGTH{ 0.2e-3 };
77 static constexpr double MIN_SMOOTHNESS{ 0.01 };
78 static constexpr double MAX_SMOOTHNESS{ 0.99 };
79 static constexpr double MIN_COLINEAR_NORM{ 1e-9 };
80};
81
82class ErrorMotionPlanningColinearConsicutiveWaypoints : public KDL::Error_MotionPlanning
83{
84public:
85 const char* Description() const override
86 {
87 return "Three collinear consecutive waypoints."
88 " A Polyline Path cannot be created.";
89 }
90 int GetType() const override
91 {
92 return ERROR_CODE_COLINEAR_CONSECUTIVE_WAYPOINTS;
93 } // LCOV_EXCL_LINE
94
95private:
96 static constexpr int ERROR_CODE_COLINEAR_CONSECUTIVE_WAYPOINTS{ 3104 };
97};
98
99} // namespace pilz_industrial_motion_planner
static std::vector< KDL::Frame > filterWaypoints(const KDL::Frame &start_pose, const std::vector< KDL::Frame > &waypoints)
compute the maximum rounding radius from KDL::Path_RoundedComosite
static std::unique_ptr< KDL::Path > polylineFromWaypoints(const KDL::Frame &start_pose, const std::vector< KDL::Frame > &waypoints, KDL::RotationalInterpolation *rot_interpo, double smoothness, double eqradius)
set the path polyline from waypoints
static double computeBlendRadius(const std::vector< KDL::Frame > &waypoints_, double smoothness)
static void checkConsecutiveColinearWaypoints(const KDL::Frame &p1, const KDL::Frame &p2, const KDL::Frame &p3)