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.
Содержание 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...