ukmars / ukmarsbot-mazerunner

Older Code for UKMARSBOT running in a classic micromouse maze - now deprecated
MIT License
37 stars 9 forks source link

Mazerunner cell size setting #6

Closed tunutmaz closed 2 years ago

tunutmaz commented 2 years ago

Hello. Where is the cell size of the maze adjusted in the Mazerunner code? We are working on a maze solving robot with a cell size of 200mm. Where do you use the size of the cell in the code, we would be very happy if you could help us with this. Thank you in advance.

micromouseonline commented 2 years ago

That is a really interesting question.

Unfortunately, the answer is a bit embarrasing. The cell size is scattered in the code as a magic number in several places.

For example, in mouse.cpp you will find a function Mouse::run_in_place_turns(). In there are several calls liek move_forward(90, topSpeed, 0); which tell the mouse to move half a cell - 90mm.

If I get a chance, I will try and update the code to account for cell size. Meanwhile, you will need to search for the numbers 90 and 180 and judge whether these need to be changed.

The fault is mine for not being more flexible in the code.

micromouseonline commented 2 years ago

OK - so that may have been easier than I expected.

I just pushed up a branch called cell-size that should have all the changes. config.h has the cell size as a constant FULL_CELL and I think I have found the places where that needs to be used in the code.

Since it did not take long, I may have missed some so I would be grateful if you could grab that branch and test it to confirm that it is good. If so, I will merge it into the main branch.

tunutmaz commented 2 years ago

You are a marvel. I will inform you with the test results. Thank you very much for your interest.

micromouseonline commented 2 years ago

I shall create a pull request for the changes. Perhaps you could feedback through that?

On 14/04/2022 20:16, tunutmaz wrote:

You are a marvel. I will inform you with the test results. Thank you very much for your interest.

— Reply to this email directly, view it on GitHub https://github.com/ukmars/ukmarsbot-mazerunner/issues/6#issuecomment-1099544852, or unsubscribe https://github.com/notifications/unsubscribe-auth/AAFC3KWVOG5NIU6MH5SLI4LVFBVJ5ANCNFSM5TMH6EZQ. You are receiving this because you commented.Message ID: @.***>

-- Peter Harrison

tunutmaz commented 2 years ago

Hello Mr. Peter. The change you made solved our problem and the code is now more functional. Thank you very much for your help. Also, I have one more question for you. forward.start(-60, 120, 0, 1000); I guess the value -60 in the line is for the robot to go back from the cell center before going to the target. Does the value calculation also occur by adding 12mm of wall thickness to the BACK_WALL_TO_CENTER constant? We are very grateful to you for helping us with our questions about the code.

int Mouse::search_to(unsigned char target) { flood_maze(target); // wait_for_front_sensor(); delay(1000); enable_sensors(); reset_drive_system(); enable_motor_controllers(); if (not handStart) { forward.start(-60, 120, 0, 1000);

micromouseonline commented 2 years ago

that is great, i am glad that you are making progress.

That code is intended to make the robot back up to the wall behind it so that it starts from a known position in the cell.

Normally, a hand start would have the robot already placed there by the user. If the robot is auto-starting, it may have stopped a little out of place and so we cannot be certain of its position after turning around.

The distance it backs up is not critical - I don't really care about the wall thickness. It just needs to be more than the likely offset and slow enough that it does not push out a wall or bounce of awkwardly. Also, I hope that, if it is not correctly aligned, the extra motion will force it to straighten up against the wall. For this reason it is a goot idea to have the back end of the robot flat and wide enough for this self-alignment.

tunutmaz commented 12 months ago

Hello Peter. Our work and development on UKmarsbot continues. I have a new question for you. IR sensors and phototransistors are used as sensors in all micromouse robots we examined. These sensors are highly affected by the lights in the competition environment. What is the use of TOF sensors such as vl53l0x instead of these sensors? The reading speed of these sensors is 20ms, but your Timer2 interrupt is 2ms. I think this temporal difference seems to be the biggest factor. We are curious about your experiences and opinions on this subject.

micromouseonline commented 12 months ago

The TOF snsors are far too slow for normal running. They can be useful during search if placed at the front of the mouse to detect wals a long way ahead but I think that is quite advanced stuff. For now, I would stick with the simple IR sensors.