sas
Modularised monitoring, logging, and control of robots.
Toggle main menu visibility
Loading...
Searching...
No Matches
sas_robot_driver_ros.hpp
1
/*
2
# Copyright (c) 2016-2025 Murilo Marques Marinho
3
#
4
# This file is part of sas_robot_driver.
5
#
6
# sas_robot_driver is free software: you can redistribute it and/or modify
7
# it under the terms of the GNU Lesser General Public License as published by
8
# the Free Software Foundation, either version 3 of the License, or
9
# (at your option) any later version.
10
#
11
# sas_robot_driver is distributed in the hope that it will be useful,
12
# but WITHOUT ANY WARRANTY; without even the implied warranty of
13
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14
# GNU Lesser General Public License for more details.
15
#
16
# You should have received a copy of the GNU Lesser General Public License
17
# along with sas_robot_driver. If not, see <https://www.gnu.org/licenses/>.
18
#
19
# ################################################################
20
#
21
# Author: Murilo M. Marinho, email: murilomarinho@ieee.org
22
#
23
# ################################################################
24
# Contributors:
25
#
26
# 1. Juan Jose Quiroz Omana (juanjose.quirozomana@manchester.ac.uk)
27
# - Added the Watchdog functionality.
28
# - Renamed robot_driver_provider_ to robot_driver_server_
29
# - Added a new std::optional parameter in RobotDriverROSConfiguration to define the watchdog period
30
#
31
*/
32
33
#pragma once
34
35
#include <atomic>
36
#include <vector>
37
#include <memory>
38
39
#include <rclcpp/rclcpp.hpp>
40
#include <sas_core/sas_shutdown_signaler.hpp>
41
#include <sas_core/sas_clock.hpp>
42
#include <sas_core/sas_robot_driver.hpp>
43
#include <sas_robot_driver/sas_robot_driver_server.hpp>
44
45
namespace
sas
46
{
47
55
struct
RobotDriverROSConfiguration
56
{
58
std::string
robot_driver_provider_prefix
;
59
61
double
thread_sampling_time_sec
;
62
64
double
watchdog_period_in_seconds
;
65
67
std::vector<double>
q_min
;
68
70
std::vector<double>
q_max
;
71
};
72
80
class
RobotDriverROS
81
{
82
private
:
83
std::shared_ptr<rclcpp::Node> node_;
84
85
RobotDriverROSConfiguration
configuration_;
86
std::atomic_bool* kill_this_node_;
//Deprecated
87
std::shared_ptr<ShutdownSignaler> shutdown_signaler_;
88
std::shared_ptr<RobotDriver> robot_driver_;
89
Clock
clock_;
90
RobotDriverServer
robot_driver_server_;
91
bool
watchdog_started_;
92
double
watchdog_period_in_seconds_;
93
double
watchdog_maximum_acceptable_delay_in_seconds_;
94
bool
_should_shutdown()
const
;
95
96
public
:
97
RobotDriverROS(
const
RobotDriverROS&) =
delete
;
98
RobotDriverROS() =
delete
;
99
108
RobotDriverROS(std::shared_ptr<rclcpp::Node>& node,
const
std::shared_ptr<RobotDriver>& robot_driver,
109
const
RobotDriverROSConfiguration
& configuration,
110
const
std::shared_ptr<ShutdownSignaler>& shutdown_signaler_);
111
112
[[deprecated(
"Use RobotDriver(const std::shared_ptr<ShutdownSignaler>& shutdown_signaler_) instead."
)]]
113
RobotDriverROS(std::shared_ptr<rclcpp::Node>& node,
const
std::shared_ptr<RobotDriver>& robot_driver,
114
const
RobotDriverROSConfiguration
& configuration, std::atomic_bool* kill_this_node);
115
119
~RobotDriverROS
();
120
129
int
control_loop
();
130
};
131
132
}
// namespace sas
marinholab::sas::core::Clock
Clock utility for timing and statistics in control loops.
Definition
sas_clock.hpp:51
sas::RobotDriverROS::~RobotDriverROS
~RobotDriverROS()
Destructor; stops the control loop and performs cleanup.
Definition
sas_robot_driver_ros.cpp:265
sas::RobotDriverROS::control_loop
int control_loop()
Run the control loop.
Definition
sas_robot_driver_ros.cpp:79
sas::RobotDriverServer
Server interface for robot driver ROS topics.
Definition
sas_robot_driver_server.hpp:57
sas::RobotDriverROSConfiguration
Configuration structure for RobotDriverROS.
Definition
sas_robot_driver_ros.hpp:56
sas::RobotDriverROSConfiguration::q_max
std::vector< double > q_max
Joint position maximum limits (q_max.size() == number of joints).
Definition
sas_robot_driver_ros.hpp:70
sas::RobotDriverROSConfiguration::robot_driver_provider_prefix
std::string robot_driver_provider_prefix
Prefix that identifies the robot driver provider node/topic namespace.
Definition
sas_robot_driver_ros.hpp:58
sas::RobotDriverROSConfiguration::watchdog_period_in_seconds
double watchdog_period_in_seconds
Watchdog period in seconds. If <= 0 the watchdog may be considered disabled.
Definition
sas_robot_driver_ros.hpp:64
sas::RobotDriverROSConfiguration::q_min
std::vector< double > q_min
Joint position minimum limits (q_min.size() == number of joints).
Definition
sas_robot_driver_ros.hpp:67
sas::RobotDriverROSConfiguration::thread_sampling_time_sec
double thread_sampling_time_sec
Control thread sampling time in seconds.
Definition
sas_robot_driver_ros.hpp:61
src
sas_robot_driver
include
sas_robot_driver
sas_robot_driver_ros.hpp
Generated by
1.17.0