sas
Modularised monitoring, logging, and control of robots.
Toggle main menu visibility
Loading...
Searching...
No Matches
sas_simulator_server.hpp
1
#pragma once
2
/*
3
# Copyright (c) 2026 Murilo Marques Marinho
4
#
5
# This file is part of sas_common.
6
#
7
# sas_common is free software: you can redistribute it and/or modify
8
# it under the terms of the GNU Lesser General Public License as published by
9
# the Free Software Foundation, either version 3 of the License, or
10
# (at your option) any later version.
11
#
12
# sas_common is distributed in the hope that it will be useful,
13
# but WITHOUT ANY WARRANTY; without even the implied warranty of
14
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15
# GNU Lesser General Public License for more details.
16
#
17
# You should have received a copy of the GNU Lesser General Public License
18
# along with sas_common. If not, see <https://www.gnu.org/licenses/>.
19
#
20
# ################################################################
21
#
22
# Author: Murilo M. Marinho, email: murilomarinho@ieee.org
23
#
24
# ################################################################
25
# Contributors:
26
# ---
27
*/
28
29
#include <atomic>
30
#include <functional>
31
32
#include <rclcpp/rclcpp.hpp>
33
#include <std_srvs/srv/trigger.hpp>
34
#include <
sas_core/sas_object.hpp
>
35
36
using namespace
rclcpp;
37
38
namespace
sas
39
{
40
49
class
SimulatorServer:
private
sas::Object
50
{
51
private
:
52
std::shared_ptr<Node> node_;
53
54
std::atomic_bool enabled_;
55
std::string topic_prefix_;
56
57
std::shared_ptr<Service<std_srvs::srv::Trigger>> service_server_start_simulation_;
58
std::shared_ptr<Service<std_srvs::srv::Trigger>> service_server_stop_simulation_;
59
60
std::function<void()> start_simulation_callback_;
61
void
start_simulation_callback_ros_(
62
const
std::shared_ptr<std_srvs::srv::Trigger::Request>,
63
std::shared_ptr<std_srvs::srv::Trigger::Response>);
64
65
std::function<void()> stop_simulation_callback_;
66
void
stop_simulation_callback_ros_(
67
const
std::shared_ptr<std_srvs::srv::Trigger::Request>,
68
std::shared_ptr<std_srvs::srv::Trigger::Response>);
69
70
public
:
71
SimulatorServer() =
delete
;
72
SimulatorServer(
const
SimulatorServer&) =
delete
;
73
80
SimulatorServer(
const
std::shared_ptr<Node> &node,
81
const
std::string topic_prefix=
"GET_FROM_NODE"
);
82
88
void
set_start_simulation_callback
(
const
std::function<
void
()>&);
89
95
void
set_stop_simulation_callback
(
const
std::function<
void
()>&);
96
102
bool
is_enabled
()
const
;
103
109
std::string
get_topic_prefix
()
const
;
110
};
111
112
}
sas::Object
Base class for SAS objects.
Definition
sas_object.hpp:40
sas::SimulatorServer::set_stop_simulation_callback
void set_stop_simulation_callback(const std::function< void()> &)
Register a callback executed when the stop service is called.
Definition
sas_simulator_server.cpp:88
sas::SimulatorServer::is_enabled
bool is_enabled() const
Query whether the server is enabled.
Definition
sas_simulator_server.cpp:93
sas::SimulatorServer::get_topic_prefix
std::string get_topic_prefix() const
Get the configured topic/service prefix.
Definition
sas_simulator_server.cpp:99
sas::SimulatorServer::set_start_simulation_callback
void set_start_simulation_callback(const std::function< void()> &)
Register a callback executed when the start service is called.
Definition
sas_simulator_server.cpp:84
sas_object.hpp
Base object class for identification and license utilities.
src
sas_common
include
sas_common
sas_simulator_server.hpp
Generated by
1.17.0