EasyManua.ls Logo

CLEARPATH Turtlebot4 - Page 116

Default Icon
153 pages
Print Icon
To Next Page IconTo Next Page
To Next Page IconTo Next Page
To Previous Page IconTo Previous Page
To Previous Page IconTo Previous Page
Loading...
ROS2 topic information
Test Create® 3 Button 1
Now that we are subscribed, lets test out our node by printing a message every time button 1 is
pressed.
Edit the interface_buttons_callback function to look like this:
# 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 Pressed!')
Now every time we receive a message the one /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 --symlink-install --packages-select turtlebot4_python_tutorials
source install/local_setup.bash