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
namespace
sas
37
{
38
47
class
SimulatorServer :
private
sas::Object
48
{
49
private
:
50
std::shared_ptr<rclcpp::Node> node_;
51
52
std::atomic_bool enabled_;
53
std::string topic_prefix_;
54
55
std::shared_ptr<rclcpp::Service<std_srvs::srv::Trigger>> service_server_start_simulation_;
56
std::shared_ptr<rclcpp::Service<std_srvs::srv::Trigger>> service_server_stop_simulation_;
57
58
std::function<void()> start_simulation_callback_;
59
void
start_simulation_callback_ros_(
const
std::shared_ptr<std_srvs::srv::Trigger::Request>,
60
std::shared_ptr<std_srvs::srv::Trigger::Response>);
61
62
std::function<void()> stop_simulation_callback_;
63
void
stop_simulation_callback_ros_(
const
std::shared_ptr<std_srvs::srv::Trigger::Request>,
64
std::shared_ptr<std_srvs::srv::Trigger::Response>);
65
66
public
:
67
SimulatorServer() =
delete
;
68
SimulatorServer(
const
SimulatorServer&) =
delete
;
69
76
SimulatorServer(
const
std::shared_ptr<rclcpp::Node>& node,
const
std::string topic_prefix =
"GET_FROM_NODE"
);
77
83
void
set_start_simulation_callback
(
const
std::function<
void
()>&);
84
90
void
set_stop_simulation_callback
(
const
std::function<
void
()>&);
91
97
bool
is_enabled
()
const
;
98
104
std::string
get_topic_prefix
()
const
;
105
};
106
107
}
// namespace sas
marinholab::sas::core::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:74
sas::SimulatorServer::is_enabled
bool is_enabled() const
Query whether the server is enabled.
Definition
sas_simulator_server.cpp:79
sas::SimulatorServer::get_topic_prefix
std::string get_topic_prefix() const
Get the configured topic/service prefix.
Definition
sas_simulator_server.cpp:84
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:70
src
sas_common
include
sas_common
sas_simulator_server.hpp
Generated by
1.17.0