torsdag den 16. december 2010

lab 14

Date: 2010-12-16 Thu
Attendances: Carsten, Dan
Duration: 9:15 - 16:00

Continuing project

Fixing Bluetooth trouble

Getting bluetooth communication working in our current code
framework. We fixed it by sending too long strings to force read() to
stop.

Bluetooth working with 2 robots

Behaviors

3 modes

  • Hunt: Killing other robots.
    • Uses distance sensor to detect how close to other robots.
    • If close enough, kills the other robot.
    • Cannot find food when in this mode (light sensor doesn't register
      it).
    • Light sensor still need to detect border.
    • Increase hunger.
  • Search: Searching for food.
    • Sonic sensor not used.
    • Uses light sensor to detect food.
    • Increase hunger.
  • Eat: Eating food.
    • In this mode after having found food.
    • Stands still and eats.
    • Decrease hunger.
  • Avoid: Don't move outside the level.
    • Simple sequence of moving backwards and turning around.

Personality

A robots personality is defined by:

  • Hunting Motivation: This determines how hungry the robot will get
    before stop hunting and start searching for food.
  • Eating Motivation: This determines how much the robot eats after
    having found a food-source.

Initial test

Our initial test with 1 robot and no avoidance gave some interesting
results. First of all, the robot moved way too fast. We need to have
the robots move as slow as possible to be able to see what they are
doing. Also, our initial guess at a personality gave a good mix of
hunting, searching and eating. It would hunt for a while, then god
hungry and go into search mode. And when finding something to eat it
would stay a eat for a good while before going back to hunting.

sensor reading interval

Our robot has a step-count of 0.5 seconds, this indicate when to
increase hunger. But 0.5 seconds is enough time for the robot to move
over a border or food without behaviors acting on it. So we simulated
concurrency with a busy-wait. We sleep 10 ms at a time and each time
check if a border or some food is detected. If detected the 0.5
seconds sleep is interrupted.

The reason this works is that only search and hunt can be
interrupted. And neither of those use any waiting. They just choose
new speed settings for the wheels. But avoid and eat do use
thread.sleep.

Track

We set up a track. A beige rectangle with gaffer's tape as an edge and
pieces of white paper signifying food.

Killing

We implemented the kill mechanics naively by checking if the distance
sensor detects something within 10 cm (or at least when the sonic
sensor returns a value less than 10). When a robot kills something it
will make a sound. It is up to the humans to detect and remove the
robot that was killed. Having a robot detect when it is killed is not
easy, and we decided to just emulate that behavior ourselves.

Track test

Our initial test with one robot with an average personality would run
around and hunt a bit. But spend most of its time searching and
eating. It stayed alive throughout the trial of 5 minutes or so. The
main problems was the robot would sometimes not detect edges properly
and run off the track, requiring help to get back. Another problem was
our pieces of paper were not taped down, causing the robot to move the
paper around confusing itself.

Personality

The PC can now transmit a new personality to a robot. This was
difficult as the NXJ doesn't report null pointer exceptions in its
threads.

torsdag den 9. december 2010

lab 13

Date: 2010-12-09 Thu
Attendances: Carsten, Dan
Duration: 11:15 - 16:15

Continuing project.

This week we implemented the score-based behavior controller.

The controller is very similar to the one from lab 10, except this one
assigns scores to each behavior, sorts the list and execute the
behavior with the highest score.

The main problem here is designing a robot with a behavior that has
some good middle-ground. Meaning simply having one of it's behavior
properties as high or low as possible always be the best option is not
a interesting problem.

We have ended up with a robot that sometimes searches for water and
sometimes hunts for other robots. When in search-mode it won't catch
other robots even if it bumps into one. When finding a source of water
(a patch of coloured paper on the ground) the robot stands still and
refills its energy. When in hunt-mode the robot goes faster and if it
bumps into another robot it kills it.

Our robots move around randomly. It does this by having 5 different
move modes (forward, slightly left, slightly right, sharply left,
sharply right). Each mode has a even chance of being selected. Each
mode runs in an some time interval, after which a new move-mode is
selected.

The basic premise of the robot is it has a hunger indicator. the
hunger indicator decreases over time. When a robot is hungry it
searches for food. When it is not hungry it hunts for other robots.

The track we imaging is a flat white area. It is surrounded by a black
edge. And food sources are grey pieces of paper. The light sensor can
be calibrated to indicate what is the track, the edge and food.

Hunting for other robots is done using the sonic distance sensor.

Log

We started by making the behavior controller

We then made some behaviors, and decided on hardware setup

We then made the logger. We had trouble with this. We stopped before
we figured it out.

classes

  • [X] Bluetooth
  • [X] PC logger (server)
  • [X] NXJ logger (client)
  • [X] score-based behavior controller
  • [X] behaviors
    • Move randomly (search)
    • Hunt
    • Eat (check light sensor, stop and eat if food is found and hunger
      is low enough)
  • [X] Hardware setup
  • [X] Light sensor values calibration
  • [X] Behaviors using sensors correctly
  • [X] Personality
  • [X] PC breeder (Personality merge)

torsdag den 2. december 2010

lab note 12, starting project bluetooth comminuaction

Attendances: Carsten, Dan
Duration: 11:15 - 15:00

Continuing project

Borrowed 2 standard robots.

classes

  • Bluetooth
  • PC logger (server)
    • Made initial server
    • uses ObjectInputStream to send object instances across Bluetooth.
    • Instances being sent implement Message.
  • NXJ logger (client)
    • Made initial client
  • score-based behavior controller
  • behaviors
  • PC breeder