Monday, April 7, 2014

Lab Session 7

Date: 04.04.2014
Duration of activity : 3 Hours
Group members participating: Lukas, Helene

Goals
  • Perform exercises from lab session 7
Plan
  • Add ultrasonic sensor, light sensor and bumper to the robot.
  • Observe the robot with a single behavior
  • Modify the observed behaviour
  • Observe the robot with multiple behaviors
  • Program the Escape behavior
  • Add third motor
  • Analyze Arbiter and Shared Car classes
Results

Single Behaviour: 

We added the light sensor, the ultrasonic sensor and the two pressure sensor for the bumper to the robot.

Then we uploaded the program RobotFigure9_3.java to the robot and ran it. With this program, the robot drove straigh ahead, until some big object was about 20 to 30 centimers in front of it. The robot then stopped, turned left and right and then drove further in to one of the two directions it just turned. Sometimes, the robot stopped again immediately, to turn left and right and change its direction again.This resulted in the robot avoiding some obstacles in front of it, like table legs and feet. When driving into a corner, the robot would just rotate left and right in the corner, without being able to escape.

To fix this behavior, we were tasked with changing the behavior to let the robot rotate 180 degrees, when something is in proximity, both when it turned left and right. We changed the program by adding a check, that if it turned left and right, and in both directions the ultrasonic sensor did detect something close by, we let the robot drive back a little and turn on the spot for about 2.25 seconds, which results in approximately a 180 degree turn. We also changed PrivateCar.java slightly, to make it possible to give negative values to the method forward(), to be able to turn on the spot, instead of turning with only one motor. Here and here are the files that were changed.


The changed section in RobotFigure9_3.java 

When using the modified program, the robot turned away, when it was stuck in a corner, or put very close to a wall or large objects and still avoided objects, when it detected that there was enough space in one direction.

The robot in action:
 

---------------------------------------------------------------------------------------------------------------------------
Multiple Behaviours:

In the next exercise, we were asked to observe the robots behavior, when running the program RobotFigure9_9.java. When letting the robot drive around in the lab, it behaved mostly liked it did at the very start of the lab session, it avoided objects and otherwise drove straight ahead, only this time, there were more pauses, where the robot would just sit and do nothing for a second or two.  Sometimes, it turned left and right and chose a new direction, without there being something in front of the robot. Other times, it would choose a new direction and drive much faster for a very short amount of time. This behaviour was the result of three different behaviors that could be triggered by different sensor inputs.
  • The Cruise behavior: Was always triggered and let the robot drive straight forward.
  • The Avoid behavior: Triggered when the ultrasonic sensor detects something being close. Turns the robot left and right and chooses a new direction.
  • The Follow behavior: Triggered when the lightsensor detects a value above a certain treshold. Turns the robot left and right and chooses the direction where the most intense light had been measured.
When we turned off the Avoid and Follow behaviors, the only behavior controlling the robot was the Cruise behavior, resulting in the robot only driving forwards and never turning.

When enabling the follow behaviour again, we used a mobile phone's LED as a lightsource and let the robot drive around in a darkened room. When pointing the light at the robots light sensor, it stopped and turned left and right, and then drove roughly in the direction of the lightsource, effectively following the mobile phone through the room. 

We were asked to implement a new behavior, the Escape behavoir, which uses the bumper on the pressure sensors to make the robot turn, when it drives into something the ultrasonic sensor could not detect. We implemented it slightly different to what was proposed in Mobile Robots on page 305. When both pressure sensors were pressed, our robot should back off and turn 180 degrees, instead of just making a 90 degree turn. When only sensor is pressed, the robot should back off and turn 90 degree away from where something pressed the sensor. The full behavior is implemented in Escape.java and the core part is shown here.
The Escape behavoir is then added to RobotFigure9_9.java by assigning a SharedCar which the behavoir can use, and starting it in its own thread. This is implemented in RobotFigure9_9-2.java. When running this program, the robot drives backwards and turns, when the bumber is pressed or the robot hits an object that the ultrasonic sensor did not sense. For now, the robot does turn by only using one wheel, and leaving the second wheel off, which requires more space than turning on the spot.

The behavior of the robot can be seen in this video:
 
We ran out of time at this point.

Conclusion

In this lab session we experimented with different behaviors that run in parrallel and successfully implemented the Escape behavior. The next thing we would like to do is to make the robot turn on the spot, which only requires small changes to the classes provided for the exercise. Building the robot with three motors, and the lightsensor on the third motor and changing the behaviors accordingly seems like an interesting task. Especially because this would make it possible to steer the robot more smoothly, instead of stopping and turning twice. The robot could just continue to drive, while the light sensor moves around and a behaviour changes the movement of the robot slightly based on the light sensors readings. An interesting challenge would also be to have the light sensor always point in the same direction and not "loose" a lightsource, while the robot turns beneath it.

References

No comments:

Post a Comment