11 added 106 characters in body edited Jun 22 '15 at 10:35 Muhammad Faique Shakeel 10588 bronze badges I'm working on an robot that would be able to navigate through a maze, avoid obstacles and identify some of the objects in it. I have a monochromatic bitmap of the maze, that is supposed to be used in the robot navigation. Up till now, I have converted/read the bitmap image of the maze into a 2D array of bits. However, now I need guidance on how to use that array to plan the path for the robot. I would appreciate if you could share any links as well, because I am new to all this stuff (I am just a 1st year BS electrical engineering student) and would be happy to have a more detailed explanation. If you need me to elaborate on anything kindly say so. I would be grateful! Here's the image of the maze. This is just a sample image; the robot should be able to work with any maze (image) with similar dimensions. And you are welcome! Thank you Chuck! UPDATE Heres the code for sub2ind in c++. Kindly see if the output is correct:- ofstream subtoind; subtoind.open("sub2ind.txt"); int sub2ind[96][64] = { 0 }; int ind2subROW[6144] = { 0 }; int ind2subCOL[6144] = { 0 }; int linearIndex=0; j = 0; z = 0; for (j = 1; j <= 64; j++) { for (z = 1; z <= 96; z++) { linearIndex = z + (j - 1) * 96; sub2ind[z-1][j-1] = linearIndex-1; //ind2subROW[linearIndex]ind2subROW[linearIndex-1] = j;j-1; //ind2subCOL[linearIndex]ind2subCOL[linearIndex-1] = z;z-1; } } for (j = 0; j < 96; j++) { subtoind << endl; //correction cout << endl;  for (z = 0; z < 64; z++) { subtoind << sub2ind[j][z] << " "; } } subtoind.close();  Heres the Link to the output file. https://drive.google.com/file/d/0BwUKS98DxycUSk5Fbnk1dDJnQ00/view?usp=sharing I'm working on an robot that would be able to navigate through a maze, avoid obstacles and identify some of the objects in it. I have a monochromatic bitmap of the maze, that is supposed to be used in the robot navigation. Up till now, I have converted/read the bitmap image of the maze into a 2D array of bits. However, now I need guidance on how to use that array to plan the path for the robot. I would appreciate if you could share any links as well, because I am new to all this stuff (I am just a 1st year BS electrical engineering student) and would be happy to have a more detailed explanation. If you need me to elaborate on anything kindly say so. I would be grateful! Here's the image of the maze. This is just a sample image; the robot should be able to work with any maze (image) with similar dimensions. And you are welcome! Thank you Chuck! UPDATE Heres the code:- ofstream subtoind; subtoind.open("sub2ind.txt"); int sub2ind[96][64] = { 0 }; int ind2subROW[6144] = { 0 }; int ind2subCOL[6144] = { 0 }; int linearIndex=0; j = 0; z = 0; for (j = 1; j <= 64; j++) { for (z = 1; z <= 96; z++) { linearIndex = z + (j - 1) * 96; sub2ind[z-1][j-1] = linearIndex-1; //ind2subROW[linearIndex] = j; //ind2subCOL[linearIndex] = z; } } for (j = 0; j < 96; j++) { cout << endl; for (z = 0; z < 64; z++) { subtoind << sub2ind[j][z] << " "; } } subtoind.close();  Heres the Link to the output file. https://drive.google.com/file/d/0BwUKS98DxycUSk5Fbnk1dDJnQ00/view?usp=sharing I'm working on an robot that would be able to navigate through a maze, avoid obstacles and identify some of the objects in it. I have a monochromatic bitmap of the maze, that is supposed to be used in the robot navigation. Up till now, I have converted/read the bitmap image of the maze into a 2D array of bits. However, now I need guidance on how to use that array to plan the path for the robot. I would appreciate if you could share any links as well, because I am new to all this stuff (I am just a 1st year BS electrical engineering student) and would be happy to have a more detailed explanation. If you need me to elaborate on anything kindly say so. I would be grateful! Here's the image of the maze. This is just a sample image; the robot should be able to work with any maze (image) with similar dimensions. And you are welcome! Thank you Chuck! UPDATE Heres the code for sub2ind in c++. Kindly see if the output is correct:- ofstream subtoind; subtoind.open("sub2ind.txt"); int sub2ind[96][64] = { 0 }; int ind2subROW[6144] = { 0 }; int ind2subCOL[6144] = { 0 }; int linearIndex=0; j = 0; z = 0; for (j = 1; j <= 64; j++) { for (z = 1; z <= 96; z++) { linearIndex = z + (j - 1) * 96; sub2ind[z-1][j-1] = linearIndex-1; //ind2subROW[linearIndex-1] = j-1; //ind2subCOL[linearIndex-1] = z-1; } } for (j = 0; j < 96; j++) { subtoind << endl; //correction cout << endl;  for (z = 0; z < 64; z++) { subtoind << sub2ind[j][z] << " "; } } subtoind.close();  Heres the Link to the output file. https://drive.google.com/file/d/0BwUKS98DxycUSk5Fbnk1dDJnQ00/view?usp=sharing 10 Rollback to Revision 8 edited Jun 22 '15 at 10:31 Muhammad Faique Shakeel 10588 bronze badges UPDATE 2 Here'sHeres the code:-////////////////////////////////////////////////////////////////////////////////////////////j =ofstream 0;subtoind; z = 0;subtoind.open("sub2ind.txt"); int currentPos; int destPos; ///////////////////////////////////////////////////////////////////////////////// int **digraph = NULL; digraphsub2ind[96][64] = new{ int0 *[6144]; }; for (int iind2subROW[6144] = 0; i < 6144; i++) { 0 }; int digraph[i]ind2subCOL[6144] = new{ int[6144]; 0 } //////////////////////////////////////////////////////////////////////////////// ; forint (linearIndex=0; j = 0; j < z 96;= j++)0; { for (zj = 0;1; zj <<= 64; z++j++) { currentPos = sub2ind[j][z]; iffor ((z - 1) > 0) { destPos = sub2ind[j][z - 1]; digraph[currentPos][destPos] = bitarray[j][z] * bitarray[j][z - 1]; } if1; ((z + 1)<= <96; 64z++) { { destPos = sub2ind[j][z + 1]; digraph[currentPos][destPos]linearIndex = bitarray[j][z] * bitarray[j][zz + 1]; } if ((j - 1) >* 0)96; { destPos = sub2ind[j sub2ind[z- 1][z]; digraph[currentPos][destPos]1][j-1] = bitarray[j][z] * bitarray[j linearIndex- 1][z];1; } if ((j + 1) < 96) //ind2subROW[linearIndex] = {j; destPos = sub2ind[j + 1][z]; digraph[currentPos][destPos]//ind2subCOL[linearIndex] = bitarray[j][z]z; * bitarray[j + 1][z]; } } } ofstream connectivityMap; connectivityMap.open("diGraph.txt"); for (int lj = 0; j < 300;96; l++j++) { // printing only 300cout elements {<< endl; for (int kz = 0; kz < 300;64; k++z++) { connectivityMapsubtoind << digraph[l][k]sub2ind[j][z] << " "; } } subtoind.close();  Heres the Link to the output file. https://drive.google.com/file/d/0BwUKS98DxycUSk5Fbnk1dDJnQ00/view?usp=sharing UPDATE 2 Here's the code:-////////////////////////////////////////////////////////////////////////////////////////////j = 0; z = 0; int currentPos; int destPos; ///////////////////////////////////////////////////////////////////////////////// int **digraph = NULL; digraph = new int *[6144]; for (int i = 0; i < 6144; i++) { digraph[i] = new int[6144]; } //////////////////////////////////////////////////////////////////////////////// for (j = 0; j < 96; j++) { for (z = 0; z < 64; z++) { currentPos = sub2ind[j][z]; if ((z - 1) > 0) { destPos = sub2ind[j][z - 1]; digraph[currentPos][destPos] = bitarray[j][z] * bitarray[j][z - 1]; } if ((z + 1) < 64) { destPos = sub2ind[j][z + 1]; digraph[currentPos][destPos] = bitarray[j][z] * bitarray[j][z + 1]; } if ((j - 1) > 0) { destPos = sub2ind[j - 1][z]; digraph[currentPos][destPos] = bitarray[j][z] * bitarray[j - 1][z]; } if ((j + 1) < 96) { destPos = sub2ind[j + 1][z]; digraph[currentPos][destPos] = bitarray[j][z] * bitarray[j + 1][z]; } } } ofstream connectivityMap; connectivityMap.open("diGraph.txt"); for (int l = 0; j < 300; l++) // printing only 300 elements { for (int k = 0; k < 300; k++) { connectivityMap << digraph[l][k] << " "; } }  UPDATE Heres the code:-ofstream subtoind; subtoind.open("sub2ind.txt"); int sub2ind[96][64] = { 0 }; int ind2subROW[6144] = { 0 }; int ind2subCOL[6144] = { 0 }; int linearIndex=0; j = 0; z = 0; for (j = 1; j <= 64; j++) { for (z = 1; z <= 96; z++) { linearIndex = z + (j - 1) * 96; sub2ind[z-1][j-1] = linearIndex-1; //ind2subROW[linearIndex] = j; //ind2subCOL[linearIndex] = z; } } for (j = 0; j < 96; j++) { cout << endl; for (z = 0; z < 64; z++) { subtoind << sub2ind[j][z] << " "; } } subtoind.close();  Heres the Link to the output file. https://drive.google.com/file/d/0BwUKS98DxycUSk5Fbnk1dDJnQ00/view?usp=sharing 9 Inserted the code that fills the digraph matrix. edited Jun 15 '15 at 16:47 Muhammad Faique Shakeel 10588 bronze badges UPDATE 2 HeresHere's the code:-////////////////////////////////////////////////////////////////////////////////////////////ofstreamj subtoind;= 0; subtoind.open("sub2ind.txt");z = 0; int currentPos; int sub2ind[96][64]destPos; ///////////////////////////////////////////////////////////////////////////////// int **digraph = {NULL; digraph 0= };new int *[6144]; for (int ind2subROW[6144]i = {0; 0i };< 6144; i++) int{ ind2subCOL[6144] = { 0digraph[i] = new int[6144]; }; int linearIndex=0;//////////////////////////////////////////////////////////////////////////////// for (j = 0; z =j 0;< 96; j++) { for (jz = 1;0; jz <=< 64; j++z++) { forcurrentPos = sub2ind[j][z]; if ((z - 1) > 0) { destPos = 1;sub2ind[j][z z- <=1]; 96; z++) digraph[currentPos][destPos] = bitarray[j][z] * bitarray[j][z - 1]; } if ((z + 1) < 64) { destPos = sub2ind[j][z + 1]; linearIndex digraph[currentPos][destPos] = zbitarray[j][z] * bitarray[j][z + 1]; } if ((j - 1) *> 96;0) { sub2ind[z-1][j-1]destPos = linearIndexsub2ind[j -1; 1][z]; digraph[currentPos][destPos] = bitarray[j][z] * bitarray[j - 1][z]; //ind2subROW[linearIndex] = j; } if ((j + 1) < 96) { //ind2subCOL[linearIndex] destPos = z;sub2ind[j + 1][z]; digraph[currentPos][destPos] = bitarray[j][z] * bitarray[j + 1][z]; } } } ofstream connectivityMap; connectivityMap.open("diGraph.txt"); for (jint l = 0; j < 96;300; j++l++) { // printing coutonly <<300 endl;elements { for (zint k = 0; zk < 64;300; z++k++) { subtoindconnectivityMap << sub2ind[j][z]digraph[l][k] << " "; } } subtoind.close();  Heres the Link to the output file. https://drive.google.com/file/d/0BwUKS98DxycUSk5Fbnk1dDJnQ00/view?usp=sharing UPDATE Heres the code:-ofstream subtoind; subtoind.open("sub2ind.txt"); int sub2ind[96][64] = { 0 }; int ind2subROW[6144] = { 0 }; int ind2subCOL[6144] = { 0 }; int linearIndex=0; j = 0; z = 0; for (j = 1; j <= 64; j++) { for (z = 1; z <= 96; z++) { linearIndex = z + (j - 1) * 96; sub2ind[z-1][j-1] = linearIndex-1; //ind2subROW[linearIndex] = j; //ind2subCOL[linearIndex] = z; } } for (j = 0; j < 96; j++) { cout << endl; for (z = 0; z < 64; z++) { subtoind << sub2ind[j][z] << " "; } } subtoind.close();  Heres the Link to the output file. https://drive.google.com/file/d/0BwUKS98DxycUSk5Fbnk1dDJnQ00/view?usp=sharing UPDATE 2 Here's the code:-////////////////////////////////////////////////////////////////////////////////////////////j = 0; z = 0; int currentPos; int destPos; ///////////////////////////////////////////////////////////////////////////////// int **digraph = NULL; digraph = new int *[6144]; for (int i = 0; i < 6144; i++) { digraph[i] = new int[6144]; } //////////////////////////////////////////////////////////////////////////////// for (j = 0; j < 96; j++) { for (z = 0; z < 64; z++) { currentPos = sub2ind[j][z]; if ((z - 1) > 0) { destPos = sub2ind[j][z - 1]; digraph[currentPos][destPos] = bitarray[j][z] * bitarray[j][z - 1]; } if ((z + 1) < 64) { destPos = sub2ind[j][z + 1]; digraph[currentPos][destPos] = bitarray[j][z] * bitarray[j][z + 1]; } if ((j - 1) > 0) { destPos = sub2ind[j - 1][z]; digraph[currentPos][destPos] = bitarray[j][z] * bitarray[j - 1][z]; } if ((j + 1) < 96) { destPos = sub2ind[j + 1][z]; digraph[currentPos][destPos] = bitarray[j][z] * bitarray[j + 1][z]; } } } ofstream connectivityMap; connectivityMap.open("diGraph.txt"); for (int l = 0; j < 300; l++) // printing only 300 elements { for (int k = 0; k < 300; k++) { connectivityMap << digraph[l][k] << " "; } }  8 deleted 28137 characters in body edited Jun 15 '15 at 14:48 Muhammad Faique Shakeel 10588 bronze badges 7 added 28873 characters in body edited Jun 15 '15 at 10:36 Muhammad Faique Shakeel 10588 bronze badges 6 edited title | link edited Jun 14 '15 at 15:24 Muhammad Faique Shakeel 10588 bronze badges 5 change control tag to planning | link edited Jun 14 '15 at 11:56 Ben♦ 4,36122 gold badges1414 silver badges3737 bronze badges 4 included image, not link edit approved Jun 7 '15 at 16:08 Bending Unit 22 1,33566 silver badges1313 bronze badges 3 Attached maze image. edited Jun 6 '15 at 15:46 Muhammad Faique Shakeel 10588 bronze badges 2 added 54 characters in body; edited title edited Jun 6 '15 at 14:52 Muhammad Faique Shakeel 10588 bronze badges 1 asked Jun 6 '15 at 14:29 Muhammad Faique Shakeel 10588 bronze badges