SMACC2
Loading...
Searching...
No Matches
cb_nav2z_client_behavior_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
22#include <cl_nav2z/cl_nav2z.hpp>
27
28namespace cl_nav2z
29{
30using namespace smacc2;
32{
33public:
35
36 template <typename TOrthogonal, typename TSourceObject>
38 {
39 // NEW: Pure component-based approach - no client dependencies
40 this->requiresComponent(nav2ActionInterface_, ComponentRequirement::HARD);
41 this->requiresComponent(actionClient_, ComponentRequirement::HARD);
42
44 }
45
46protected:
47 // NEW: Component-based API - uses components directly
48 void sendGoal(nav2_msgs::action::NavigateToPose::Goal & goal)
49 {
51 {
53 }
54 }
55
57 {
59 {
61 }
62 }
63
64 // Component-based signal connections
65 template <typename T>
66 boost::signals2::connection onNavigationSucceeded(
67 void (T::*callback)(const components::CpNav2ActionInterface::WrappedResult &), T * object)
68 {
70 {
71 return nav2ActionInterface_->onNavigationSucceeded(callback, object);
72 }
73 return boost::signals2::connection();
74 }
75
76 template <typename T>
77 boost::signals2::connection onNavigationAborted(
78 void (T::*callback)(const components::CpNav2ActionInterface::WrappedResult &), T * object)
79 {
81 {
82 return nav2ActionInterface_->onNavigationAborted(callback, object);
83 }
84 return boost::signals2::connection();
85 }
86
87 template <typename T>
88 boost::signals2::connection onNavigationCancelled(
89 void (T::*callback)(const components::CpNav2ActionInterface::WrappedResult &), T * object)
90 {
92 {
93 return nav2ActionInterface_->onNavigationCancelled(callback, object);
94 }
95 return boost::signals2::connection();
96 }
97
98 // NEW: Component references instead of client reference
101 actionClient_ = nullptr;
102
103 // Common legacy member for result tracking
104 rclcpp_action::ResultCode navigationResult_;
105
106 // REMOVED: All legacy client-based members
107 // ❌ cl_nav2z::ClNav2Z * nav2zClient_
108 // ❌ cl_nav2z::ClNav2Z::SmaccNavigateResultSignal::SharedPtr navigationCallback_
109 // ❌ rclcpp_action::ResultCode navigationResult_
110 // ❌ goalHandleFuture_
111
112 // Virtual methods for derived classes - now use component types
118};
119
121{
122 Default,
124 Forward
125};
126} // namespace cl_nav2z
virtual void onNavigationActionSuccess(const components::CpNav2ActionInterface::WrappedResult &)
smacc2::client_core_components::CpActionClient< nav2_msgs::action::NavigateToPose > * actionClient_
components::CpNav2ActionInterface * nav2ActionInterface_
virtual void onNavigationActionAbort(const components::CpNav2ActionInterface::WrappedResult &)
boost::signals2::connection onNavigationSucceeded(void(T::*callback)(const components::CpNav2ActionInterface::WrappedResult &), T *object)
virtual void onNavigationResult(const components::CpNav2ActionInterface::WrappedResult &)
void sendGoal(nav2_msgs::action::NavigateToPose::Goal &goal)
boost::signals2::connection onNavigationAborted(void(T::*callback)(const components::CpNav2ActionInterface::WrappedResult &), T *object)
boost::signals2::connection onNavigationCancelled(void(T::*callback)(const components::CpNav2ActionInterface::WrappedResult &), T *object)
boost::signals2::connection onNavigationCancelled(void(T::*callback)(const WrappedResult &), T *object)
boost::signals2::connection onNavigationSucceeded(void(T::*callback)(const WrappedResult &), T *object)
std::shared_future< typename GoalHandle::SharedPtr > sendGoal(Goal &goal)
boost::signals2::connection onNavigationAborted(void(T::*callback)(const WrappedResult &), T *object)
void requiresComponent(SmaccComponentType *&storage, ComponentRequirement requirementType=ComponentRequirement::SOFT)