From 415f0e9ad5be9b1a8e07a44523892fe8cc4cb33a Mon Sep 17 00:00:00 2001 From: Oleg Kalachev Date: Fri, 15 Dec 2023 10:03:07 +0300 Subject: [PATCH] Use model name as topics namespace in simulation --- gazebo/flix.cpp | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/gazebo/flix.cpp b/gazebo/flix.cpp index c610704..acb27ff 100644 --- a/gazebo/flix.cpp +++ b/gazebo/flix.cpp @@ -205,11 +205,12 @@ public: void initNode() { nodeHandle = transport::NodePtr(new transport::Node()); - nodeHandle->Init(); // TODO: namespace - motorPub[0] = nodeHandle->Advertise("~/motor0"); - motorPub[1] = nodeHandle->Advertise("~/motor1"); - motorPub[2] = nodeHandle->Advertise("~/motor2"); - motorPub[3] = nodeHandle->Advertise("~/motor3"); + nodeHandle->Init(); + string ns = "~/" + model->GetName(); + motorPub[0] = nodeHandle->Advertise(ns + "/motor0"); + motorPub[1] = nodeHandle->Advertise(ns + "/motor1"); + motorPub[2] = nodeHandle->Advertise(ns + "/motor2"); + motorPub[3] = nodeHandle->Advertise(ns + "/motor3"); } void publishTopics() {