sas
Modularised monitoring, logging, and control of robots.
Loading...
Searching...
No Matches
sas_object_server_gazebo.hpp
1#pragma once
2/*
3# Copyright (c) 2026 Murilo Marques Marinho
4#
5# This file is part of sas_robot_driver_gazebo.
6#
7# sas_robot_driver_gazebo 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_robot_driver_gazebo 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_robot_driver_gazebo. 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#include <dqrobotics/DQ.h>
29
30#include <gz/msgs.hh>
31#include <gz/transport.hh>
32
34#include <sas_common/sas_object_server.hpp>
35
36using namespace DQ_robotics;
37
38namespace sas
39{
40
42{
43 std::string set_pose_service_name;
44 std::string get_pose_topic_name;
45 std::vector<std::string> entity_names;
46};
47
49{
50 private:
51 class PoseSubscriberSingleton
52 {
53 public:
54 std::mutex msg_mutex;
55 void _get_pose_subscriber_callback(const gz::msgs::Pose_V& msg)
56 {
57 std::unique_lock<std::mutex> lock(msg_mutex, std::try_to_lock);
58 if (lock.owns_lock()) {
59 poses_from_gazebo_ = msg;
60 }
61 }
62 gz::transport::Node gazebo_node_;
63 gz::msgs::Pose_V poses_from_gazebo_;
64 };
65
66 static std::unique_ptr<PoseSubscriberSingleton> pose_subscriber_;
67 std::shared_ptr<ObjectServer> object_server_;
68
69 std::string gazebo_entity_name_;
70 std::string gazebo_set_pose_service_name_;
71
72 gz::transport::Node gazebo_node_;
73 gz::msgs::Pose pose_to_gazebo_msg_;
74 DQ last_pose_to_gazebo_{0};
75
76 void _set_pose_service_response_callback(const gz::msgs::Boolean&, const bool);
77 public:
78 ObjectServerGazebo() = delete;
81
82 ObjectServerGazebo(const std::shared_ptr<ObjectServer>& object_server,
83 const std::string& gazebo_entity_name,
84 const std::string& gazebo_set_pose_service_name,
85 const std::string& gazebo_world_dynamic_pose_topic);
86
87 void update();
88};
89
90}
91
Definition sas_object_server_gazebo.hpp:49
Definition sas_object.hpp:39
Base object class for identification and license utilities.
Definition sas_object_server_gazebo.hpp:42