Hi! I am a semi new programmer making my final project for this year.
I have a Husky Lens AI camera thats capable to read AprilTags. I want to create a device that, as you walk, reads the AprilTags at intersections of a building. Then, using hardcoded directions, tell you which way to turn in order to get to your location.
I already have audio and detection working and I'm left with the hard part, pathfinding. The arduino knows where you start because of the reading of the AprilTags on the ground. You'd be able to tell where to go through some sort of interface. I thought about treating all these points (intersections and destinations) as points in an array. The array would look like this:
/*
________________________
|-23 -13 -3 7 17 27 37 |
|-24 -14 -4 6 16 26 36 |
|-25 -15 -5 5 15 25 35 |
|-26 -16 -6 4 14 24 34 |
|-27 -17 -7 3 13 23 33 |
|-28 -18 -8 2 12 22 32 |
|-29 -19 -9 1 11 21 31 |
|-30 -20 -10 0 10 20 30|
|____________^___________
Entrence
(floor 2 could just be +100 or smthn)
*/
As you can see, you enter at 0 and moving left is -10, right is +10, up is +1, and down is -1. This idea looks promising because now I can have a function the looks kinda like this (psudocode)
int NUM_ROOMS = 2;
int MAX_STEPS = 10;
int myPos = 0;
int roomToRoom[NUM_ROOMS / 2][NUM_ROOMS][MAX_STEPS]{ //We /2 b/c directions from room 2->1 is just 1->2 * -1. Thats a later problem
{ //Entrence
{} //Fill direction from entrence to entrence w/ 0
{1, 10, -1, 10, 1, -10}, //Up, Rht, Dwn, Rht, Up, Lft (directions from entrence (room 0) to room 1)
{10, -1, -10, -10, -1, 10}, //Rht, Dwn, Lft, Lft, Dwn, Rht (directions from entrence (room 0) to room 2)
}
// ... (and so on)
};
void direct(int currentPoint, int endingPoint){
//for now, we assume currentPoint is < NUM_ROOMS/2
for (int i = 0; i < MAX_STEPS; i++){
myPos += roomToRoom[currentPoint][endingPoint][i] // This is for the future where I can have changing directions mid path.
switch(roomToRoom[currentPoint][endingPoint][i])
case 1:
playSound("Fwd");
break;
case 10:
playSound("Rht");
break;
case -1:
playSound("Dwn");
break;
case -10:
playSound("Lft");
break;
}
}
The main jist of what I just wrote (please ignore any mistakes I made there) is that there will be 1 large, 3D array that will hold each room (first index) to another room (second index) and the directions (third index) from the first rom to the second. Then we can make a function that loops through the directions and plays the sounds. Obviously there is alot missing but its what I thought of.
Does anyone have any ideas how to do this better? It feels like alot of work but I can't see another way to do it myself. Any feedback or advice is appreciated.
EDIT: Yes I know if the "hight" of the space is >10 then it will break but in my case, it wont.