Robotics

Smiley face

Today Monday November 3, 2014 was our first day of working with robotics.
We used a LEGO NXT robot kit. We built the robot pictured above in less
than five minutes. After we built it we dual booted into Ubuntu to use
python. We put the mac address of our robot into the python demo file that
Mark Miller made. We turned on our robot and we ran the demo file which
automatically made the computer search and connect to the robot by using
bluetooth. After the computer connected to the robot we could control the
robot by typing in commands. We typed in "bot.forward()" and it made the
robot go forward. We could type in a number in the parenthesis to make the
robot go faster or slower. We also typed in "bot.right()" to make the robot
turn to the right. If we changed the word "right" to "left" in the command
we could make the robot turn to the left. If we put a number in the parenthesis
that number would be the amount of time that the robot would turn.

Smiley face

Smiley face

Today we worked on our robots again. We installed python 2.6 to try to get
the robots to work. After messing around with python we got them to work.
My group and I used the code pictured above to make a square. We had to
first tell the robot to go forward and then tell it to stop and turn. This
was not like the turtles module because we couldn't just tell it to turn because
it would not listen until you tell it to stop and then to turn.

Smiley face

Today we continued to work on our robots. Today we used an ultrasonic sensor
and a touch sensor. To do that we had to use the code pictured above that Mark
Miller made. It is just making variables for us so that we don't have to type
that out all the time.

Smiley face

After copying and pasting the code I started creating the code that would
make the bot wander around without crashing. As you can see pictured above
I first made a function called move. I then made a repeat loop that would
repeat whatever code was in front of it. I then made variables for the
commands that tell the robot to check how far whatever object was in front
of the sonar and the command that tells the robot to check if the touch
sensor was pressed. I then told it that if the distance of whatever object
was in front of the sonar was greater than or equal to 25 to go forward and
then stop and sleep. I then told it that if the distance was less than 25 to
go back and sleep and then turn right and sleep and then stop. This whole block
of code made the robot stop and turn and go forward every time it was going to
crash. This code did not make the robot go forward smoothly. It made it go
forward a little and stop the whole time.

Smiley face

I then wanted to add a touch sensor and make it so that every time the touch
sensor was activated the robot would completely stop. As pictured above this
was really simple. I just told it hat if the touch sensor was activated to stop.
I ended this program by putting move() so that the program automatically starts
when you run the program. One problem that I faced was that I was not formatting
my code correctly. It would not work until Dillon told me that it was not organized
correctly.