Tuesday, August 31, 2010

NXT Tribot

The tribot was build exactly (99.99%, tell you what's not exact later) follows the Lego documentation, I used it to experiment how things are detected using the ultrasonic sensor. While thinking for the project, I read Krystian Majewski article about a NXT radar, it inspire me to make the tribot scan its surroundings, look for an object and then go and grab it. Just want to share it here for all the fun I have in making it.

After I build the tribot, I have an idea of scanning the surroundings with the ultrasonic sensor and look for something, say, within 10 inch of distance. I first tried to do this by incrementing the B/C motors a degree a time and scan the distance, however, it seems that the data read back fluctuates a lot and it is difficult to determine when it "sees" an object. To get better understanding of the problem, I build a simple program in NXT-G to control the B/C motors to rotate slowly and scan the readings, save them to a file in the NXT and uploaded to my PC, plot them using Excel and the graph on the right is what I found.




Then I tried another approach, the B/C motors were controlled to rotate anitclockwise slowly, at the same time, scans the surroundings for objects with distance less than 10 inch. This is not accurate and it only serves to get a rough starting point, then, I use an iteration method to converge the result. The purpose is to find the point where the ultrasonic cone first intersects the object edge, then we will rotate the robot a known amount so that the robot faces the center of the object and grab it.


When the first point was found, the robot is stopped immediately. Depends on the speed of motors and other unknown reasons, the first point could be close to the edge of the object or already get inside the object a certain amount.










The robot is then rotated back (clockwise) a certain angle, check the ultrasonic again to see if it intersect the object. If intersection occurs, it means that the robot overrruns too much before detecting the object the first time. As a result, our next rotation should be also clockwise with the same angle as we have to find a point where the ultrasonic cone does not intersect the object.



If no intersection occurs, it means that the object edge is somewhere between this point and the point we first found it in our previous step. We shall then rotate anti-clockwise for half the amount and check again for intersection.



We can summarize the method as below:


1) Rotate anticlockwise to find the first point

2) Rotate clockwise for a certain degree and scan, if intersect, further rotate the same degree clockwise and scan again, until we found the point with no intersection.

3) If step 2 does not intersect, rotate it anti-clockwise for half the angle in step 2 and check ultrasonic distance. If no intersection, repeat again until we found intersection point. If intersection occurs, rotate it clockwise for half the angle and check for ultrasonic intersection.

4) Steps 2 and 3 are repeated according to the result of ultrasonic intersection with the object. It will eventually converge to a point where the robot motors no longer rotate.

The video below shows how it happens.



I take a small bottle as object for grabbing, the blue ball which comes with the nxt kit is too short, and ultrasonic sensor did not detect the ball well. I put a few coins inside the bottle to make it heavier, so that it will not fall down when the tribot collide with it. The bottle I use is a bit too tall for the purpose, and hit against the ultrasonic sensor when the tribot approach it, but I don't have a right size one at home.

A minor modification to the tribot is to remove the orange color part in the grab area (see picture below the right one), so that it grabs the bottle better.



After having all the fun with the iteration method, I summarize my discoveries here:


1) Ultrasonic sensing does not provide an accurate or sharp data on the border of the object, the accuracy is even worst when detecting distance while the robot is moving.

2) A flat smooth floor is can avoid getting extra noise (although they are always there) and confuse the sensor reading.

3) To run the robot at low speed, you have to use the motor block with motor power control selected. Otherwise, the motor may not move at all. Motor power control is only available on the motor block, but not the move block.

4) The program written detects only one of the edge of the object, and hardcode an angle to further rotate the motors so that it aligns with the center of the object. It is better to memorize the angle of the first edge found, and detect the second edge, then find the mid point of the object. It is difficult to do it now as using the NXT-G a more complicated program runs more slowly on my computer, also, without a compass sensor, just by memorizing the rotations of the motor cannot control it accurately (e.g. you record a +90 deg rotation, then you run a -90 deg rotation it does not go back to the exact orientation).

The NXT-G program is provided here, welcome any comments for improvement.



Angle of intersection

No comments:

Post a Comment