The Lightring Publisher Uses The Lightringleds Message Type; Add This Code Below Your Interface_Buttons_Callback - CLEARPATH Turtlebot4 User Manual

Table of Contents

Advertisement

Create a lightring publisher
Now that we can receive a button press, lets create a lightring publisher.
class TurtleBot4FirstNode(Node):
def __init__(self):
super().__init__('turtlebot4_first_python_node')
# Subscribe to the /interface_buttons topic
self.interface_buttons_subscriber = self.create_subscription(
InterfaceButtons,
'/interface_buttons',
self.interface_buttons_callback,
qos_profile_sensor_data)
# Create a publisher for the /cmd_lightring topic
self.lightring_publisher = self.create_publisher(
LightringLeds,
'/cmd_lightring',
qos_profile_sensor_data)
Note
The Lightring publisher uses the
Next, lets create a function that will populate a
Add this code below your
def button_1_function(self):
# Create a ROS2 message
lightring_msg = LightringLeds()
# Stamp the message with the current time
lightring_msg.header.stamp = self.get_clock().now().to_msg()
# Override system lights
lightring_msg.override_system =
# LED 0
lightring_msg.leds[0].red =
lightring_msg.leds[0].blue =
lightring_msg.leds[0].green =
LightringLeds
interface_buttons_callback
True
255
0
0
message type.
LightringLeds
message, and publish it.
function:

Advertisement

Table of Contents
loading
Need help?

Need help?

Do you have a question about the Turtlebot4 and is the answer not in the manual?

Questions and answers

Subscribe to Our Youtube Channel

This manual is also suitable for:

Turtlebot 4 lite

Table of Contents