SMACC2
Loading...
Searching...
No Matches
cb_moveit2z_client_behavior_base.hpp
Go to the documentation of this file.
1// Copyright 2026 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: Brett Aldrich, Pablo Inigo Blasco
18 *
19 ******************************************************************************************************************/
20
21#pragma once
22
28
29namespace cl_moveit2z
30{
31
32// Base for cl_moveit2z motion behaviors. Encodes the async-thread discipline
33// (see the locking rule in CLAUDE.md): all components are resolved here, in
34// onStateOrthogonalAllocation on the state machine thread - never from the
35// asynchronous onEntry/onExit threads, where requiresComponent contends for
36// the state machine mutex and can deadlock against a concurrent transition.
37// Derived behaviors use the protected component members directly and finish
38// through postMotionSuccess()/postMotionFailure(), which centralize the
39// client-scoped motion event + behavior-scoped EvCbSuccess/EvCbFailure pair.
40//
41// Execution model is unchanged: blocking MoveGroupInterface calls on the
42// asynchronous behavior thread (check isShutdownRequested() in long loops).
44{
45public:
46 template <typename TOrthogonal, typename TSourceObject>
48 {
49 // CpMoveGroupInterface is always created by ClMoveit2z; the rest are
50 // optional per-SM opt-ins (preferred path when present, legacy fallback
51 // otherwise - same semantics the behaviors implemented individually)
56
58 }
59
61
62protected:
64 {
65 RCLCPP_INFO_STREAM(
66 getLogger(), "[" << getName() << "] motion execution succeeded. Throwing success event.");
67 if (cpMoveGroup_ != nullptr)
68 {
70 }
71 this->postSuccessEvent();
72 }
73
75 {
76 RCLCPP_WARN_STREAM(
77 getLogger(), "[" << getName() << "] motion execution failed. Throwing fail event.");
78 if (cpMoveGroup_ != nullptr)
79 {
81 }
82 this->postFailureEvent();
83 }
84
89};
90
91} // namespace cl_moveit2z
Component for centralized motion planning operations.
Component for centralized trajectory execution.
virtual rclcpp::Logger getLogger() const
void requiresComponent(SmaccComponentType *&storage, ComponentRequirement requirementType=ComponentRequirement::SOFT)