In the last lecture you examined different techniques for feature extraction and, in particular, line detection and fitting. Remember from the lecture that when we speak of a feature, such as a line, we are interested in information in sensor data that is robust to variations in rotation and scale as well as noise. Since all sensors in mobile robots are prone to some degree of noise, we will focus on how to integrate multiple sensors to decrease the influence of noise and refine the accuracy of the robot’s world view. Although sensor fusion techniques will be the subject of much of the remaining course, today we will start simply, using only three of the infra-red distance sensors at a time. Your goal for this lab is to implement line detection to recognize the walls of the Ratslife world, and orient the E-Puck accordingly.
The E-Puck has eight distance sensors labeled “ps0” through “ps7”. They have the following bearings in degrees from the front of the E-Puck: , , , , , , , and , with “ps0” on a bearing of and “ps7” on a bearing of . To create, enable, and use a distance sensor, follow these steps:
//declare as a global variable above the constructor
//initialize in construtor
myDistSensor = getDistanceSensor("ps0”);
//use .getValue() in methods to get the value of the sensor
double someDistance = myDistSensor.getValue()
The following additional information was taken from the DistanceSensor page of the Webots Reference Manual. “This device simulation is performed by detecting the collisions between one or several sensor rays and the bounding objects of Solid nodes in the environment. A lookupTable is used for specifying the desired response curve and noise of the device. This table indicates how the ray intersection distances measured by Webots must be mapped to response values returned by the function getValue(). The first column of the table specifies the input distances, the second column specifies the corresponding desired response values, and the third column indicates the desired noise. The noise on the return value is computed according to a uniform random number distribution whose range is calculated as a percent of the response value. Let us consider an example,
The above lookup table means that for a distance of 0 meters, the sensor will return a value of 1000 without noise (0); for a distance of 0.1 meter, the sensor will return 1000 with a noise of up to 10 percent (100); for a distance value of 0.2 meters, the sensor will return 400 plus or minus up to 10 percent (40), etc. Distance values not directly specified in the lookup table will be linearly interpolated. Note that the input values of a lookup table must always be positive and sorted in increasing order. ”
The lookuptable for the E-Puck is:
You will need to use this lookuptable to do linear interpolation to find the actual distance in meters given the distance sensor reading. For example, if we receive a reading of 1000 we know this distance is somewhere between 0.02m and 0.03m. To find the exact distance, create a line between the points (2211, 0.02) and (306, 0.03) and then use your line to find the value at x = 1000, which is around 0.026m.
Getting Points from Distances:
The whole premise of line detection assumes that you have a point cloud derived from your sensors to which you will fit your line. This involves creating a point (x, y) from a distance given by a distance sensor. This point can be created, relative to the E-Puck, using the distance given, , and the angle, , of the sensor relative to the E-Puck's axis. For example, assume the robot is positioned at (0, 0) on the coordinate system and has received the distances , , and from the sensors “ps1”, “ps2”, and “ps3”. The sensor “ps1” is positioned from the front of the robot which means it is also from the horizontal axis of the robot. The sensor “ps2” is from the front of the robot which means it has an angle of relative to the horizontal axis. The third sensor, “ps3”, has an angle of from the front which means it has an angle of with respect to the horizontal axis. We can then use these angles from the horizontal to find the (x, y) point relative to the E-Puck by using sine and cosine. For example, the point given by “ps3” would be .
Detecting the Line:
Although the equations introduced in the lecture are more general (and more involved) for this situation involving only three sensors, we can use a simpler approach to finding the best-fit line. If you have the two outer points, you can fit a line through it, by finding m and b in the equation . You can then use the middle point to determine whether all three points are on the same line. The error between where the middle point actually lies and where the line indicates it should lie is given by the difference between these two values. If the error is too large, the three sensors do not see a line and the measurement should be rejected. Otherwise, the E-Puck can use this line to adjust its orientation. The orientation of the E-Puck relative to the wall that it detected is given , where is the slope of the line. The distance of the E-Puck from the wall is given by , where is the slope of the line, is the y-intercept of the line, and is the angle of orientation of the E-Puck.
For this lab we are going to venture into the Rats Life part of Webots. When you first start Webots, choose the Rats Life Contest window, this will open the Rats Life demo world. This world has a randomized maze and two E-Pucks along with their controllers. You can edit one of the controllers given or create a new controller to work with. When you first try and alter anything about this world, Webots will warn you that you are trying to overwrite one of their source files and will ask if you want to make a copy of the project outside the installation directory. You should choose YES to this and make a copy in your own folders to use for the remainder of this lecture.
1) Write an algorithm that uses the input from three of the distance sensors to detect the line corresponding to one of the E-Puck's neighboring walls. Use this line to print the E-Puck's orientation and distance with respect to the detected wall.
2) Some of you noticed in lab #6, path-planning, that the E-Puck slowly accumulated orientation errors as it progressed through the maze. Integrate your algorithm from 1) above into your controller for lab #6, path-planning, to help your E-Puck keep its correct orientation within each square as it moves toward its goal.