src
example_library.cpp
Go to the documentation of this file.
1
// Copyright 2021 PickNik Inc.
2
//
3
// Redistribution and use in source and binary forms, with or without
4
// modification, are permitted provided that the following conditions are met:
5
//
6
// * Redistributions of source code must retain the above copyright
7
// notice, this list of conditions and the following disclaimer.
8
//
9
// * Redistributions in binary form must reproduce the above copyright
10
// notice, this list of conditions and the following disclaimer in the
11
// documentation and/or other materials provided with the distribution.
12
//
13
// * Neither the name of the PickNik Inc. nor the names of its
14
// contributors may be used to endorse or promote products derived from
15
// this software without specific prior written permission.
16
//
17
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
18
// AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
19
// IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
20
// ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
21
// LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
22
// CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
23
// SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
24
// INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
25
// CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
26
// ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
27
// POSSIBILITY OF SUCH DAMAGE.
28
29
/* Author: Tyler Weaver
30
Desc: Simple example using the [boost].SML library
31
*/
32
33
// C++
34
#include <string>
35
36
// ROS
37
#include <
boost_sml/example.h
>
38
#include <
ros/ros.h
>
39
using namespace
sml_example
;
40
41
int
example_main
(
int
argc,
char
** argv) {
42
const
std::string node_name =
"sml_example"
;
43
44
// Initialize ROS
45
ros::init
(argc, argv, node_name);
46
ROS_INFO_STREAM_NAMED
(node_name,
"Starting"
);
47
48
ros::AsyncSpinner
spinner(1);
49
spinner.
start
();
50
51
SmlRosLogger
logger(node_name);
52
StateMachine
state_machine{logger};
53
Spin
spin
{};
54
55
ros::Rate
loop_rate(1);
56
while
(
ros::ok
() && !state_machine.is(boost::sml::X)) {
57
state_machine.process_event(
spin
);
58
ros::spinOnce
();
59
loop_rate.
sleep
();
60
}
61
62
// Shutdown
63
ROS_INFO_STREAM_NAMED
(node_name,
"Shutting down."
);
64
spinner.
stop
();
65
ros::shutdown
();
66
67
return
0;
68
}
ros::init
ROSCPP_DECL void init(const M_string &remappings, const std::string &name, uint32_t options=0)
ros::AsyncSpinner::start
void start()
ros.h
ros::AsyncSpinner
sml_example::Spin
Definition:
example.h:40
ros::spinOnce
ROSCPP_DECL void spinOnce()
ros::shutdown
ROSCPP_DECL void shutdown()
ros::ok
ROSCPP_DECL bool ok()
sml_example
Definition:
example.h:36
ros::Rate::sleep
bool sleep()
ros::AsyncSpinner::stop
void stop()
example.h
ROS_INFO_STREAM_NAMED
#define ROS_INFO_STREAM_NAMED(name, args)
SmlRosLogger
Definition:
logger.h:45
ros::Rate
spin
ROSCPP_DECL void spin()
example_main
int example_main(int argc, char **argv)
Definition:
example_library.cpp:41
sml_example::StateMachine
sml::sm< StateMachineLogic, sml::logger< SmlRosLogger > > StateMachine
Definition:
example.h:62
boost_sml
Author(s): boost-experimental (https://github.com/boost-experimental)
autogenerated on Tue Jan 24 2023 03:32:39