Introduction to Robotics

bouncerarcheryAI and Robotics

Nov 14, 2013 (3 years and 7 months ago)

63 views

Introduction to Robotics


Lecture 9: Reading and Writing Data

Location Mapping, Path Planning


Dr. Michael Hvidsten


United International College

Spring 2010


Storing Data


The BASIC Stamp’s program memory is
non
-
voltaile
. If we download a program to the CPU
and disconnect the power, the program will still
be in memory. As soon as we reconnect power,
the program starts running again from the
beginning.


Any portion of the program memory that is not
used for the program can be used to
store data
.
This
data will persist in memory
, even if power
is disconnected.

Storing Data


The chip on the BASIC Stamp that stores
program memory and data is called an
EEPROM
. EEPROM stands for
electrically
erasable programmable read
-
only
memory
.

EEPROM



We can view what is in the Basic Stamp
EEPROM by using the
Basic Stamp Editor
.





If we connect our
BoeBot

to the computer with
the USB cord and click on
Run
-
>Memory Map
a
window will open up as shown on the next slide.

EEPROM Memory Map



EEPROM Memory Map


The Memory Map uses different colors to show
how both the BASIC Stamp module’s RAM
(variables) and EEPROM (program memory) are
being used.

EEPROM Memory Map


The EEPROM Map has two graphs. Suppose a program
has been stored in the CPU. The bar at the far left
shows that only a small fraction of the program
memory is used to store the program.

EEPROM Memory Map


By scrolling to the bottom of the EEPROM Map’s main
window and counting the bytes highlighted in blue, we
see that only 101 bytes out of the 2048 byte EEPROM
are used for the current program. The remaining 1947
bytes are free to store data.

EEPROM Read,Write


The
WRITE

command is used to store values in
the EEPROM, and the
READ

command is

used to retrieve those values.


The syntax for the WRITE command is:


WRITE
Location, Data


Note
:
Location

= EEPROM memory location


Data

= data value in bytes



Example
: to write the value 195 to address 7 in
the EEPROM:


WRITE 7, 195

EEPROM Read,Write


Note
:
The largest byte value is 255. To write a value
larger than this, we need to use a
Word

value.


Word

values can be anywhere between 0 and 65565
while
Byte

values can only contain numbers between 0
and 255. A word value takes the space of two bytes.



If you want to write a
Word

size value to EEPROM, you
have to use the optional
Word

modifier

AND
you have
to skip one of the byte size addresses in EEPROM
before you can write another word.

EEPROM Read,Write


Example
: to write the values 345 and 400 to
EEPROM , beginning at address 7:



WRITE 7, WORD 345


WRITE 9, WORD 400


CAUTION:
It is possible to overwrite a program!
Make sure you know where the program resides
in memory and do not write data to those
memory locations !!!

EEPROM Read,Write


You can use the memory map to figure out the
highest value not used by your PBASIC program.




The numbers on the left side of the main
Memory Map (shown on the previous slides) are
hexadecimal numbers
, and 79A is the highest
value not occupied by a program token.

EEPROM Read,Write


Hexadecimal

means
base
-
16
, so 79A is:


7
×
16
2

+ 9
×
16 + A = 7
×
256 + 9
×
16 + 10
×
1


= 1946.



So,the

highest address we can use for storing
data is Address 1946.



You can also program the BASIC Stamp to make
this conversion for you using the
DEBUG

command’s

DEC

formatter and the
$

hexadecimal operator:


DEBUG DEC $79A

StoreLightMeasurementsInEeprom.bs2

EEPROM Read


The
READ

command is used to retrieve values from
the EEPROM.


The syntax for the READ command is:


READ
Location, Data


Note
:
Location

= EEPROM memory location


Data

=
variable

to store the value



Note
: As with the
WRITE

command, we can also
READ

Word size values (2 bytes).

ReadLightMeasurementsFromEeprom.bs2

Activity #1



Create a
photoresistor

RC circuit on IO pin 2.



Run StoreLightMeasurementsToEeprom.bs2



Gradually increase the shade over the
photoresistor

during the 2 ½ minute test period for meaningful data.




After the program has completed, disconnect and

reconnect the power supply to the
Boebot

and use the
MemoryMap

to confirm that the data is not erased
from the module’s EEPROM when the power is
disconnected.

Activity #1



Leave the
Boebot’s

power disconnected until you are
ready to run ReadLightMeasurementsFromEeprom.bs2;
otherwise, it will start taking measurements again.



