sas
Modularised monitoring, logging, and control of robots.
Toggle main menu visibility
Loading...
Searching...
No Matches
sas_object_server_gazebo.hpp
Go to the documentation of this file.
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
35
36
#include <dqrobotics/DQ.h>
37
38
#include <gz/msgs.hh>
39
#include <gz/transport.hh>
40
41
#include <
sas_core/sas_object.hpp
>
42
#include <sas_common/sas_object_server.hpp>
43
44
using namespace
DQ_robotics;
45
46
namespace
sas
47
{
48
53
struct
ObjectServerGazeboConfiguration
54
{
55
std::string
set_pose_service_name
;
56
std::string
get_pose_topic_name
;
57
std::vector<std::string>
entity_names
;
58
};
59
67
class
ObjectServerGazebo:
private
sas::Object
68
{
69
private
:
70
class
PoseSubscriberSingleton
71
{
72
public
:
73
std::mutex msg_mutex;
74
void
_get_pose_subscriber_callback(
const
gz::msgs::Pose_V& msg)
75
{
76
std::unique_lock<std::mutex> lock(msg_mutex, std::try_to_lock);
77
if
(lock.owns_lock()) {
78
poses_from_gazebo_ = msg;
79
}
80
}
81
gz::transport::Node gazebo_node_;
82
gz::msgs::Pose_V poses_from_gazebo_;
83
};
84
85
static
std::unique_ptr<PoseSubscriberSingleton> pose_subscriber_;
86
std::shared_ptr<ObjectServer> object_server_;
87
88
std::string gazebo_entity_name_;
89
std::string gazebo_set_pose_service_name_;
90
91
gz::transport::Node gazebo_node_;
92
gz::msgs::Pose pose_to_gazebo_msg_;
93
DQ last_pose_to_gazebo_{0};
94
95
void
_set_pose_service_response_callback(
const
gz::msgs::Boolean&,
const
bool
);
96
public
:
97
ObjectServerGazebo() =
delete
;
98
ObjectServerGazebo(
const
ObjectServerGazebo&) =
delete
;
99
ObjectServerGazebo(ObjectServerGazebo&&) =
default
;
100
109
ObjectServerGazebo(
const
std::shared_ptr<ObjectServer>& object_server,
110
const
std::string& gazebo_entity_name,
111
const
std::string& gazebo_set_pose_service_name,
112
const
std::string& gazebo_world_dynamic_pose_topic);
113
120
void
update
();
121
};
122
123
}
124
sas::ObjectServerGazebo::update
void update()
Synchronize ObjectServer and Gazebo poses.
Definition
sas_object_server_gazebo.cpp:67
sas::Object
Base class for SAS objects.
Definition
sas_object.hpp:40
sas_object.hpp
Base object class for identification and license utilities.
sas::ObjectServerGazeboConfiguration
Parameters for ObjectServerGazebo.
Definition
sas_object_server_gazebo.hpp:54
sas::ObjectServerGazeboConfiguration::entity_names
std::vector< std::string > entity_names
Entity names managed by the node.
Definition
sas_object_server_gazebo.hpp:57
sas::ObjectServerGazeboConfiguration::get_pose_topic_name
std::string get_pose_topic_name
Gazebo topic used to read entity poses.
Definition
sas_object_server_gazebo.hpp:56
sas::ObjectServerGazeboConfiguration::set_pose_service_name
std::string set_pose_service_name
Gazebo service used to set entity poses.
Definition
sas_object_server_gazebo.hpp:55
src
sas_robot_driver_gazebo
src
sas_object_server_gazebo.hpp
Generated by
1.17.0