0% found this document useful (0 votes)
72 views6 pages

Combining Raspberry Pi and Arduino To Form A Low-Cost, Real-Time Autonomous Vehicle Platform

Uploaded by

kartik rao
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
72 views6 pages

Combining Raspberry Pi and Arduino To Form A Low-Cost, Real-Time Autonomous Vehicle Platform

Uploaded by

kartik rao
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 6

2016 American Control Conference (ACC)

Boston Marriott Copley Place


July 6-8, 2016. Boston, MA, USA

Combining Raspberry Pi and Arduino to Form a Low-Cost, Real-Time


Autonomous Vehicle Platform
Ryan Krauss

I. A BSTRACT Another challenge associated with experimental con-


This paper presents a novel, low-cost autonomous ve- trol systems is choosing the right hardware/software
hicle platform based on the combination of a Raspberry combination to allow students to program and implement
Pi mini-computer, an Arduino micro-controller, and a the control law. Some researchers ask their students
Zumo track-driven robot chassis. The Arduino allows to program microcontrollers directly in C [11], [12],
the control law to be executed at hard real-time intervals while others seek to insulate students from traditional
while the Raspberry Pi provides additional computing programming entirely, relying instead on software that
power, a web interface, and wireless data-streaming allows a high-level description of the control law us-
for control tuning and debugging. The efficacy of the ing a block-diagram interface. There are commercially
platform in controls education is assessed after using available systems for real-time control using a block-
the platform for demonstration purposes in a first course diagram interface. Much work has also been done on
on feedback control. The entire system including the creating open-source, real-time systems [13], [14], [15].
Raspberry Pi and Arduino Uno costs roughly $215. Another hardware/software approach presented in the
literature combines a microcontroller with a computer
II. BACKGROUND AND L ITERATURE R EVIEW to create a real-time feedback control system [16], [17].
Feedback controls is a powerful and important subject The computer in this approach does not need to be run-
that can be challenging for students to learn. Controls ning a real-time operating system. The microcontroller
can come across as mathematically intensive and ab- enforces the real-time execution of the control law, reads
stract. Experimental projects and demonstrations can all of the sensor signals, and sends all of the actuator
increase students’ interest in controls and expose them signals while the computer provides a higher-level pro-
to the practical challenges of implementing control gramming language and additional computational and
systems [1], [2]. Experimental projects can also help memory resources.
students develop necessary skills for building and debug- This paper presents a low-cost platform for controls
ging control systems. In a 2009 IEEE Controls System education that possesses some unique strengths:
Society survey, 72% of industry respondents felt that • The total cost of the system including the robot
"hands-on experience" is the area that most needs to chassis, motors, Raspberry Pi, and Arduino is $215.
be strengthened to better prepare control engineers for • The Arduino/Raspberry Pi combination provides
successful careers [3]. hard real-time control at update frequencies of 100-
Setting up feedback control experiments can be chal- 150Hz.
lenging, especially if the control law needs to be exe- • The Raspberry Pi allows large amounts of data to be
cuted at hard, real-time intervals. There are many com- collected and wirelessly transmitted for each test.
mercially available real-time data acquisition and control • All of the software used is free and open-source.
solutions. Experiments based on these commercially • The user interface for the students can adjust from
available options have been used in controls courses and very simple to exposing all of the details of the
have been well-received by students [4], [5], [6]. integrated mechatronic system. Students in a first
Given the cost of engineering laboratories and the course on feedback controls can run tests using only
pressures on many university budgets, low-cost or stu- the simple web interface.
dent owned experiments have attracted some attention in
the literature. Several researchers have presented ideas III. I NTRODUCTION TO THE R ASPBERRY P I +
for low-cost or students-owned plants and investigated A RDUINO A PPROACH
how to use these plants to enrich controls courses and Raspberry Pi and Arduino are both popular and inex-
facilitate different pedagogical techniques [7], [8], [9], pensive boards for learning programming and allowing
[10]. user code to interact with real-world systems through

978-1-4673-8682-1/$31.00 ©2016 AACC 6628


