SMACC2
Loading...
Searching...
No Matches
cl_nav2z.hpp
Go to the documentation of this file.
1// Copyright 2024 Robosoft 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#pragma once
16
18#include <nav2_msgs/action/navigate_to_pose.hpp>
20#include <smacc2/smacc.hpp>
21
22namespace cl_nav2z
23{
24
25// Pure component-based ClNav2Z - No legacy support
26// Follows cl_keyboard pattern: orchestrator only, behaviors use requiresComponent()
28{
29public:
30 // Type aliases required for event system (TSource::WrappedResult in smacc_default_events.hpp)
31 using ActionType = nav2_msgs::action::NavigateToPose;
32 using GoalHandle = rclcpp_action::ClientGoalHandle<ActionType>;
33 using WrappedResult = typename GoalHandle::WrappedResult;
34 using Feedback = typename ActionType::Feedback;
35
36 // Constructor
37 ClNav2Z(std::string actionServerName = "/navigate_to_pose") : actionServerName_(actionServerName)
38 {
39 }
40
41 virtual ~ClNav2Z() = default;
42
43 // Component composition during orthogonal initialization
44 template <typename TOrthogonal, typename TClient>
46 {
47 // Create core action client component
48 this->createComponent<
50 TOrthogonal, ClNav2Z>(actionServerName_);
51
52 // Create nav2-specific interface component (requires actionClient)
54
55 RCLCPP_INFO_STREAM(
56 this->getLogger(), "[ClNav2Z] Components created for action server: " << actionServerName_);
57 }
58
59private:
60 std::string actionServerName_;
61
62 // ✅ PURE ORCHESTRATOR PATTERN - ALL LEGACY METHODS REMOVED:
63 //
64 // ❌ REMOVED: sendGoal() methods - use CpNav2ActionInterface::sendGoal()
65 // ❌ REMOVED: signal connection proxy methods - use CpNav2ActionInterface::onNavigationSucceeded()
66 // ❌ REMOVED: signal getter methods - signals owned by components
67 // ❌ REMOVED: component accessor methods - use requiresComponent()
68 // ❌ REMOVED: convenience wrapper methods - use component APIs directly
69 // ❌ REMOVED: type aliases - use component types directly
70 //
71 // ✅ NEW BEHAVIOR PATTERN:
72 // class CbNavigateForward : public CbNav2ZClientBehaviorBase {
73 // void onEntry() override {
74 // CpNav2ActionInterface* navInterface;
75 // this->requiresComponent(navInterface);
76 // navInterface->onNavigationSucceeded(&CbNavigateForward::onSuccess, this);
77 // Goal goal = createForwardGoal();
78 // navInterface->sendGoal(goal);
79 // }
80 // };
81 //
82 // ✅ SMACC2 SIGNAL COMPLIANCE: All signal connections use createSignalConnection()
83 // ✅ FRAMEWORK CONSISTENCY: Matches cl_keyboard pure component pattern
84 // ✅ CLEAN SEPARATION: Client orchestrates, components implement, behaviors consume
85};
86
87} // namespace cl_nav2z
typename GoalHandle::WrappedResult WrappedResult
Definition cl_nav2z.hpp:33
typename ActionType::Feedback Feedback
Definition cl_nav2z.hpp:34
void onComponentInitialization()
Definition cl_nav2z.hpp:45
std::string actionServerName_
Definition cl_nav2z.hpp:60
ClNav2Z(std::string actionServerName="/navigate_to_pose")
Definition cl_nav2z.hpp:37
virtual ~ClNav2Z()=default
rclcpp_action::ClientGoalHandle< ActionType > GoalHandle
Definition cl_nav2z.hpp:32
nav2_msgs::action::NavigateToPose ActionType
Definition cl_nav2z.hpp:31
rclcpp::Logger getLogger()
SmaccComponentType * createComponent(TArgs... targs)