User Tools

Site Tools


bfs_and_dfs_implementation_v2

This is an old revision of the document!


BFS & DFS Implementation V2 (IN-PROGRSS)

Author: Francis Palustre Email: palusf1@unlv.nevada.edu
Date: Last modified on <11/09/23>
Keywords: Navigation, BFS, DFS, Robotino, C, \\ {{ :sampleimageforwritingtutorial.jpg?200

  double getCurrentTime() {
       struct timeval tv; //timeval struct to store time values
       gettimeofday(&tv, NULL); //get current time and store in timeval
       
       //convert time to seconds and add microseconds for precision
       return (tv.tv_sec) + tv.tv_usec / 1000000.0;
  }

* roboMove() prints the final path from the algorithm and will result into the movement of Robotino

  void roboMove(map<string, vector<string> > newGraph, string startNode, string desiredNode) {
       vector<string> roboPath = BFS(newGraph, startNode, desiredNode); //or DFS
       
       //couts the final path
       for (vector<string>::iterator it = roboPath.begin(); it != roboPath.end(); it++) {
           cout << *it << " ";
        } cout << endl;
        
       //movement of Robotino
       for (int i = 0; i < int(roboPath.size()) - 1; i++) {
           //movement is based on current and next value in path
           int currPos = atoi(roboPath.at(i).c_str());
           int nextPos = atoi(roboPath.at(i + 1).c_str());
           
            if ((currPos + 6) == nextPos) {
                moveY(0,1);
            }
            
            if ((currPos - 6) == nextPos) {
                moveY(1,0);
            }
            
            if ((currPos - 1) == nextPos) {
                moveX(1,0);
            }
            
            if ((currPos + 1) == nextPos) {
                moveX(0,1);
            }
       }
       omni.setVelocity(0,0,0);
  }

==== Robotino Functions ==== Robotino functions are functions that used for Robotino's movement ==== Breadth First Search==== Algorithm for BFS ==== Depth First Search ==== Algorithm for DFS ==== Final Words ==== This tutorial's objective was to implement the BFS and DFS algorithm into Robotino using an alternative method when compared to the first version. Complete source code for the algorithms can be found at the beginning of the tutorial. Once the concepts were conveyed the reader could try to implement BFS and DFS and other path planning algorithms into their own projects.

Speculating future work derived from this tutorial, includes <fill in the blank>. In the big picture, the problem of <fill in the blank> can be solved with this tutorial.

For questions, clarifications, etc, Email: palusf1@unlv.nevada.edu

bfs_and_dfs_implementation_v2.1699581078.txt.gz · Last modified: by fpalustre