various sensors and actuators. While Raspberry Pi and
Arduino are alike in size and cost, they are quite
different in what they are and how they are used.
An Arduino is a microcontroller programmed in C.
The primary way to interact with an Arduino is through
a serial-to-USB cable that sends ASCII characters. The
Arduino is a microcontroller and not truly a computer
and that leads to several advantages and limitations.
One of the primary advantages of a microcontroller
is that it can easily execute tasks at hard real-time
intervals based on a timer interrupt. An Arduino is also Fig. 1. The autonomous vehicle platform being presented in this
paper: a Zumo robot controlled by the combination of a Raspberry Pi
capable of interacting with many sensors and actuators and an Arduino.
directly through on-board analog-to-digital converters,
PWM generators, and pin interrupts for fast encoder
reading. An Arduino Uno has an 8-bit microprocessor to the blade. The cell phone charger is used to power
running at 16 MHz with 32 KB of flash memory and the Raspberry Pi via a USB cable. The Raspberry Pi is
2 KB of SRAM. attached to the Arduino using Velcro○ R
. The only other
In contrast, the Raspberry Pi is a mini-computer connection necessary is a USB cable from the Arduino
running a Linux operating system. The Raspberry Pi 2 to the Raspberry Pi for serial communication.
has a quad-core 900 MHz processor and 1 GB of RAM. Tabel I lists the components of the Zumo autonomous
The Raspberry Pi is primarily programmed in Python. vehicle platform and the cost for each at the time the
As a Linux computer, it is easy to remotely connect to paper was written.
a Raspberry Pi using SSH or VNC.
The Zumo Shield for Arduino is a small, track driven TABLE I
robot that is designed to plug directly into an Arduino C OMPONENTS OF THE Z UMO AUTONOMOUS VEHICLE PLATFORM
as a shield. The robot is roughly 10cm by 10cm and Component Price Source
costs roughly $100. The shield includes integrated motor Zumo Robot Chassis
drivers and a reflectance array used for line following (assembled with motors) $99.95 Pololu
applications. Combining the Zumo Shield with an Ar- Raspberry Pi 2 (Rev. B) $41.95 SparkFun
duino allows students who understand basic Arduino Arduino Uno $24.95 SparkFun
programming to work with line following control di- USB cable A to B 6" $4.99 Amazon
rectly on the Arduino. However, it is difficult to get USB cable A to micro B 6” $2.95 Amazon
large amounts of data from the Arduino to a computer 16 GB micro SD card $8.19 Amazon
wirelessly. Allowing students to view the sensor data vs. Edimax Wifi Adapter $9.99 Amazon
time is a key component in helping them learn to design RPi case (optional) $8.95 Amazon
and debug feedback control systems. Anker Battery (optional) $9.99 Amazon
This paper presents an approach for combining a AA batteries $2.00 Aldi
Raspberry Pi with an Arduino attached to a Zumo
total $213.91
Shield to create a line following autonomous vehicle
that returns large data sets for guiding student control
design.
V. R EAL -T IME C ONTROL A PPROACH
IV. S YSTEM D ESCRIPTION AND A SSEMBLY Figure 2 shows a block diagram of the Raspberry
Figure 1 shows the autonomous vehicle platform Pi and Arduino working together to create a versatile
being presented in this paper. The Arduino mounts real-time feedback control system. Either device could
upside down on top of the Zumo shield. The Zumo probably provide a decent control system by itself, but
shield includes a reflectance array sensor used for line the combination of the two provides some really useful
following. The Zumo robot is differential drive and the features. There are two primary drawbacks to using
motor drivers are integrated into the Zumo shield. In only the Arduino. First, the students would have to
order to assemble the platform as shown, two holes learn to program the Arduino directly in C. If the line
need to be drilled in the blade on the front in order following robot is simply being used to supplement a
to allow the cell phone battery charger to be zipped tied traditional first course in automatic controls, this level

6629
u v Motor
− controller PWM
serial Drivers
error Reflectance
Raspberry Pi signal Array
(Python) Arduino Zumo Shield

Fig. 2. Block diagram showing the Raspberry Pi and Arduino working


together to create a real-time feedback control system.

of microcontroller programming may be too much. The


