I'm encountering a problem with a project we have to do for university. Our task is to build an autonomous robot, which collects coloured tin cans (3 kind of colors, size of a beer can) and brings them to different areas within a field of 2x2 meters, depending on the detected color.
We started small with a simple method to let the robot rotate and stop if it detects a can:
The problem now is that the angle between the object (can) and the robot itself are not properly aligned, apparently because of the ultrasonic signal diffusion.
The code lacks a correction functionality depending on the distance and effect of diffusion.
- Code: Select all
boolean minDistReached = false;
final int MINDISTANCE = 60;
int lastDistVal = 0;
while (!minDistReached) {
// Auslesen des usSensors
minDistReached = usSensor.getDistance() <= MINDISTANCE;
lastDistVal = usSensor.getDistance();
pilot.setRotateSpeed(18);
pilot.rotateRight();
}
pilot.stop();
Now we figured out a second problem. There will be walls around our 2x2m "robot field". So our robot also has to differ between walls and an actual object.
I tried implementing a method that reads the ultrasonic sensor's value twice with a delay of 100ms and calculates the delta value - this is done in a while-loop which is only left if the delta condition is true. If it's above a certain value, the methods breaks the loop, saves its heading and continues to turn until there is the next drop in the ultrasonic sensor's value, that is when the robot turns away from the object. Then it should stop again, save its position and correct the heading angle by half the amount of the difference and theoretically put the robot in a direct line facing the can. The whole thing with the Pilot / OdometryPoseProvider works, BUT ....
The whole thing works in theory, but actually we have a hard time finding the actual objects, because the "delta triggers" are not triggered. Mostly the reason is measurement errors because the tin cans don't reflect the signal properly. Also corners between two walls lead to heavy distortion.
Do you have any other ideas how we could properly solve this problem?
// Maybe there would be a possibility to check the Pose if it might be that the robot is "looking" into a corner and ignore those values. It might be quite complicated to realize, but just a thought .. I'm not sure whether it's worth an effort.
Thank you in advance!
Best
Aron