Run ReadLightMeasurementsFromEeprom.bs2.




Compare the table that is displayed by this program
with the one displayed by

StoreLightMeasurementsInEeprom.bs2, and verify that
the values are the same.

Robot Navigation



A major area of research in robotics is that of
robot
navigation
. The major issue is how can we create and
program a robot to effectively move in its environment
and carry out its assigned set of tasks?


Examples:


Industrial Robots
: Robot arms must move in space to
construct cars, circuit boards, etc.



Service Robots
: A robot vacuum cleaner must move about
a room, avoiding obstacles.



Computer Animation
: Virtual humans (robots) must
interact with each other naturally, walking, running, falling,
etc.

Robot Navigation



Robot Navigation includes three major tasks:


Map Creation
: Robot creates an internal
mathematical representation (map) of its
surrounding environment.



Localization
: Robot identifies its location (
x,y,z
)
and orientation (rotation angles) within the map.



Path Planning
: Assigned a task of moving from one
position to another, robot uses its internal map to
plan the most efficient way to move, avoiding
obstacles in its path.

Map Creation



Robotic Mapping
deals with the construction of an
internal map that records the robot’s environment.



Three types of internal maps:


(1)
Dead
-
reckoning
: As it moves, the robot records
its position by counting the number of wheel turns
it has done. This gives the
absolute position
of the
robot.


Drawbacks
: This method is subject to
cumulative error

which can grow fast. Also, this
map
cannot identify obstacles
.

Map Creation


Three types of internal maps (continued):

(2)
Local Map
: Sensors of the robot, like a camera, a
microphone,
laser
,
sonar
, ... Provide a distance to
the robot in local coordinates.

Drawbacks
: Two
different places can be
perceived the same
. For example, in a building,
you can't know where you are using only local
information, because when you move to a
different floor, the halls, rooms, might look the
same.


Map Creation


Three types of internal maps (continued):

(3)
Global Map
: Usually Global Positioning System
based (GPS) map. GPS sensors determine positions
on a global coordinate system.

Drawbacks
: Sensors are very
expensive
, don’t
work in every environment (inside metal
buildings).


Localization



Localization

is almost always a by
-
product of the
creation of an internal map, as the robot uses itself as a
base for the coordinate system.

Path Planning



Path Planning

is the third component of Robot
Navigation and is by far the
hardest

component.



Example
: Consider a robot arm that has multiple
joints. To move the arm, you must decide how every
joint must move.

Path Planning



Movement through space of multiply jointed arms,
legs, etc, can be analyzed in two ways:



Kinematics


Given lengths of limbs and joint angles, determine the
final position of the end
effector
.



Inverse Kinematics (IK)


Given an end
effector

position, determine the possible
joint angles needed to reach that position.


These are important topics, covered in a more
advanced Robotics course (graduate school?)

Path Planning



We will consider a simpler path planning problem:

Given an initial robot position and a final
destination position, what is the best path for the
robot to take, making sure to avoid obstacles?



This is known as the
Piano Movers Problem
. It is also
the primary difficulty faces by the Mars Rover!


Activity #2: Path Planning



In this Activity we will look at a simple path planning
exercise for our
Boebots
. The goals of this Activity are:

(1)
Create a Local Map
of the
Boebot’s

environment, which will store distances to
obstacles.

(2)
Plan a path
that will take the
Boebot

to a
specified position, avoiding obstacles.

Activity #2: Path Planning



Tasks
:



Connect the Ping Ultrasound sensor
so that is facing
forward on the
Boebot
. (See Lecture 7 for a reminder
of how to use the Ping Sensor).



Create a program
that will do the following:



Have the
Boebot

rotate through angles 0, 45, 90,
135, 180, 225, 270, and 315 degrees. At each angle,
your program should record the Ping distance (in
cm) and store this distance in the EEPROM memory.



The distances will serve as a simple map of the
Boebot’s

environment, including obstacles.

Activity #2: Path Planning



Tasks
:



Select a position
behind one of the identified
obstacles.



Create a second program
that will make the
Boebot

move to the new position
, while
avoiding all obstacles.

For Fun



A fun application of the data storage capabilities of
the
BasicStamp

can be found in the book “
What’s a
Micro
-
Controller? Student Guide
ver

2.2
”. This book
can be accessed through the
Links

page on the course
web site.



In
Chapter #8: Frequency and Sound
, there are
activities to make the
Boebot

play music, using the
piezo
-
electric speaker and the Memory storage.