CLEARPATH Turtlebot4 User Manual page 121

Table of Contents

Advertisement

Finally, we publish the message.
self.lightring_publisher.publish(lightring_msg)
Publish the lightring command with a button press
Now we can connect our interface button subscription to our lightring publisher. Simply call
button_1_function
inside the interface_buttons_callback.
# Interface buttons subscription callback
def interface_buttons_callback(self, create3_buttons_msg: InterfaceButtons):
# Button 1 is pressed
if create3_buttons_msg.button_1.is_pressed:
self.get_logger().info('Button 1
self.button_1_function()
Test this out by running the node like before.
Press button 1 and the lightring light should look like this:
Toggle the lightring
You will notice that once you have set the lightrings LEDs they will remain like that forever. Lets
make the button toggle the light on or off each time we press it.
Pressed!')
Lightring colours controlled with the press of a button!

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

This manual is also suitable for:

Turtlebot 4 lite

Table of Contents