This tutorial demonstrates how to set up the Arduino development environment on the Raspberry Pi system. To complete this tutorial, you will need an Arduino development board, any model is fine; I am using the UNO. Below are the specific steps to set up the development environment:
The official download address for the Arduino IDE is: https://www.arduino.cc/en/Main/Software , since the Raspberry Pi’s CPU is an ARM chip, you need to choose the Linux ARM version when downloading the IDE. After downloading, you can use the scp command to send the downloaded IDE to the Raspberry Pi, or you can download it directly on the Raspberry Pi to save the step of sending it from Ubuntu.
Once the compressed package is sent to the Raspberry Pi, the first step is to decompress it with the following commands:
(1) xz -d arduino-1.8.1-linuxarm.tar.xz
(2) tar -xvf arduino-1.8.1-linuxarm.tar
After decompression, you will see the folder for arduino-1.8.1. Since the Arduino IDE does not require additional configuration, you can directly execute the Arduino executable file in the folder to start the IDE. After starting, you can perform some simple configuration of the IDE, and then you can upload a simple program to the Arduino board to test if the IDE is working properly.
Next, download the package responsible for communication between Arduino and ROS, called rosserial. The download command is: git clone https://github.com/ros-drivers/rosserial.git , and after downloading, you need to call catkin_make -j2 to complete the compilation.
After downloading and compiling the rosserial package, the next step is to install ros_lib into the Arduino development environment, specifically in the libraries directory under the Arduino directory in the home directory.
Once the ros_lib library is installed in the libraries, you can find ros_lib in the IDE by going to File->Examples. This way, we can directly write and compile ROS-related code in Arduino. Here, we find the helloWorld example code under ros_lib and upload it to the Arduino UNO board.
After the upload is complete, we need to test if the entire environment works correctly. First, start roscore on the Raspberry Pi, and then start the Arduino node with rosrun rosserial_python serial_node.py /dev/ttyACM0.
During the startup, an error indicating that diagnostic_msgs.msg is missing may occur, which is due to the common_msgs package not being installed. When we install ROS packages from source in the future, we may encounter various errors, so we need to find the corresponding dependency packages and download the source code for compilation based on the error messages. The command to download the common_msgs package is:
git clone https://github.com/ros/common_msgs.git
After downloading this source package, you will still need to recompile it, as shown in the following steps:
You still need to call catkin_make -j2 to compile. When starting the Arduino node, you need to source the devel/setup.bash script so that the newly compiled packages in the workspace can be called normally. At this point, you can start the Arduino node normally. You can check if the topics exist by using rostopic list and print the message content to see if it works correctly using rostopic echo.
Finally, by checking the printed messages in the chatter topic, it indicates that the Arduino can communicate normally with the ROS master node. Thus, the setup of the Arduino development environment on the Raspberry Pi is complete.
If you want to view the complete video tutorial, open: http://v.youku.com/v_show/id_XMjQ4MDQyOTU3Ng==.html on Youku. If you want to see more video tutorials, you can search for “ROS Classroom” on Youku to find more ROS video tutorials.