sas
Modularised monitoring, logging, and control of robots.
Loading...
Searching...
No Matches
sas_force_sensor_client.hpp
1#pragma once
2/*
3# Copyright (c) 2020-2026 Murilo Marques Marinho
4#
5# This file is part of sas_force_sensor.
6#
7# sas_force_sensor 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_force_sensor 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_force_sensor. If not, see <https://www.gnu.org/licenses/>.
19#
20# ################################################################
21#
22# Author: Murilo M. Marinho, email: murilomarinho@ieee.org
23#
24# ################################################################*/
25
26#include <atomic>
27
28#include <dqrobotics/DQ.h>
29
30#include <rclcpp/rclcpp.hpp>
31#include <geometry_msgs/msg/wrench_stamped.hpp>
32#include <sas_core/sas_object.hpp>
33
34using namespace DQ_robotics;
35
36namespace sas
37{
46class ForceSensorClient: private sas::Object
47{
48private:
49 std::shared_ptr<rclcpp::Node> node_;
50
51 std::atomic_bool enabled_;
52 const std::string topic_prefix_;
53
54 rclcpp::Subscription<geometry_msgs::msg::WrenchStamped>::SharedPtr subscriber_wrench_;
55 DQ force_;
56 DQ torque_;
57
58 void _callback_wrench(const geometry_msgs::msg::WrenchStamped& msg);
59public:
60 ForceSensorClient() = delete;
61 ForceSensorClient(const ForceSensorClient&) = delete;
62
70 ForceSensorClient(const std::shared_ptr<rclcpp::Node>& node, const std::string& topic_prefix="GET_FROM_NODE");
71
77 bool is_enabled() const;
78
85 DQ get_force() const;
86
93 DQ get_torque() const;
94
100 std::string get_topic_prefix() const;
101};
102
103}
Base class for SAS objects.
Definition sas_object.hpp:40
std::string get_topic_prefix() const
Get the configured topic prefix.
Definition sas_force_sensor_client.cpp:83
DQ get_torque() const
Get the last received torque reading.
Definition sas_force_sensor_client.cpp:75
DQ get_force() const
Get the last received force reading.
Definition sas_force_sensor_client.cpp:67
bool is_enabled() const
Check whether the client has received at least one force/torque reading.
Definition sas_force_sensor_client.cpp:62