From 9c3a97f9451ae504fed9748329606639d3505b1d Mon Sep 17 00:00:00 2001 From: Oleg Kalachev Date: Tue, 15 Mar 2022 14:45:29 +0300 Subject: [PATCH] simulator: #435 fix working LED layer if there is no camera in the world --- clover_simulation/src/sim_leds.cpp | 17 +++++------------ 1 file changed, 5 insertions(+), 12 deletions(-) diff --git a/clover_simulation/src/sim_leds.cpp b/clover_simulation/src/sim_leds.cpp index 4dfa7123..e2d0b36f 100644 --- a/clover_simulation/src/sim_leds.cpp +++ b/clover_simulation/src/sim_leds.cpp @@ -73,16 +73,10 @@ public: ROS_INFO_NAMED(("LedController_" + robotNamespace).c_str(), "LedController has started (as %s)", role == Role::Client ? "client" : "server"); nh.reset(new ros::NodeHandle(robotNamespace)); - if (role == Role::Server) - { - setLedsSrv = nh->advertiseService("led/set_leds", &LedController::setLeds, this); - statePublisher = nh->advertise("led/state", 1, true); - } - else - { - // LED state should be published to the "led/state" topic, so we grab our data there - stateSubscriber = nh->subscribe("led/state", 1, &LedController::handleLedsMsg, this); - } + + setLedsSrv = nh->advertiseService("led/set_leds", &LedController::setLeds, this); // the newer service server would overwrite the previous one + statePublisher = nh->advertise("led/state", 1, true); + stateSubscriber = nh->subscribe("led/state", 1, &LedController::handleLedsMsg, this); }; ~LedController() @@ -101,8 +95,7 @@ public: ROS_DEBUG_NAMED(("LedController_" + robotNamespace).c_str(), "Registering LED visual plugin to %s (LED id=%d)", (role == Role::Client) ? "client" : "server", ledIdx); registeredLeds[ledIdx] = plugin; ledState.leds[ledIdx].index = ledIdx; - if (role == Role::Server) - statePublisher.publish(ledState); + statePublisher.publish(ledState); } void unregisterPlugin(sim_led::LedVisualPlugin* plugin)