bigger issue is that using the Arduino by itself makes
it very difficult to stream data back to a computer
for control tuning, debugging, and other educational
purposes. The addition of the Raspberry Pi solves these
problems by providing an easy-to-use web interface and
Fig. 3. Screen-shot of the simple web interface for running a test.
wifi connections via SSH or VNC.
Alternatively, it may also be possible to control the
Zumo robot using only a Raspberry Pi. However, the
first press the Open Serial button to initialize the USB-
Zumo chassis is designed as an Arduino shield. This
to-serial connection between the Raspberry Pi and the
means that the electrical connecitons assume the pinout
Arduino. Once the serial connection is established, the
of the Arduino and the example code for reading the
students go back to the main page and press the Calibrate
sensor array and driving the motors is written for the
button. This button executes the calibration routine for
Arduino.
the reflectance array line sensor. During the calibration,
The synergistic combination of a Raspberry Pi and
the robot rotates in a circle and records values for
an Arduino allows the Arduino to control the real-time
the sensor array as it passes over the black line and
execution of the control law, read the sensor signals,
white background. The code for the calibration routine
and send the PWM signal to the motors. The Raspberry
is provided by Pololu, the maker of the Zumo shield.
Pi provides the web interface, the wifi connection,
Once calibration is done, the students can input the
additional computational power and RAM, and captures
PID gains and press the Run Test button. The robot then
data for tuning and educational purposes. The primary
drives around the track for one lap. At the conclusion of
limitation of this approach is that the USB-to-serial
the test, a graph of the reflectance array sensor error is
connection limits the digital control frequency to 100-
shown along with some summary data that includes the
150 Hz.
lap time and the total error from the reflectance array for
VI. S OURCE C ODE the lap. A screen-shot from a completed test is shown
The source code for this project is available on github: in Figure 4.
https://github.com/ryanGT/zumo_serial. The main Ar-
VIII. L ECTURE D EMONSTRATIONS
duino file is line_follower_RT/line_follower_RT.ino and
the main Raspberry Pi file is cherrypy_krauss_1.py. So far, the robot platform has been used in two
Running the Python file on the Raspberry Pi starts the lecture demonstrations as part of a first course on
web interface that is discussed in the next section. feedback controls. The first demonstration was designed
to show how feedback control can help systems reject
VII. W EB I NTERFACE disturbance inputs. The robot was tasked with driving
If the robot is being used in a mechatronics course straight down a board that had been deliberately tilted.
or an advanced digital control course, students could The control system would have to compensate for the
program the Arduino and/or the Raspberry Pi directly. lateral pull of the component of gravity acting down the
However, if the platform is being used in a first course slope of the roadway. The Zumo robot is shown on the
on automatic controls, it may be desirable to insulate laterally inclined roadway in Figure 5. In the first part
the students from microcontroller coding. To that end, of the demonstration, the robot is simply commanded to
a simplified web interface has been created. Figure 3 send the same voltage to both motors under open-loop
shows a screen-shot of the web interface for running control. Predictably, the lateral pull of gravity causes the
PID tuning tests. In order to run a test, the students robot to veer off the road. The reflectance array is used

6630
(a) (b)

Fig. 6. Starting and stopping points for the initial condition rotation
test.

input pulse
300

(counts)
250 u1
200
150 u2
100 u3
50
0
0 50 100 150 200
0

error (counts)
−500
Fig. 4. Screen-shot from a completed test using the web interface.
Multiplying the loop count n by the digital control time step dt gives −1000
time in seconds. The error is in counts and measures the line position
on the line sensor reflectance array.
−1500

−2000

−2500
0 50 100 150 200
Loop count n

Fig. 7. Open-loop test results for the initial condition rotation test.
Loop count n times dt gives time in seconds. The error equals zero
when the line is in the center of the reflectance array.

counts and 400 counts corresponds to full speed). The


