You are on page 1of 7

Design, build, and test of an autonomous myRIO based Segbot (PDF Dow... https://www.researchgate.net/publication/283819798_Design_build_and_...

2015 American Control Conference


Palmer House Hilton
July 1-3, 2015. Chicago, IL, USA

Design, Build, and Test of an Autonomous myRIO Based Segbot


Matt Migchelbrink, Warren N. White, Lucas Gorentz, Jacob Wagner, and Brian Blankenau

978-1-4799-8686-6/$31.00 2015 AACC 2783

1 of 7 6/8/17, 12:51 PM
Design, build, and test of an autonomous myRIO based Segbot (PDF Dow... https://www.researchgate.net/publication/283819798_Design_build_and_...

978-1-4799-8686-6/$31.00 2015 AACC 2783

displacements are measured in the right hand sense about the used to create a detailed drawing of the Segbot. Part masses
y-axis. The system parameters used to describe the Segbot were measured using a laboratory balance. By finding the
geometry and other physical quantities are listed in Table 1. part volume from the CAD software, the density of the part
Z could be estimated. This allowed for the estimation of
inertial values and the mass center location. The Table 1
inertial quantities I1, I2, and I3 together with the length
z were found in this way. The procedure of mass, volume, and
z
density determination was performed for all Segbot parts.
-Axel center The Table 1 parameters Km, Kt, Ra, and J were found
-Pendulum COM through identification. The brushed DC motor torque is
K t ia
i
j
where is the developed torque in N-m and ia is the armature
y current in amps. The DC motor voltage is
X V i a R a K m
r y Y
l where V is the voltage across the motor in volts and is the
x
motor shaft angular position in radians.
x
V X i Y j
A regulated power supply provided a constant 12.08
volts to the motor driver. The duty cycle of a PWM input to
Figure 1: Segbot Coordinate Systems the motor driver was then varied from 0 to 1. The wheel was
Table 1: System Parameters allowed to spin freely while DC motor voltage and current
Symbol Description Value Units
were measured. Angular position was determined using an
J Mass Moment of Inertia for Wheel, Gearbox, and Motor 0.00157 kg-m
2
optical encoder and a discrete observer, using a fixed time
I1 Mass Moment of Inertia of Body and Wheels about x Axis 0.00153 kg-m2 step of 0.001 sec., estimated the motor angular velocity.
I2 Mass Moment of Inertia of Body about y Axis 0.00111 kg-m2
Mass Moment of Inertia of Body and Wheels about z Axis 0.00089 kg-m2
Motor characteristics were measured for two different
I3
W Distance between Wheel Centers 0.1639 m motor operating configurations. The first configuration
mw Wheel mass 0.0332 kg consisted of the wheel being placed in a locked rotor
R Wheel Radius 0.0508 m situation while various voltages were applied to the DC
mp Mass of Pendulum 1.2398 kg
motor. The corresponding current was measured from the
hc Distance from Axle Center to Pendulum Mass Center 0.0746 m
g Acceleration of Gravity 9.81 m/s2
motor driver. Then the wheel was allowed to spin freely. The
Km Back EMF Constant 0.594 V-s/rad corresponding current, voltage, and wheel speed were
Kt Torque Constant 0.594 N-m/amp measured.
Ra Armature Resistance 12.36 ohms The measurements from each motor configuration were
N Gear ratio 30
inserted into (2) to calculate the best guess for the motor
B. Dynamics parameters via a least squares technique. The resistance
given in ohms, while the back emf constant has the units of
The equations of motion were derived using Lagrangian volt-sec/rad. Table 1 shows the least squares analysis results.
mechanics in terms of two rigid body rotational angles, the
Because one motor model was desired, the least squares
two wheel angles, two X-Y axle center coordinates, and two
was performed together with data taken from both motors.
Lagrangian multipliers associated with the nonholonomic
Because SI units were used to find Km, the torque constant
constraint of the shaft center motion along the trajectory.
is the same value, but with units of N-m/amp.
The next step of the dynamic analysis is to reduce the The remaining unidentified Table 1 quantity is the motor,
number of variables. Note that the angle can be gearbox, and wheel collective mass moment of inertia. The
determined from the difference between the wheel Segbot was positioned so that the wheels were off the
displacements. Through substitution, the equations of ground. There is no translation and each wheel rotates
motion can be reduced to three second order, nonlinear freely. A motor torque balance is written. Eqs.(1) and (2) are
differential equations in time in terms of the tilt angle and applied to this dynamic model providing the relation
the wheel rotational displacements r and l. The derivation
Kt C R
details are contained in [4 ]. While the model development J Cd accel V d a K m

Ra
would be beyond the scope of a second controls class, the Kt
equations could be presented together with an outline of the where Cd is the viscous damping coefficient and J is the
derivation procedure. The end result would be to linearize collective inertia. Note that Ra, Kt, and Km were determined
the equations so that control design could be performed. earlier. Writing (3) in the frequency domain yields
Kt
C. Identification
s Ra J b
The Table 1 parameters W, mw, R, mp, and g can be 2
s s b1
V s C R K tK m
directly measured. The CAD software Solidworks, the s s d a

Ra J
2 of 7 same software used in the undergraduate graphics class, was 6/8/17, 12:51 PM
Design, build, and test of an autonomous myRIO based Segbot (PDF Dow... https://www.researchgate.net/publication/283819798_Design_build_and_...

s Ra J b
The Table 1 parameters W, mw, R, mp, and g can be 2
s s b1
V s C R K tK m
directly measured. The CAD software Solidworks, the s s d a

Ra J
same software used in the undergraduate graphics class, was

2784

where the bi replace the ratios in the numerator and that are not part of the standard package. The IMU is one
denominator. Providing a voltage step and inverting the such device and more will be described later in this section.
resulting Laplace transform yields There are two main loops used in the LabView Virtua
b2 b2 b2 Instrument (VI). These loops are shown in Fig. 2. The first is
t V (5)
b1 t
t e a feedback acquisition loop. This loop runs on available
2 2
b1 b 1
b1
processor time. The main objective of this loop is to obtain
where t is the time in seconds, V is the magnitude of the and parse state measurements. The first loop runs faster than
voltage step input, is the base of the natural logarithms, the second loop. The purpose of the second loop is to realize
Cd Ra Kt Km , and Kt
. (6) the real-time control where feedb ack information is used
b1 b2
Ra J R aJ evaluate the control law and issue the necessary voltages
Again the least squares method is used to determine the through the D/A converters. The second loop also allows for
unknown constants b1 and b2. By knowing these two supervisory control where commands can be issued from the
constants, (6) provides an estimate for J. The estimate of the host computer to turn the controller on or off, change the
wheel position to a voltage step input is given by Equations nature of the control (tracking, stabilization, etc.), and
(5) and (6). Comparing (5) to the measured result is the least change control gains. The second loop executes at 100 Hz.
squares basis. The value of J is listed in Table 1. Software Organization
Untimed loop executes as fast as possible as the idle process
D. Linearized Dynamics
The dynamics of the Segbot were linearized about the Initialize the IMU on start-up
point where the lean angle and lean rate are both zero, and Read gyros and accelerometers
the rate of change of both wheels is equal. Let the state Read motor encoders
Communicate feedback to timed loop using
vector be specified as X r l r l T . The linearized

shared variables
state equations are

X r l r l T
A X Bu
Timed loop executes in real-time 100 Hz.
0 0 0 1 0 0 0 0

0 0 0 0 1 0 0 0 Receive shared
. (7)
0 0 0 0 0 1 0 0 r variable feedback MATL AB
Configure
X information script for
and create
0 0 141 .75 0 0 0 696 . 23 1248 .88 l User option on trajectory
PWM signals
0 0 141 .75 0 0 0 148 .88 696 .23 execution mode generation and

for motors
Read IR and sonar control
0 0 196 .43 0 0 0 372 .72 372 .72
sensors

E. Torque Control Figure 2: Control Code Structure


The voltage input is determined from the control law
torque values. The torque applied by the left and right Optical encoders are mounted on each motors. T
motors are used as inputs to the system as shown in (7). The resolution is 420 counts per rev. before the X4 quadrature
torque input can be converted to a voltage input through the decode. The acquisition and decode is performed by the
application of (1), (2), and using the desired torque and the FPGA. The wheel angle calculated by the state acquisition
motor angular velocity. Thus, the torque can be controlled loop is made a shared variable which means that it can
by the application of the correct motor DC voltage. passed to the second loop which calculates the control law.
A Pololu dual MC33926 motor driver is used to apply The state acquisition loop runs on available processor
the calculated voltages to the motors. The motor driver is time. I2C protocol is used to streamline data acquisition from
configured for a drive-brake operation. In this configuration a Sparkfun MPU 6050 3-axis accelerometer and
the current flows through the motor when the pulse width gyroscope. The FP GA had to be reprogrammed to allow for
modulation (PWM) motor input is high, and the leads to the the IMU. The gyroscope measurements are directly used
DC motor are shorted together when the PWM signal is low. estimate the pendulum body angular velocity. The estimate
This allows the linear relationship of Vout =Vs Din where of is calculated by a complementary filter of the form
is the duty cycle of the PWM motor input which ranges over actua l 0 .998 gyro 0 .002 accel (8)
0-1.0, Vout is the average voltage supplied to the DC motor,
and is the regulated motor driver supply voltage. where actual is the best estimate of , gyro is the sum of
previous actual and the gyroscope reading for multiplied
F. State Determination Loop the time step, and accel is the estimate of the pendulum ang
3 of 7 The myRIO has three data acquisition ports. The data given by the accelerometer readings. Complementary filte
6/8/17, 12:51 PM
Design, build, and test of an autonomous myRIO based Segbot (PDF Dow... https://www.researchgate.net/publication/283819798_Design_build_and_...

previous actual and the gyroscope reading for multiplied by


F. State Determination Loop the time step, and accel is the estimate of the pendulum angle
The myRIO has three data acquisition ports. The data given by the accelerometer readings. Complementary filters
acquisition is accomplished through an on-board field are widely used and the reader is encouraged to visit the
programmable gate array (FPGA) which has a factory webpage [5] for more information. The estimate for actual
shipped standard configuration or personality. This FPGA was also made a shared variable so it could be passed to the
can be reprogrammed to accommodate feedback transducers control loop.

2785

G. Timed Loop In implementation, the state feedback gains from (10


The second loop is a timed loop. The main purpose of could stabilize the Segbot. However, the values were altered
this loop is to allow the user the freedom to choose an slightly to yield a more desirable response. This process was
operating mode and conditions, calculate desired trajectories performed by varying the feedback gain values as the Segbot
if need be, and calculate the control law. Many individual operated by using the supervisory control functions on the
parameters are passed to the myRIO timed loop from the host computer. The final linear gains used to stabilize the
host computer using LabVIEW utilities. Also passed are the Segbot are
state measurements determined by the state acquisition loop. 0 0.12 10 .27 0.026 0 .14 0 .19
The control loop also has a discrete observer to estimate of K .(
the angular wheel velocities using the angular displacement 0 . 12 0 10 .27 0 .14 0 .026 0 .19

information passed via shared variables from the B. Trajectory Tracking


measurement loop to the timed loop. Currently, the IR and
Once the Segbot was stabilized, the main control design
sonar sensors are read in the timed loop.
task is the trajectory tracking control of the axle center.
The control law evaluation is performed in the second loop The nonholonomic relationships between the wheel
by a math script node which consists of a MATLAB script angular velocities and the global velocity, shown in Fig. 1
file. This provides convenience because the script file is are
easy to create and debug. This is the main function used in
R r l R r l
the timed control loop. A simple series of programming X cos andY sin . (1
statements can be used to affect the control output of the 2 2
timed loop, the simplest of which is the case of stabilizing The Segbot is a nonholonomic dynamic system and as
the Segbot. The MATLAB script is also used to implement result cannot move sideways without violating the
the tracking controller. Following the math script node, the nonholonomic constraint. In order to reduce the influence of
required pulse width modulated (PWM) signals are created disturbances on the tracking error, a navigational control
for the motor driver. must be added to the Segbot trajectory so the robot can
This control code started with a published NI example of eventually join the correct path. The navigational control
the myRIO being used with the Sparkfun MPU-6050 IMU. receives the current axle center position, heading direction,
The published code, documentation, and hardware details are and the desired trajectory. The navigational control then
found at: https://decibel.ni.com/content/docs/DOC-30443 produces a compensating angular velocity for each wheel so
that the path is regained. For the case of stabilization, the
desired velocities in the control loop are set to zero.
III. CONTROL ISSUES The derivation for the navigational control is rather
straight forward as outlined in [ 7]. A variation of
A. Stabilization derivation is presented here that produces better tracking.
Brysons rule [6] was used to determine an initial set of The development of the navigational control begins with an
linear state feedback gains to stabilize the dynamic system. object that is subject to the nonholonomic constraints of
The weighting matrices were defined as
1
x cos 0
v
y sin 0
2 0 0 0 0 0
(13)
max
1


0 0 0 0 0

2
max
0 1
1
0 0
where v is the translational speed, is the heading direction,
0 0 0
max
2

Q
1 and is the rate of change in heading. Fig. 3 shows
0 0 0 0 0

2
max
actual position of the object as a triangle.
0 1
0 0 0 0
max
2


0 0 0 0 0
1

(xd, yd)
2max
Y
and
1 0 1
(9)
R
4 of 7 0 1 b 2 6/8/17, 12:51 PM
Design, build, and test of an autonomous myRIO based Segbot (PDF Dow... https://www.researchgate.net/publication/283819798_Design_build_and_...

Y
and
1 0 1
(9)
R 2
0 1 b 2
where max = 10, max = 0.05, max = 10, max = 5, b2 is from
(6), and Vmax = 10 were used along with the MATLAB
command K=-lqr(A,B,Q,R) to determine the linear quadratic
regulator feedback gains of (x,y)
0 0 .047 8 .848 0 .035 0 .070 0 .290
K . (10)

0. 047 0 8 .848 0 .070 0 .035 0 .290 X
Figure 3: Navigational Control Posture Error

2786

The actual position of the object is (x, y, ) while the The trajectory tracking control has the same linear
desired position of the object is given by (xd, yd, d). feedback gains as the stabilizing control in (11). However,
The technique of [7] suggests defining the posture error rd = r and rd = r, while rd and ld are determined
as the error between the current coordinates and the desired
by the navigational control. For stabilization all of the
coordinates in the local body fixed coordinate system of the desired states in the navigational control are set to zero.
object being controlled shown in Fig. 3 as The last step is to choose gains for the ki that are used in
e d cos sin 0 x d x the navigational control. In [4 , 7] the gain k3 is set

P e l sin cos 0 y d y . (14) k 3 2 k2. Then appropriate gains must be found for the

other ki. The Segbot was given the figure-8 trajectory of
e 0 0 1 d
cos t cos t sin t
With some trigonometric simplifications the time Xd r and Yd r (
1 sin t 1 sin t
2 2
derivative of the vector in (14) can be written as
as the desired trajectory where is the angular frequency of
ed e l v v d sin e the figure-8 and 2r is the width across the figure-8. The

P el ed vd sin e (15) result in (20) can be differentiated to determine desired
trajectory time derivatives and the desired heading direction
e d
can be found by rearranging the nonholonomic constraint as
where is the position error measured along the local drive
1 Y
direction, is the position error measured in the local lateral tan . (21)

direction, e is the error in the heading direction, is the X
compensational translational speed found by the navigational
control, is the actual translational speed, and the subscript e IV. APPLICATIONS
stands for the desired coordinate minus the actual coordinate.
After the Segbot completes a few figure-8 revolutions to
The navigational control law is developed through a
overcome initial conditions, the trajectory converged to
Lyapunov argument. The candidate Lyapunov function is
steady-state path. The effects of changing and are
chosen as
shown in Figures 4 and 5. The intent of Figures 4 and 5 are
1 2 2 1 cos e to illustrate the influence of the control constants.
V ed el (16)
2 k2 k1=variable,k2=5,k3=2*sqrt(k2),k 4=0,k5=0
1.5

This can be observed to be non-negative in the errors and V


describes a positive definite system. The time derivative of 1
(16) while observing the results of (15) can be shown to be
sin e e
V ed ed e l el 0.5

2k2
Y Position (m)


e d e l v vd cos e el e d v d sin e (17) 0



sin e d . -0.5
Desired Path

2 k2 k1=0.1
k1=1.0
-1
The development in [4] proposes the control law of k1=0.3

v v d cos e k1 e d k4 e d el
2 -1.5 -1 -0.5 0 0.5 1 1.5
X Position (m)
5 of 7 6/8/17, 12:51 PM
Design, build, and test of an autonomous myRIO based Segbot (PDF Dow... https://www.researchgate.net/publication/283819798_Design_build_and_...

The development in [4] proposes the control law of

v v d cos e k1 e d k4 e d el
2 -1.5 -1 -0.5 0 0.5 1 1.5
X Position (m)

and
Figure 4: Effects of Modifying k1
d vd k 2 el k3 sin e k 5 sin e e l
2
(18)
The Segbot tracking can be improved by the proper gain
where the ki are all positive constants used as control choices as shown in Figure 6 which demonstrates that the
parameters. In [7] there are only three control parameters. new tracking control technique produces a better result.
Substituting the proposed control laws into the Lyapunov
time derivative shows V. SEGBOT CONSTRUCTION
k 5 sin e e l
2 2
k3
v d sin e
2
V k1e k 4 e e
2 2 2
(19) In building the Segbot, the aim was to replace
d d l
k2 k2 microcontroller. Use was made of the existing framework
which shows that V is positive definite and V is negative and peripheral parts described in [3]. Although we started
definite. In [7], V was only negative semi-definite. with the Segbot shell, many design changes were introduced
as the construction progressed. Fig. 7 shows the completed
device. Information, such as CAD drawings of the Segbot,

2787

pdf of the CAD drawings, a parts list, the LabVIEW behave similarly to the inverted pendulum cart which may be
controller, pictures, a wiring diagram, and video showing the better suited for an introductory controls class.
Segbot operation, is available at [8]. The LabVIEW environment allows a simplification of
programming and sensor interfacing details, an important
k1=0.3,k2=variable,k3=2*sqrt(k2),k4=0,k5=0
1.5 consideration for students to complete their projects in a
timely fashion. This simplification provides the opportunity
1
to concentrate on control issues. The material presented here
is better suited for a controls class as opposed to
mechatronics class because of the fewer interface details.
0.5
Y Position (m)

-0.5

Desired Path
k2=1.0
-1 k2=15.0
k2=5.0

-1.5 -1 -0.5 0 0.5 1 1.5


X Position (m)

Figure 5: Effects of Modifying k2

k1=1.1,k2=50,k3=2*s qrt(k2),k4=500,k5=100

1
Figure 7: Completed Segbot

0.5
VII. ACKNOWLEDGEMENTS
Y Position (m)

The authors gratefully acknowledge the KSU students:


0
Kris Larson and Skyler Butler for our website video, Sergio
Ortiz and Alan Ramirez for their creation and management
-0.5 of our website, and Cameron Lucero for the wiring diagram.

-1 Desired Path VIII. REFERENCES


Actual Path
[1] Hau-Shiue Juang an d Kai-Yew Lum, Design and C ontrol of a Two-
Wheel Self-Balancing Robot using the Arduino Microcontroller
-1.5 -1 -0.5 0 0.5 1 1.5
X Position (m) Board, 2013 10th IEEE International Conference on Control and
Automation (ICCA), June 12-14, 2013, pp. 634-639.
[2] He Bin, Liu Wen Zhen, an d Lv Hai Feng, The Kinematics Mode
6 of 7 Figure 6: Good Segbot Tracking Performance a Two-wheeled Self-balancing Autonomous Mobile6/8/17,
Robot and 12:51 PM
Design, build, and test of an autonomous myRIO based Segbot (PDF Dow... https://www.researchgate.net/publication/283819798_Design_build_and_...

X Position (m) Board, 2013 10th IEEE International Conference on Control and
Automation (ICCA), June 12-14, 2013, pp. 634-639.
[2] He Bin, Liu Wen Zhen, an d Lv Hai Feng, The Kinematics Model of
Figure 6: Good Segbot Tracking Performance a Two-wheeled Self-balancing Autonomous Mobile Robot and Its
Simulation, 2010 Second International IEEE C onference
Computer Engineering and Applications, pp. 64-68.
VI. CONCLUSIONS [3] The Segbot Home Page College of Engineering Control Systems
An autonomous Segbot has been built and tested. The Laboratory, http://coecsl.ece.illinois.edu/segbot/segbot.html,
robot was constructed with off-the-shelf parts and the cost accessed 03/15/2015.
[4] Matt Migchelbrink, Sliding Mode Control Trajectory Tracking
was kept to a minimum. The implementation of the NI Implementation on Underactuated Dynamic System, M.S. t hesis
myRIO as a microcontroller allows a convenient means of Mechanical a nd Nuclear Engr. Dept., Kansas State University,
WiFi communication between the robot and host computer. Manhattan, KS August, 2014.
The KSU Segbot resulted from the work of a group of [5] Gyroscopes and Accelerometers on a Chip,
http://www.geekmomprojects.com/gyroscopes-and-accelerometers-
undergraduates and one graduate student. Most of the on-a-chip/ , last accessed 03/15/2 015.
students volunteered their time in this effort. [6] G.F. Franklin, J.D. Powell, and A. Emami-Naeini, Feedback Control
This paper provides the details of model development, of Dyna mic Systems, Upper Saddle River, NJ: Pearson, 6th ed., 2010
identification, stabilizing control, and tracking control. p. 463.
[7] Y. Kanayama, Y. Ki mura, F. Miyazaki, and T. Noguchi, A Stable
The unique dynamics of the Segbot can appeal to a range Tracking Control Method for an Autonomous Mobile Robot, 1990
of students. The Segbot can provide an opportunity for IEEE International Conference on Robotics and Automation, May 1
graduate study in non-linear controls, digital controls, or 18, Cincinnati, OH, pp. 38 4-389.
nonholonomic tracking. If the dynamics are simplified so the [8] The KSU Mechanical and Nuclear En gr. Dept. Segbot Website -
left and right wheel turn together, the Segbot dynamics http://www.mne.ksu.edu/research/laboratories/dynamic-systems-
controls-laboratory-1/segbot, last accessed 03/15/2015.

7 of 7 6/8/17, 12:51 PM

You might also like