sas
Modularised monitoring, logging, and control of robots.
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
46namespace sas
47{
48
57{
60
63
66
68 std::vector<double> q_min;
69
71 std::vector<double> q_max;
72};
73
81class RobotDriverROS
82{
83private:
84 std::shared_ptr<rclcpp::Node> node_;
85
86 RobotDriverROSConfiguration configuration_;
87 std::atomic_bool* kill_this_node_; //Deprecated
88 std::shared_ptr<ShutdownSignaler> shutdown_signaler_;
89 std::shared_ptr<RobotDriver> robot_driver_;
90 Clock clock_;
91 RobotDriverServer robot_driver_server_;
92 bool watchdog_started_;
93 double watchdog_period_in_seconds_;
94 double watchdog_maximum_acceptable_delay_in_seconds_;
95 bool _should_shutdown() const;
96
97public:
98 RobotDriverROS(const RobotDriverROS&)=delete;
99 RobotDriverROS()=delete;
100
109 RobotDriverROS(std::shared_ptr<rclcpp::Node>& node,
110 const std::shared_ptr<RobotDriver>& robot_driver,
111 const RobotDriverROSConfiguration& configuration,
112 const std::shared_ptr<ShutdownSignaler>& shutdown_signaler_);
113
114 [[deprecated("Use RobotDriver(const std::shared_ptr<ShutdownSignaler>& shutdown_signaler_) instead.")]]
115 RobotDriverROS(std::shared_ptr<rclcpp::Node>& node,
116 const std::shared_ptr<RobotDriver>& robot_driver,
117 const RobotDriverROSConfiguration& configuration,
118 std::atomic_bool* kill_this_node);
119
124
133 int control_loop();
134};
135
136}
Clock utility for timing and statistics in control loops.
Definition sas_clock.hpp:49
~RobotDriverROS()
Destructor; stops the control loop and performs cleanup.
Definition sas_robot_driver_ros.cpp:226
int control_loop()
Run the control loop.
Definition sas_robot_driver_ros.cpp:84
Server interface for robot driver ROS topics.
Definition sas_robot_driver_server.hpp:58
Configuration structure for RobotDriverROS.
Definition sas_robot_driver_ros.hpp:57
std::vector< double > q_max
Joint position maximum limits (q_max.size() == number of joints).
Definition sas_robot_driver_ros.hpp:71
std::string robot_driver_provider_prefix
Prefix that identifies the robot driver provider node/topic namespace.
Definition sas_robot_driver_ros.hpp:59
double watchdog_period_in_seconds
Watchdog period in seconds. If <= 0 the watchdog may be considered disabled.
Definition sas_robot_driver_ros.hpp:65
std::vector< double > q_min
Joint position minimum limits (q_min.size() == number of joints).
Definition sas_robot_driver_ros.hpp:68
double thread_sampling_time_sec
Control thread sampling time in seconds.
Definition sas_robot_driver_ros.hpp:62