SMACC2
Loading...
Searching...
No Matches
cb_spiral_motion.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
21#pragma once
22
25
26namespace cl_nav2z
27{
28
29// client behaviors typically accept parameters to be customized in the state it is being used
30// we follow this pattern, with a basic structure with optional fields, that make thee initialization of the behavior more readable in the
31// state initialization. It also avoid an explosion of constructors for each variation of the parameters.
33{
34 std::optional<float> linearVelocity = 0.0f;
35 std::optional<float> maxLinearVelocity = 0.5f;
36 std::optional<float> initialAngularVelocity = 1.5f;
37 std::optional<rclcpp::Duration> spiralMotionDuration = rclcpp::Duration::from_seconds(40);
38 std::optional<float> finalRadius = 20.0f; //meters
39};
40
41/* a basic client behavior has a simple onEntry and onExit functions. When we enter into a stae we call onEntry.
42This client behavior is asynchronous so that onEntry returns immediately, it opens a thread to run the behavior*/
44{
45public:
46 //
47 // constructor, we accept an empty usag of the behavior, but also any other combination of parameters
48 CbSpiralMotion(std::optional<CbSpiralMotionOptions> options = std::nullopt);
49
50 void onEntry() override;
51
52 void onExit() override;
53
54private:
55 // this client behavior has its own temporal publisher to control the robot
56 rclcpp::Publisher<geometry_msgs::msg::Twist>::SharedPtr cmdVelPub_;
57
58 // we store the options that customize the behavior
60};
61} // namespace cl_nav2z
std::optional< float > initialAngularVelocity
std::optional< float > linearVelocity
std::optional< rclcpp::Duration > spiralMotionDuration
std::optional< float > maxLinearVelocity
std::optional< float > finalRadius
CbSpiralMotionOptions options_
rclcpp::Publisher< geometry_msgs::msg::Twist >::SharedPtr cmdVelPub_
CbSpiralMotion(std::optional< CbSpiralMotionOptions > options=std::nullopt)