onsdag den 1. december 2010

LAB.10 - Bump car

Date: 18/11-2010
Group members participating: Brian, Michael
_____________________________________________
Schedule for the day
- Getting the sample bumpercar to work on the NXT

Problems and progress (notes):
  1. Press the touch sensor and keep it pressed. What happends ? Explain.
  2. Both DriveForward and DetectWall have a method takeControl that are called in the Arbitrator. Investigate the source code for the Arbitrator and figure out if takeControl of DriveForward is called when the triggering condition of DetectWall is true.
  3. Implement a third behavior, Exit. This behavior should react to the ESCAPE button and call System.Exit(0) if ESCAPE is pressed. Exit should be the highest priority behavior. Try to press ESCAPE both when DriveForward is active and when DetectWall is active. Is the Exit behavior activated immediately ? What if the parameter to Sound.pause(20) is changed to 2000 ? Explain.
  4. To avoid the pause in the takeControl method of DetectWall a local thread in DetectWall could be implemented that sample the ultrasonic sensor every 20 msec and stores the result in a variable distance accessible to takeControl. Try that. For some behaviors the triggering condition depends on sensors sampled with a constant sample interval. E.g. a behavior that remembers sensor readings e.g. to sum a running average. Therefore, it might be a good idea to have a local thread to do the continous sampling.
  5. Try to implement the behavior DetectWall so the actions taken also involve to move backwards for 1 sec before turning.
  6. Try to implement the behavior DetectWall so it can be interrupted and started again e.g. if the touch sensor is pressed again while turning.

Detailed description of solution
Finale Status:
- We downloaded the example code from the Behavior programming, and at first we got some problems that it seamed not to go into the driveforward, but we found the problem to be that one of the motors in driveforward was set wrong.

  1. When the touch sensor is pressed, it will execute the HitWall behavior, and in the event that it the touch sensor keep pressed, it will execute the HitWall behavior again and again until the touch sensor is released.
  2. From the source code, we can't see that DriveForward class is being called when DetectWall is called, because DetectWall take direct control over the motors.
  3. The way we implemented it, was to make an class that extende the ButtonListener, and made it active when ESCAPE was pressed. It works when it is avoiding an wall and when driving forward. When the ESCAPE button is pressed the program exits right away or as fast so we can't detect the differents.
  4. Done.
  5. Done, by using thread.sleep
  6. Without any change in the core behavior in DetectWall, we just added printout to the screen, we could see that the TakeControl is called about 7 times, every time the button is pressed. Further more we experienced that the we could interrupt the HitWall progress, by pressing the button while. This made it start over again.

Ingen kommentarer:

Send en kommentar