I have LEGO NXT and a square room of 100x100cm. I would like to use the center of the of the room always as my starting point(the black box). The green box is going to be my park area. Circles can be the random placed obstacles on my way. Red is the walls of the room. Objectives:

When starting no matter where the robot is, it should return to center, afterwards it should be able to park into the green box when requested.

In its returning center/home progress there can be obstacles on the way, I should try to overcome these obstacles and park successfully. The obstacles don't have to be circular, they can be square as well.

If there is an obstacle in the park/center area I should give an error not possible to park or abort the parking...

Worst case scenarios: Robot starting from the corner and obstacles on the way to park.
I'm using for the time being color sensor and ultrasound sensor, I can also add a gyro sensor but haven't made yet deep search about it. I also have RFID sensor but I think only with 2 transponders it wont help much.

My first challenge is without any obstacles for starters would be identifying the center to the robot, and it knows where it has to come from a random position. Any tips?

1 Answer
1

Position Your robot should be able to know where it is in the room. This can be achieved in a few ways:

Using the ultrasonic sensor as a sonar, rotating it around and storing the readouts, then calcualting based on the known map of the room (if the layout is fixed and known in advance).

Tracking the movements and calculating from the last known position. This method depends on how accurate are the starting data and the measurement of the movement. This also loses accuracy over time.

Placing unique markers along the floor or the wall that the robot can read. I don't know how could this be accomplished using LEGO pieces, but I wouldn't say it's impossible to do. However you could mark the two important locations (the green box and the center) to have an easy way to tell if you're at them.

Orientation Your robot should also know which direction is it facing. Most of the above methods offer a way to calculate this, but you could also use a compass sensor.

Knowledge of the environment Your robot should know if there is an obstacle in it's way. The random obstacles are by definition impossible to know in advance, so you'll need to detect them somehow.

You could use the aforementioned ultrasonic sonar, if the obstacles provide a good enough acho.

If the obstacles are made of a suitable material, you could try to use a color sensor to see if there is one in front of the robot

In theory you could try to measure the resistance of the motors when you try to drive into an obstacle but this might prove impossible, depending on the capabilities of the hardware and software sou are using. This method also makes it impossible to use the incremental location method.

Given these problems in my opinion your best bet would be a simpler, more brute force approach. Outlined in highly abstract pseudocode below:

going to the green target box:
while not in target area
while not at wall
if obstacle is in front of me: get around
else: move forward
end while // now you're at the wall
move forward along the wall
end while // now you're at the target
going to the center: // assuming you're at the green box
turn towards the center
while not at center:
if obstacle is in front of me: get around
else: move forward
if moved more than the journey should have taken: announce that you're stuck
end while // now you're at the center or lost

I would like to simplify my question. Im in the center, I made some movements, I just want to return to my starting position. I dont have a compass sensor. I read this could be possible with motor decoding but Im lost in this area...
–
AnarkieApr 30 '14 at 20:18

I can't seem to find the related documentation on retrieving the measurements of the encoders on the motors. But you could always approach the problem by keeping track of every movement the robot has made from the known starting position. Then when you have to turn around, you can simply replay the stored movements with the rotations inversed. So for example if you stored F10, R90, F25, L60, F20, you'd have to turn around (L180) and then follow your way back: F20, R60, F25, L90, F10.
–
zovitsMay 2 '14 at 12:27