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_(
60
const
std::shared_ptr<std_srvs::srv::Trigger::Request>,
61
std::shared_ptr<std_srvs::srv::Trigger::Response>);
62
63
std::function<void()> stop_simulation_callback_;
64
void
stop_simulation_callback_ros_(
65
const
std::shared_ptr<std_srvs::srv::Trigger::Request>,
66
std::shared_ptr<std_srvs::srv::Trigger::Response>);
67
68
public
:
69
SimulatorServer() =
delete
;
70
SimulatorServer(
const
SimulatorServer&) =
delete
;
71
78
SimulatorServer(
const
std::shared_ptr<rclcpp::Node> &node,
79
const
std::string topic_prefix=
"GET_FROM_NODE"
);
80
86
void
set_start_simulation_callback
(
const
std::function<
void
()>&);
87
93
void
set_stop_simulation_callback
(
const
std::function<
void
()>&);
94
100
bool
is_enabled
()
const
;
101
107
std::string
get_topic_prefix
()
const
;
108
};
109
110
}
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: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
src
sas_common
include
sas_common
sas_simulator_server.hpp
Generated by
1.17.0