ROS 101: Monitoring a push button switch with the robot operating system

We can study the fundamentals and basic concepts of the robot operating system (ROS) using only an Arduino, a Raspberry Pi, and a tactile push button. With these electronic components, we can easily demonstrate the ROS concept of posting a topic when the tactile push button is pressed.

This hands-on tutorial, adapted from the wiki, takes several minutes to install and will display a True Where False boolean message on a Linux terminal.

The ROS model for posting the Boolean message is shown below:

The push button ROS circuit is quite simple in terms of the number of components. The circuit consists of a tactile pushbutton wired to digital pin 3 of an Arduino Uno. The tactile push button provides a weak digital logic signal activated by a software pull-up resistor of the Arduino code.

Here is a circuit diagram:

Here is also an equivalent electrical wiring diagram showing how to attach the tactile push button to an Arduino Uno:

The Arduino software code (sketch) to activate the pull-up resistor for the touch switch is provided below:

Once the electrical wiring from the touch button to the Arduino Uno is complete, the electronics prototyping platform can be connected to the Raspberry Pi 3 B + using a USB cable. Connector B mates with the Arduino. Connector A connects to the Raspberry Pi 3 B + USB port.

Here is the actual prototype of the ROS push button tutorial:

The next phase is to download the push button code to the Arduino. Once the Arduino Integrated Development Environment (IDE) is open, navigate to the Rosserial Arduino library. Use the mouse to select Button_ example.

To activate the ROS Master, subject monitoring (push) is triggered by pressing a tactile push button. Opening a Linux terminal and entering the ROS roscore command after the ($) prompt will launch the ROS master code for pushbutton monitoring.

To allow the establishment of the data communication between the ROS Master and the pushed subject, the command rosserial is then typed.

Opening a new Linux terminal window and entering the rosrun rosserial_python / dev / ttyACM0 command will establish a serial communication link between the ROS Master and the pushed subject.

The baud rate for this communication link is fixed at 56700 baud. The editor node will transmit the Boolean message True or False depending on the event or triggered state of the touch button.

An example of a ROS button session displaying the Boolean value when the tactile pushbutton is activated is shown in the following figure:

To display the Boolean data pushed from the published topic, another Linux terminal window is opened. After the prompt, type the command ROS high rostopic echo to display the Boolean data on the open Linux terminal window.

For further experimentation with this ROS monitoring application, we could replace the tactile push button with another electrical or electronic switching device such as the normally open (NO) or normally closed (NC) contacts of an electromechanical relay, or a digital transistor switch. You can also create a pull-down resistor by modifying the push button code previously displayed and observing the software behavior of the triggered switch.

For reference material on how to get started with ROS read the introduction Design News article here.

[All images courtesy Don Wilcher]

Don Wilcher is a passionate professor of electronic technology and an electrical engineer with 26 years of industrial experience. He has worked on industrial robotics systems, automotive electronic modules / systems and integrated wireless controls for small consumer devices. He is also a book author, writing DIY project books on electronic and robotic technologies.

Leave a Reply

Your email address will not be published.