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>
43#include <sas_robot_driver/sas_robot_driver_server.hpp>
44
45using namespace rclcpp;
46
47namespace sas
48{
49
58{
61
64
67
69 std::vector<double> q_min;
70
72 std::vector<double> q_max;
73};
74
83{
84private:
85 std::shared_ptr<Node> node_;
86
87 RobotDriverROSConfiguration configuration_;
88 std::atomic_bool* kill_this_node_; //Deprecated
89 std::shared_ptr<ShutdownSignaler> shutdown_signaler_;
90 std::shared_ptr<RobotDriver> robot_driver_;
91 Clock clock_;
92 RobotDriverServer robot_driver_server_;
93 bool watchdog_started_;
94 double watchdog_period_in_seconds_;
95 double watchdog_maximum_acceptable_delay_in_seconds_;
96 bool _should_shutdown() const;
97
98public:
99 RobotDriverROS(const RobotDriverROS&)=delete;
100 RobotDriverROS()=delete;
101
110 RobotDriverROS(std::shared_ptr<Node>& node,
111 const std::shared_ptr<RobotDriver>& robot_driver,
112 const RobotDriverROSConfiguration& configuration,
113 const std::shared_ptr<ShutdownSignaler>& shutdown_signaler_);
114
115 [[deprecated("Use RobotDriver(const std::shared_ptr<ShutdownSignaler>& shutdown_signaler_) instead.")]]
116 RobotDriverROS(std::shared_ptr<Node>& node,
117 const std::shared_ptr<RobotDriver>& robot_driver,
118 const RobotDriverROSConfiguration& configuration,
119 std::atomic_bool* kill_this_node);
120
125
134 int control_loop();
135};
136
137}
Definition sas_clock.hpp:46
ROS integration helper for a RobotDriver implementation.
Definition sas_robot_driver_ros.hpp:83
~RobotDriverROS()
Destructor; stops the control loop and performs cleanup.
Definition sas_robot_driver_ros.cpp:195
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:59
Timing utilities for control loops and statistics collection.
Abstract RobotDriver interface and watchdog support.
Cross-module shutdown signaling helper.
Configuration structure for RobotDriverROS.
Definition sas_robot_driver_ros.hpp:58
std::vector< double > q_max
Joint position maximum limits (q_max.size() == number of joints).
Definition sas_robot_driver_ros.hpp:72
std::string robot_driver_provider_prefix
Prefix that identifies the robot driver provider node/topic namespace.
Definition sas_robot_driver_ros.hpp:60
double watchdog_period_in_seconds
Watchdog period in seconds. If <= 0 the watchdog may be considered disabled.
Definition sas_robot_driver_ros.hpp:66
std::vector< double > q_min
Joint position minimum limits (q_min.size() == number of joints).
Definition sas_robot_driver_ros.hpp:69
double thread_sampling_time_sec
Control thread sampling time in seconds.
Definition sas_robot_driver_ros.hpp:63