TurtleBot4FirstNode()
: Node(
"turtlebot4_first_cpp_node"
), lights_on_(
false
)
{
// Subscribe to the /interface_buttons topic
interface_buttons_subscriber_ =
this->
create_subscription<irobot_create_msgs::msg::InterfaceButtons>(
"/interface_buttons"
,
rclcpp::SensorDataQoS(),
std::bind(
&
TurtleBot4FirstNode::interface_buttons_callback,
this
, std::placeholders::_1));
// Create a publisher for the /cmd_lightring topic
lightring_publisher_ =
this->
create_publisher<irobot_create_msgs::msg::LightringLeds
>
(
"/cmd_lightring"
,
rclcpp::SensorDataQoS());
}
private
:
// Interface buttons subscription callback
void
interface_buttons_callback(
const
irobot_create_msgs::msg::InterfaceButtons::SharedPtr create3_buttons_msg)
{
// Button 1 is pressed
if
(create3_buttons_msg->button_1.is_pressed) {
RCLCPP_INFO(
this->
get_logger(),
"Button 1 Pressed!"
);
button_1_function();
}
}
// Perform a function when Button 1 is pressed.
void button_1_function()
{
// Create a ROS2 message
auto
lightring_msg = irobot_create_msgs::msg::LightringLeds();
// Stamp the message with the current time
lightring_msg.header.stamp =
this->
get_clock()
->
now();
// Lights are currently off
if
(!lights_on_) {
// Override system lights
lightring_msg.override_system = true;
// LED 0
lightring_msg.leds[
0
].red =
255
;
Содержание TurtleBot 4 Lite
Страница 50: ...Running the Light Ring test...
Страница 61: ...Adding Displays in Rviz2...
Страница 63: ...Camera image displayed in Rviz2...
Страница 82: ...TurtleBot 4 Lite with a NED2 arm...
Страница 147: ...Color camera diagnostics...