ros2_control - rolling
Loading...
Searching...
No Matches
ros2_control
controller_interface
include
semantic_components
led_rgb_device.hpp
1
// Copyright (c) 2024, Sherpa Mobile Robotics
2
//
3
// Licensed under the Apache License, Version 2.0 (the "License");
4
// you may not use this file except in compliance with the License.
5
// You may obtain a copy of the License at
6
//
7
// http://www.apache.org/licenses/LICENSE-2.0
8
//
9
// Unless required by applicable law or agreed to in writing, software
10
// distributed under the License is distributed on an "AS IS" BASIS,
11
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12
// See the License for the specific language governing permissions and
13
// limitations under the License.
14
15
#ifndef SEMANTIC_COMPONENTS__LED_RGB_DEVICE_HPP_
16
#define SEMANTIC_COMPONENTS__LED_RGB_DEVICE_HPP_
17
18
#include <string>
19
20
#include "semantic_components/semantic_component_command_interface.hpp"
21
#include "std_msgs/msg/color_rgba.hpp"
22
23
namespace
semantic_components
24
{
25
class
LedRgbDevice
:
public
SemanticComponentCommandInterface<std_msgs::msg::ColorRGBA>
26
{
27
public
:
39
explicit
LedRgbDevice
(
40
const
std::string & name,
const
std::string & interface_r,
const
std::string & interface_g,
41
const
std::string & interface_b)
42
: SemanticComponentCommandInterface(
43
name, {{name +
"/"
+ interface_r}, {name +
"/"
+ interface_g}, {name +
"/"
+ interface_b}})
44
{
45
}
46
59
bool
set_values_from_message
(
const
std_msgs::msg::ColorRGBA & message)
override
60
{
61
if
(
62
message.r < 0 || message.r > 1 || message.g < 0 || message.g > 1 || message.b < 0 ||
63
message.b > 1)
64
{
65
return
false
;
66
}
67
bool
all_set =
true
;
68
all_set &= command_interfaces_[0].get().set_value(
static_cast<
double
>
(message.r));
69
all_set &= command_interfaces_[1].get().set_value(
static_cast<
double
>
(message.g));
70
all_set &= command_interfaces_[2].get().set_value(
static_cast<
double
>
(message.b));
71
return
all_set;
72
}
73
};
74
75
}
// namespace semantic_components
76
77
#endif
// SEMANTIC_COMPONENTS__LED_RGB_DEVICE_HPP_
semantic_components::LedRgbDevice::set_values_from_message
bool set_values_from_message(const std_msgs::msg::ColorRGBA &message) override
Set LED states from ColorRGBA message.
Definition
led_rgb_device.hpp:59
semantic_components::LedRgbDevice::LedRgbDevice
LedRgbDevice(const std::string &name, const std::string &interface_r, const std::string &interface_g, const std::string &interface_b)
Constructor for an LED RGB device with interface names set based on device name.
Definition
led_rgb_device.hpp:39
Generated by
1.15.0