Skip to content

Commit fa85555

Browse files
committed
feat: make dds domainId configurable
1 parent a4e7bbc commit fa85555

6 files changed

Lines changed: 13 additions & 13 deletions

File tree

api/dsr_api.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,7 @@ DSRGraph::DSRGraph(GraphSettings settings) :
6565
std::cout << "Participant unmatched [" << info.participant_name.to_string() << "]" << std::endl;
6666
graph->delete_node(info.participant_name.to_string());
6767
}
68-
}));
68+
}), settings.domain_id);
6969

7070

7171
// RTPS Initialize publisher with general topic
@@ -122,8 +122,8 @@ DSRGraph::DSRGraph(GraphSettings settings) :
122122
qDebug() << __FUNCTION__ << "Constructor finished OK";
123123
}
124124

125-
DSRGraph::DSRGraph(std::string name, uint32_t id, const std::string &dsr_input_file, bool all_same_host)
126-
: DSR::DSRGraph(GraphSettings {id, 5, 1, name, dsr_input_file, "", all_same_host, GraphSettings::LOGLEVEL::INFOL})
125+
DSRGraph::DSRGraph(std::string name, uint32_t id, const std::string &dsr_input_file, bool all_same_host, int8_t domain_id)
126+
: DSR::DSRGraph(GraphSettings {id, 5, 1, name, dsr_input_file, "", all_same_host, GraphSettings::LOGLEVEL::INFOL, domain_id})
127127
{}
128128

129129

api/include/dsr/api/dsr_api.h

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -57,9 +57,9 @@ namespace DSR
5757
size_t size() const;
5858

5959
DSRGraph(GraphSettings settings);
60-
DSRGraph(std::string name, uint32_t id, const std::string& dsr_input_file = std::string(), bool all_same_host = true);
61-
[[deprecated("root parameter is not used anymore")]] DSRGraph(uint64_t root, std::string name, int id, const std::string& dsr_input_file = std::string(), bool all_same_host = true)
62-
: DSRGraph(name, id, dsr_input_file, all_same_host)
60+
DSRGraph(std::string name, uint32_t id, const std::string& dsr_input_file = std::string(), bool all_same_host = true, int8_t domain_id=0);
61+
[[deprecated("root parameter is not used anymore")]] DSRGraph(uint64_t root, std::string name, int id, const std::string& dsr_input_file = std::string(), bool all_same_host = true, int8_t domain_id=0)
62+
: DSRGraph(name, id, dsr_input_file, all_same_host, domain_id)
6363
{}
6464

6565
~DSRGraph() override;

api/include/dsr/api/dsr_graph_settings.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ struct GraphSettings {
1616
enum struct LOGLEVEL: uint8_t {
1717
DEBUGL = 0, INFOL, WARNINGL, ERRORL
1818
} log_level {LOGLEVEL::INFOL};
19-
19+
int8_t domain_id = 0;
2020
};
2121

2222
}

core/include/dsr/core/rtps/dsrparticipant.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ class DSRParticipant
1616
public:
1717
DSRParticipant();
1818
virtual ~DSRParticipant();
19-
[[nodiscard]] std::tuple<bool, eprosima::fastdds::dds::DomainParticipant *> init(uint32_t agent_id, const std::string& agent_name, int localhost, std::function<void(eprosima::fastdds::rtps::ParticipantDiscoveryStatus, const eprosima::fastdds::rtps::ParticipantBuiltinTopicData&)> fn);
19+
[[nodiscard]] std::tuple<bool, eprosima::fastdds::dds::DomainParticipant *> init(uint32_t agent_id, const std::string& agent_name, int localhost, std::function<void(eprosima::fastdds::rtps::ParticipantDiscoveryStatus, const eprosima::fastdds::rtps::ParticipantBuiltinTopicData&)> fn, int8_t domain_id=0);
2020
[[nodiscard]] const eprosima::fastdds::rtps::GUID_t& getID() const;
2121
[[nodiscard]] const char *getNodeTopicName() const { return dsrgraphType->get_name().data();}
2222
[[nodiscard]] const char *getRequestTopicName() const { return graphrequestType->get_name().data();}

core/rtps/dsrparticipant.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ DSRParticipant::~DSRParticipant()
3030

3131
}
3232

33-
std::tuple<bool, eprosima::fastdds::dds::DomainParticipant*> DSRParticipant::init(uint32_t agent_id, const std::string& agent_name, int localhost, std::function<void(eprosima::fastdds::rtps::ParticipantDiscoveryStatus, const eprosima::fastdds::rtps::ParticipantBuiltinTopicData&)> fn)
33+
std::tuple<bool, eprosima::fastdds::dds::DomainParticipant*> DSRParticipant::init(uint32_t agent_id, const std::string& agent_name, int localhost, std::function<void(eprosima::fastdds::rtps::ParticipantDiscoveryStatus, const eprosima::fastdds::rtps::ParticipantBuiltinTopicData&)> fn, int8_t domain_id)
3434
{
3535
// Create RTPSParticipant
3636
DomainParticipantQos PParam;
@@ -86,7 +86,7 @@ std::tuple<bool, eprosima::fastdds::dds::DomainParticipant*> DSRParticipant::ini
8686

8787
int retry = 0;
8888
while (retry < 5) {
89-
mp_participant = DomainParticipantFactory::get_instance()->create_participant(0, PParam, m_listener.get(), StatusMask::none());
89+
mp_participant = DomainParticipantFactory::get_instance()->create_participant(domain_id, PParam, m_listener.get(), StatusMask::none());
9090
if(mp_participant != nullptr) break;
9191
retry++;
9292
qDebug() << "Error creating participant, retrying. [" << retry <<"/5]";

python-wrapper/python_api.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -735,12 +735,12 @@ PYBIND11_MODULE(pydsr, m) {
735735
py::class_<DSRGraph>(m, "DSRGraph")
736736
.def(py::init([&](int root, const std::string &name, int id,
737737
const std::string &dsr_input_file = "",
738-
bool all_same_host = true) -> std::unique_ptr<DSRGraph> {
738+
bool all_same_host = true, int8_t domain_id = 0) -> std::unique_ptr<DSRGraph> {
739739
local_agent_id = id;
740-
auto g = std::make_unique<DSRGraph>(root, name, id, dsr_input_file, all_same_host);
740+
auto g = std::make_unique<DSRGraph>(root, name, id, dsr_input_file, all_same_host, domain_id);
741741
return g;
742742
}), "root"_a, "name"_a, "id"_a, "dsr_input_file"_a = "",
743-
"all_same_host"_a = true, py::call_guard<py::gil_scoped_release>())
743+
"all_same_host"_a = true, "domain_id"_a=0, py::call_guard<py::gil_scoped_release>())
744744
.def("get_agent_id", &DSRGraph::get_agent_id, "get agent_id")
745745
.def("get_agent_name", &DSRGraph::get_agent_name, "get agent_id")
746746
.def("get_node", [](DSRGraph &self, uint64_t id) -> std::optional<Node> {

0 commit comments

Comments
 (0)