In this tutorial, we’ll show you how to connect Arduino to Leo Rover.
In this tutorial, we’ll show you how to connect Arduino to Leo Rover.
Before we get started, let’s say a few words about what Arduino actually is.
Arduino is an open-source electronic platform that allows users to easily access advanced technologies interacting with the physical world.
You might wonder what the point of having Arduino inside Leo Rover is. After all, isn’t the robot already equipped with a Raspberry Pi micro-computer?
Well, the simplicity of Arduino makes it more convenient for typical hardware projects. Arduino has analog capabilities that the Raspberry Pi lacks by default. Its flexibility allows you to work with almost any type of sensor.
Arduino speeds up the creation of simple projects that don’t require advanced software and a good Internet connection.
Let's not forget that behind the name "Arduino" hide many boards, so if you want to learn how to choose the best one for your project, look here. For our projects, we mostly use Arduino DUE.
Having finished the tutorial you'll know how to connect Arduino to the Leo Rover and use its potential to further improve your projects and make the development process of future projects a little bit faster.
We have created mechanical interfaces for Arduino DUE, which you can get here:
You'll need to press in ten M3, threaded heat-set inserts into the base part. This allows you to use M3x6 Allen screws to hold the Arduino securely. The cover is held by 4 screws of the same size.
Since Arduino Due has the largest footprint out of all the Arduino boards it should be pretty easy to adapt the provided Arduino DUE adapter models to fit other boards inside. All you need to do is use 3D CAD program like fusion 360 to change the way mounting holes for the board are positioned.
For most intents and purposes the only connection you need to provide is an USB connection between the board and the USB port at the top of the rover. However, you may want to provide the microcontroller, and the sensors that you are using, with external power source. For such cases powerbox addon might be a good choice.
There are several ways to integrate Arduino into the rover. From this tutorial, you’ll learn about two of them so that you can decide which one works best for you.
First, install Arduino IDE using any of those provided tutorials:
Then, you need to set up Arduino IDE (we’re using Arduino DUE which needs a special configuration in Arduino IDE).
To do so, do as follows: while in IDE, go to: tools -> Board -> Boards Manager
Type “DUE” in the search bar and install the latest version of Arduino SAM Boards (32-bits ARM Cortex-M3).
The next step is to take care of the board specific setup:
The easiest way to check if the board is working, is to use pre-created example codes. One of them is the blink sketch provided in the Arduino IDE examples.
Go to: File -> Examples -> 01.Basics and choose the Blink sketch
You should see something similar to this:
Now, you’ll have to verify the code and send it to the board. First, make sure the correct board and ports are chosen as shown below:
Now you can verify(1) and upload(2) the code.
After a few seconds, you should see two things:
Unplug the Arduino from your computer and move it to the rover’s USB Port.
With this step, you have moved all of your Arduino functionality to a battery-powered mobile development platform.
First connect to the rover via Remote Desktop and connect the rover to the network (see Prerequisites).
Now, install and set up Arduino IDE following instructions below:
Now, you need to extract the .tar file. To do so open new terminal (ctrl + alt + t) and go to the downloads directory, and unpack the Arduino installation files with tar command.
You can see the unpacked files in the directory using ls command.
Now you need to move extracted files from Downloads directory, to /opt directory. To do so type (while being in Downloads directory):
Then you need to install the files. To do so go to the moved Arduino files in /opt directory and run install.sh script.
Arduino IDE should be installed and you should see new icon on the Desktop.
Now, connect Arduino to the rover. To do so, plug the USB cable in and then, open the Arduino IDE.
After that, set up the board specific options doing the following steps:
While in IDE, go to: tools -> Board -> Boards Manager
Type “DUE” in the search bar and install the latest version of Arduino SAM Boards (32-bits ARM Cortex-M3).
The next step is to take care of the board specific setup:
The easiest way to check if the board is working, is using pre-created example codes. One of them is the blink sketch provided in the Arduino IDE examples.
Go to: File -> Examples -> 01.Basics and choose the Blink sketch
You should see something similar to this:
Now, you’ll have to verify the code and send it to the board. First, make sure the correct board and ports are chosen as shown below:
Now you can verify(1) and upload(2) the code.
After a few seconds, you should see two things:
First step is to download the rosserial library.
Go to: tools -> Manage Libraries
Type “rosserial” in the search bar and download Rosserial Arduino Library
The board that we are using - Arduino Due - needs one additional step in order to properly work with rosserial.
Find ArduinoHardware.h
From this point forward, most of our instructions will be rephrased instructions made by wiki.ros.org. You can check this site for more detailed instructions.
In the first tutorial, you can see how to get data from Arduino to the rover’s mind
You can get to the sample code by following the path shown below
Upload the code to Arduino. Make sure to use the correct PORT and BOARD in Arduino.
Then, start a new terminal window and launch rosserial node, that will start communication between Arduino and the rover's onboard computer.
Start another terminal window and check the list of running nodes (you should see your node there)
You can get more information about your node - eg. what topics it is listening/publishing to. As you can see, /Arduino_COM_node is publishing to /chatter topic
You can also see list of all active topics (You should see one called “chatter” that was created by Arduino after you’ve created the node you’ve named)
Now to see data published to our topic, type in the terminal
In this example, we will show you our real live use case of Arduino with LeoRover.
Our task was to check whether there is a correlation between soil quality and motor current in Leo Rover pulling a plow. Therefore we have designed a lowered plow, capable of gathering pulling force data and drove Leo Rover through soil of different quality, while gathering the data. And in the end, we could analyze gathered data.
The Plow is connected to the rest of the rover with a strain gauge beam. Pulling force can be observed as tiny changes in voltage, that get amplified with an amplifier. Arduino is used to gather the data and send it to the computer.
With the code imported to Arduino and all the necessary wires connected, you can start the Arduino node. To do so, open new terminal and type
In another terminal run
You’ll see a graph following the changes in sensor output.
Sending either True or False to plow_control topic controls the plow position for us (either lowered or raised) for you it can control any binary device e.g. turn the LEDs on and off. You can send those messages by typing in the terminal
Or
For instructions related to data recording refer to this site. And If you want to make recordings easier to use, you can change .bag files to .csv files by following this tutorial.
If you want to Learn more about working with ROS (e.g. make arduino node start on Leo Rover startup) check this tutorial.
You can also find other ideas and tutorials here: