Now every time we receive a message on the
/interface_buttons
topic we will check if button 1
is pressed, and if it is then the node will print a message.
To test this out, we will need to build our package using colcon:
cd
~/turtlebot4_ws
colcon build
--packages-select
turtlebot4_cpp_tutorials
source
install/local_setup.bash
The
--packages-select
flag allows you to enter any number of packages that you want to build,
in case you don't want to build all packages in your workspace.
Now, try running the node:
ros2 run turtlebot4_cpp_tutorials turtlebot4_first_cpp_node
When you run it, nothing will happen until you press button 1 on your TurtleBot 4.
Press the button, and you should see this message in your terminal:
[INFO] [1652379086.090977658] [turtlebot4_first_cpp_node]: Button 1 Pressed!
Tip
Printing messages like this is a great way to debug your code.
Create a lightring publisher
Now that we can receive a button press, lets create a lightring publisher.
Need help?
Do you have a question about the Turtlebot4 and is the answer not in the manual?
Questions and answers