lightring_msg.leds[
3
].blue =
255
;
lightring_msg.leds[
3]
.green =
0
;
// LED 4
lightring_msg.leds[
4
].red =
255
;
lightring_msg.leds[
4
].blue =
0
;
lightring_msg.leds[
4
].green =
255
;
// LED 5
lightring_msg.leds[
5
].red =
0
;
lightring_msg.leds[
5
].blue =
255
;
lightring_msg.leds[
5
].green =
255
;
}
// Lights are currently on
else
{
// Disable system override. The system will take back control of the lightring.
lightring_msg.override_system = false;
}
// Publish the message
lightring_publisher_
->
publish(lightring_msg);
// Toggle the lights on status
lights_on_ = !lights_on_;
}
Now the Create® 3 will regain control of the lightring if we press button 1 again.
Your first C++ Node
You have finished writing your first C++ node! The final
.cpp
file should look like this:
#include <chrono>
#include <functional>
#include <memory>
#include <string>
#include "rclcpp/rclcpp.hpp"
#include "irobot_create_msgs/msg/interface_buttons.hpp"
#include "irobot_create_msgs/msg/lightring_leds.hpp"
class
TurtleBot4FirstNode
:
public
rclcpp::Node
{
public
:
Summary of Contents for TurtleBot 4 Lite
Page 50: ...Running the Light Ring test...
Page 61: ...Adding Displays in Rviz2...
Page 63: ...Camera image displayed in Rviz2...
Page 82: ...TurtleBot 4 Lite with a NED2 arm...
Page 147: ...Color camera diagnostics...