SMACC2
Loading...
Searching...
No Matches
smacc2_client_library
nav2z_client
nav2z_client
include
nav2z_client
client_behaviors
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
23
#include <
nav2z_client/components/pose/cp_pose.hpp
>
24
#include <
smacc2/smacc_asynchronous_client_behavior.hpp
>
25
26
namespace
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.
32
struct
CbSpiralMotionOptions
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.
42
This client behavior is asynchronous so that onEntry returns immediately, it opens a thread to run the behavior*/
43
struct
CbSpiralMotion
:
public
smacc2::SmaccAsyncClientBehavior
44
{
45
public
:
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
54
private
:
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
59
CbSpiralMotionOptions
options_
;
60
};
61
}
// namespace cl_nav2z
smacc2::SmaccAsyncClientBehavior
Definition
smacc_asynchronous_client_behavior.hpp:56
cp_pose.hpp
cl_nav2z
Definition
backward_global_planner.hpp:28
smacc_asynchronous_client_behavior.hpp
cl_nav2z::CbSpiralMotionOptions
Definition
cb_spiral_motion.hpp:33
cl_nav2z::CbSpiralMotionOptions::initialAngularVelocity
std::optional< float > initialAngularVelocity
Definition
cb_spiral_motion.hpp:36
cl_nav2z::CbSpiralMotionOptions::linearVelocity
std::optional< float > linearVelocity
Definition
cb_spiral_motion.hpp:34
cl_nav2z::CbSpiralMotionOptions::spiralMotionDuration
std::optional< rclcpp::Duration > spiralMotionDuration
Definition
cb_spiral_motion.hpp:37
cl_nav2z::CbSpiralMotionOptions::maxLinearVelocity
std::optional< float > maxLinearVelocity
Definition
cb_spiral_motion.hpp:35
cl_nav2z::CbSpiralMotionOptions::finalRadius
std::optional< float > finalRadius
Definition
cb_spiral_motion.hpp:38
cl_nav2z::CbSpiralMotion
Definition
cb_spiral_motion.hpp:44
cl_nav2z::CbSpiralMotion::options_
CbSpiralMotionOptions options_
Definition
cb_spiral_motion.hpp:59
cl_nav2z::CbSpiralMotion::onExit
void onExit() override
Definition
cb_spiral_motion.cpp:134
cl_nav2z::CbSpiralMotion::onEntry
void onEntry() override
Definition
cb_spiral_motion.cpp:43
cl_nav2z::CbSpiralMotion::cmdVelPub_
rclcpp::Publisher< geometry_msgs::msg::Twist >::SharedPtr cmdVelPub_
Definition
cb_spiral_motion.hpp:56
cl_nav2z::CbSpiralMotion::CbSpiralMotion
CbSpiralMotion(std::optional< CbSpiralMotionOptions > options=std::nullopt)
Definition
cb_spiral_motion.cpp:30
Generated by
1.12.0