widths of the pulses were tuned experimentally to get
the robot to finish the test with the line near the center
Fig. 5. Rear view of the Zumo robot on a roadway with a lateral of the reflectance array. Open-loop results are plotted in
incline. Figure 7.
Closed-loop results for the initial condition rotation
test are shown in Figure 8. During the demonstration,
for feedback control in the second part of the demonstra- students were asked what aspects of the response were
tion and the robot is able to easily stay on the roadway changing as the proportional gain K p was changed. The
to the end. A video of this demonstration was created connection between damping ratio and closed-loop pole
and posted online: https://youtu.be/rNm-AMTSUzU locations was discussed.
In a second lecture demonstration, the robot was The final use of the Zumo robot platform will be in
used to show that feedback can alter pole locations and a student control design competition later this semester
affect the transient response of a system. The robot was (probably Nov. 2015). Student teams will compete to
programmed only to rotate in place (i.e. no forward see who can minimize tracking error and lap time
velocity) and was placed so that the line was off to the simultaneously while the Zumo robot races around a
far corner of the reflectance array sensor. The starting small line-following track.
position for this demonstration is shown in Figure 6 (a).
The desired stopping point with the line near the center IX. A SSESSMENT P ROCEDURE AND R ESULTS
of the reflectance array is shown in Figure 6 (b). For the The Zumo robot was incorporated into a series of
open-loop part of the demonstration, different amplitude lectures that teach students the potential benefits and
pulses were given to the motor drivers (amplitude is in the risks of using feedback control. The effectiveness

6631
1000 30
Quiz 1
500 Quiz 2

Number of Responses
25
0 Quiz 3
error (counts)

20 Quiz 4
−500
Quiz 5
15 Quiz 6
−1000

−1500 10
Kp = 0.15
Kp = 0.35
−2000 5
Kp = 0.55
−2500
0 10 20 30 40 50 60 70 80 0
Loop count n open-loop closed-loop both neither

Fig. 8. Closed-loop test results for the initial condition rotation test. Fig. 9. Assessment results for pre/post quiz question 2: Which control
approach is affected more by disturbance inputs?

30
Quiz 1
of the demonstrations and lectures was assessed using Quiz 2

Number of Responses
25
a series of pre/post multiple choice quizzes. Quizzes Quiz 3
were administered at the beginning and end of three 20 Quiz 4
lectures. Two of the lectures included demonstrations Quiz 5
15
involving the Zumo robot while the third lecture did not; Quiz 6
it was a traditional lecture/discussion. Quizzes 1 and 2 10
were given before and after the lecture containing the
disturbance rejection demonstration. It is worth noting 5
that the disturbance rejection video that was posted
online was made available to the students after the first 0
open-loop closed-loop both neither
lecture demonstration (in between quizzes 2 and 3).
Quizzes 3 and 4 were given before and after the lecture Fig. 10. Assessment results for pre/post quiz question 3: Which
on how feedback can affect the transient response of a control approach can change the damping coefficient of a system?
system. Quizzes 5 and 6 were given before and after the
traditional lecture that focused on teaching students that
because feedback control can alter system pole locations a system? There is a significant jump in the number
it can also drive stable systems unstable. It should be of correct responses before and after the lecture and
noted that 33 students completed quizzes 1 and 2 while demonstration on this topic (from quiz 3 to quiz 4).
only 29 completed quizzes 3-6. So, for questions that Figure 11 shows the results for quiz question 5: Which
involve all 6 quizzes, it may be more meaningful to approach can change the poles of the system? There is
track the reduction in wrong answers than the increase a significant increase in the number of correct responses
in correct answers. before and after the second lecture/demo covering the
effects of feedback on transient response.
Figure 9 shows the results for quiz question 2: Which
Figure 12 shows the results for quiz question 7:
control approach is affected more by disturbance inputs?
Which approach can drive a system unstable, i.e. cause a
While most students correctly guessed that disturbance
stable system to become unstable? The responses to this
inputs are a bigger problem for open-loop systems even
question show a considerable amount of confusion until
before the demonstration, there is still an increase in the
the final lecture that focuses on the connection between
number of correct answers after the demonstration (from
pole locations and system stability.
quiz 1 to quiz 2). A YouTube video was also posted after
the lecture and some of the students watched the video X. C ONCLUSIONS
before the next lecture. This may explain a reduction A low-cost platform for autonomous vehicle research
in the number of wrong answers between quiz 2 and and feedback controls education has been presented. The
quiz 3. platform costs $215 and is controlled by an Arduino Uno
Figure 10 shows the results for quiz question 3: Which and Raspberry Pi working together. The system is ca-
control approach can change the damping coefficient of pable of hard real-time control with update frequencies

6632
30
[4] Shiakolas, P. and Piyabongkarn, D., “Development of a Real-
Time Digital Control System with a Hardware-in-the-Loop Mag-
Number of Responses
25 netic Levitation Device for Reinforcement of Controls Educa-
Quiz 3 tion,” IEEE Transactions on Education, Vol. 46, No. 1, 2003,
20 Quiz 4 pp. 79–87.
[5] Kamis, Z., Topcu, E., and Yuksel, I., “Computer-Aided Auto-
Quiz 5
15 matic Control Education With a Real-Time Development Sys-
Quiz 6 tem,” Computer Applications in Engineering Education, Vol. 13,
No. 3, 2005, pp. 181–191.
10 [6] Salzmann, C., Gillet, D., and Huguenin, P., “Introduction to Real-
time Control using LabVIEW with an Application to Distance
5 Learning,” Int. J. of Engineering Education, Vol. 16, No. 5, 2000,
pp. 372–384.
[7] Reck, R. M. and Sreenivas, R. S., “Developing an Affordable
0 Laboratory Kit for Undergraduate Controls Education,” ASME
open-loop closed-loop both neither
Dynamic Systems and Controls Conference, 2014. Proceedings
of the 2014, ASME, Oct. 2014.
Fig. 11. Assessment results for pre/post quiz question 5: Which
[8] Reck, R. M. and Sreenivas, R. S., “Developing a new affordable
approach can change the poles of the system?
DC motor laboratory kit for an existing undergraduate controls
course,” American Control Conference (ACC), 2015, IEEE, 2015,
30 pp. 2801–2806.
[9] Reck, R. M., “BYOE: Affordable and Portable Laboratory Kit
for Controls Courses,” 122nd ASEE Annual Conference and
Number of Responses

25
Quiz 3 Exposition, 2015, Paper ID: 13467.
[10] Hill, R., “Hardware-based activities for flipping the system
20 Quiz 4 dynamics and control curriculum,” American Control Conference
Quiz 5 (ACC), 2015, IEEE, 2015, pp. 2777–2782.
15 [11] Jack, H. and Blauch, A., “A Modeling and Controls Course
Quiz 6 using Microcontrollers,” Proceedings of the 2004 ASEE Annual
Conference and Exposition, 2004.
10
[12] Jack, H. and Blauch, A., “A Modeling and Controls Course
using Microcontrollers,” Proceedings of the 2005 ASEE Annual
5 Conference and Exposition, 2005.
[13] Bucher, R. and Dozio, L., “CACSD under RTAI Linux with
0 RTAI-LAB,” Fifth Real-Time Linux Workshop, Valencia, Spain,
open-loop closed-loop both neither 2003.
[14] Dozio, L. and Mantegazza, P., “Real time distributed control
Fig. 12. Assessment results for pre/post quiz question 7: Which systems using RTAI,” Object-Oriented Real-Time Distributed
approach can drive a system unstable, i.e. cause a stable system to Computing, 2003. Sixth IEEE International Symposium on,
become unstable? IEEE, 2003, pp. 11–18.
[15] Bucher, R. and Balemi, S., “Scilab/Scicos and Linux RTAI -
A unified approach,” Control Applications, 2005. CCA 2005.
Proceedings of 2005 IEEE Conference on, IEEE, 2005, pp.
of 100-150 Hz. The system uses only free, open-source 1121–1126.
[16] Krauss, R. W. and Croxell, J. R., “A Low-Cost Microcontroller-
software. Students can run experimental tests using the in-the-Loop Platform for Controls Education,” American Control
platform through a simple web interface without having Conference, 2012. Proceedings of the 2012, IEEE, 2012.
to program the Arduino or the Raspberry Pi. At the [17] Krauss, R. W., “Evaluation of a Low-Cost Microcontroller for
Real-Time Control Education and Prototyping,” ASME Dynamic
conclusion of a test, students can download the real- Systems and Controls Conference, 2014. Proceedings of the
time data for the test. The system has been used in two 2014, ASME, Oct. 2014.
lecture demonstrations during a first course on feedback
controls. Assessment data from pre/post quizzes shows
that students are learning important feedback controls
concepts as a result of the lectures and demonstrations.

R EFERENCES

[1] Bernstein, D., “Enhancing undergraduate control education,”


Control Systems Magazine, IEEE, Vol. 19, No. 5, oct 1999,
pp. 40 –43.
[2] Bernstein, D., “Control experiments and what I learned from
them: a personal journey,” Control Systems Magazine, IEEE,
Vol. 18, No. 2, apr 1998, pp. 81–88.
[3] Cook, J. A. and Samad, T., “Controls curriculum survey: A CSS
outreach task force report,” Nov. 2009.

6633

You might also like