SMACC2
Loading...
Searching...
No Matches
cp_waypoints_navigator_base.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#pragma once
21
24#include <smacc2/smacc.hpp>
25
26#include <geometry_msgs/msg/pose.hpp>
27
28namespace cl_nav2z
29{
30struct Pose2D
31{
32 Pose2D(double x, double y, double yaw)
33 {
34 this->x_ = x;
35 this->y_ = y;
36 this->yaw_ = yaw;
37 }
38
39 double x_;
40 double y_;
41 double yaw_;
42};
43
44// This component contains a list of waypoints. These waypoints can
45// be iterated in the different states using CbNextWaiPoint
46// waypoint index is only incremented if the current waypoint is successfully reached
48{
49public:
51
53
55
56 void onInitialize() override;
57
58 // DEPRECATED: For third-party compatibility only. Third-party developers should migrate to onStateOrthogonalAllocation
59 // This method exists to support existing third-party classes that inherit from this base class
60 // and call CpWaypointNavigatorBase::onOrthogonalAllocation<TOrthogonal, TSourceObject>()
61 template <typename TOrthogonal, typename TSourceObject>
62 [[deprecated(
63 "Use onStateOrthogonalAllocation instead. This method exists only for third-party "
64 "compatibility.")]] void
66 {
67 // Call the new method to maintain functionality for third-party inheritors
69 }
70
71 template <typename TOrthogonal, typename TSourceObject>
73 {
74 ClNav2Z * client = dynamic_cast<ClNav2Z *>(owner_);
75 waypointsEventDispatcher.initialize<TSourceObject, TOrthogonal>(client);
76 }
77
78 void loadWayPointsFromFile(std::string filepath);
79
80 void loadWayPointsFromFile2(std::string filepath);
81
82 void setWaypoints(const std::vector<geometry_msgs::msg::Pose> & waypoints);
83
84 void setWaypoints(const std::vector<Pose2D> & waypoints);
85
86 const std::vector<geometry_msgs::msg::Pose> & getWaypoints() const;
87 const std::vector<std::string> & getWaypointNames() const;
88 std::optional<geometry_msgs::msg::Pose> getNamedPose(std::string name) const;
89 geometry_msgs::msg::Pose getPose(int index) const;
90 geometry_msgs::msg::Pose getCurrentPose() const;
91
92 long getCurrentWaypointIndex() const;
93 std::optional<std::string> getCurrentWaypointName() const;
94
96
97 void rewind(int count);
98
99 void forward(int count);
100 void seekName(std::string name);
101
103 std::string parameter_name, std::string yaml_file_package_name);
104
105 void notifyGoalReached();
106
107protected:
108 void insertWaypoint(int index, geometry_msgs::msg::Pose & newpose);
109
110 void removeWaypoint(int index);
111
112 std::vector<geometry_msgs::msg::Pose> waypoints_;
113
114 std::vector<std::string> waypointsNames_;
115};
116} // namespace cl_nav2z
void setWaypoints(const std::vector< geometry_msgs::msg::Pose > &waypoints)
const std::vector< geometry_msgs::msg::Pose > & getWaypoints() const
void loadWayPointsFromFile2(std::string filepath)
std::vector< geometry_msgs::msg::Pose > waypoints_
geometry_msgs::msg::Pose getCurrentPose() const
void loadWayPointsFromFile(std::string filepath)
std::optional< std::string > getCurrentWaypointName() const
std::optional< geometry_msgs::msg::Pose > getNamedPose(std::string name) const
geometry_msgs::msg::Pose getPose(int index) const
const std::vector< std::string > & getWaypointNames() const
void loadWaypointsFromYamlParameter(std::string parameter_name, std::string yaml_file_package_name)
void insertWaypoint(int index, geometry_msgs::msg::Pose &newpose)
ISmaccClient * owner_
Definition component.hpp:96
Pose2D(double x, double y, double yaw)