| 180 | } |
| 181 | |
| 182 | void led_controller::LedController::handleLedsMsg(const led_msgs::LEDStateArrayConstPtr& leds) |
| 183 | { |
| 184 | std::lock_guard<std::mutex> lock(registryMutex); |
| 185 | for(const auto& led : leds->leds) |
| 186 | { |
| 187 | if (led.index < registeredLeds.size()) |
| 188 | { |
| 189 | auto color = GazeboColor(led.r / 255.0f, led.g / 255.0f, led.b / 255.0f); |
| 190 | auto ledPlugin = registeredLeds[led.index]; |
| 191 | if (ledPlugin) ledPlugin->SetColor(color); |
| 192 | } |
| 193 | } |
| 194 | } |
| 195 | |
| 196 | GZ_REGISTER_VISUAL_PLUGIN(sim_led::LedVisualPlugin); |