GithubHelp home page GithubHelp logo

robond-rover-project's Introduction

Mars Rover Behavioral Cloning Project


Deprecated Repository

This repository is deprecated. Currently enrolled learners, if any, can:

Udacity - Robotics NanoDegree Program

Search and Sample Return Project

alt text

This project is modeled after the NASA sample return challenge and it will give you first hand experience with the three essential elements of robotics, which are perception, decision making and actuation. You will carry out this project in a simulator environment built with the Unity game engine.

The Simulator

The first step is to download the simulator build that's appropriate for your operating system. Here are the links for Linux, Mac, or Windows.

You can test out the simulator by opening it up and choosing "Training Mode". Use the mouse or keyboard to navigate around the environment and see how it looks.

Dependencies

You'll need Python 3 and Jupyter Notebooks installed to do this project. The best way to get setup with these if you are not already is to use Anaconda following along with the RoboND-Python-Starterkit.

Here is a great link for learning more about Anaconda and Jupyter Notebooks

Recording Data

I've saved some test data for you in the folder called test_dataset. In that folder you'll find a csv file with the output data for steering, throttle position etc. and the pathnames to the images recorded in each run. I've also saved a few images in the folder called calibration_images to do some of the initial calibration steps with.

The first step of this project is to record data on your own. To do this, you should first create a new folder to store the image data in. Then launch the simulator and choose "Training Mode" then hit "r". Navigate to the directory you want to store data in, select it, and then drive around collecting data. Hit "r" again to stop data collection.

Data Analysis

Included in the IPython notebook called Rover_Project_Test_Notebook.ipynb are the functions from the lesson for performing the various steps of this project. The notebook should function as is without need for modification at this point. To see what's in the notebook and execute the code there, start the jupyter notebook server at the command line like this:

jupyter notebook

This command will bring up a browser window in the current directory where you can navigate to wherever Rover_Project_Test_Notebook.ipynb is and select it. Run the cells in the notebook from top to bottom to see the various data analysis steps.

The last two cells in the notebook are for running the analysis on a folder of test images to create a map of the simulator environment and write the output to a video. These cells should run as-is and save a video called test_mapping.mp4 to the output folder. This should give you an idea of how to go about modifying the process_image() function to perform mapping on your data.

Navigating Autonomously

The file called drive_rover.py is what you will use to navigate the environment in autonomous mode. This script calls functions from within perception.py and decision.py. The functions defined in the IPython notebook are all included inperception.py and it's your job to fill in the function called perception_step() with the appropriate processing steps and update the rover map. decision.py includes another function called decision_step(), which includes an example of a conditional statement you could use to navigate autonomously. Here you should implement other conditionals to make driving decisions based on the rover's state and the results of the perception_step() analysis.

drive_rover.py should work as is if you have all the required Python packages installed. Call it at the command line like this:

python drive_rover.py

Μετασχηματισμός Προοπτικής

Στην πρώτη συνάρτηση perspect_transform(), μετατρέπουμε την όψη της εικόνας που φαίνεται από την κάμερα του rover σε κάτοψη, δηλαδή όπως φαίνεται από πάνω. Στην εικόνα grid_img, κάθε τετράγωνο στο πλέγμα έχει μέγεθος 10x10 pixel. Δημιουργούμε μια μεταβλητή dst_size όπου την ορίζουμε ως την απόσταση από την γωνία ως το κέντρο του τετραγώνου (=10/2=5 μονάδες) και μια μεταβλητή bottom_offset που ορίζεται ως την απόσταση της κάμερας από το τετράγωνο της εικόνας (=6 μονάδες). Η επιλογή των σημείων προέλευσης έγινε μέσω του διαδραστικού παραθύρου matplotlib. Επιλέγουμε να φτιάξουμε το τετράγωνο προορισμού στο κέντρο της εικόνας, δηλαδή το μέσο της κάτω πλευράς του τετραγώνου θα είναι στο κέντρο της εικόνας και 6 μονάδες (bottom_offset) πάνω. Το image.shape[0] ισούται με 160 μονάδες, δηλαδή με το μήκος του άξονα y και το image.shape[1] ισούται με 320 μονάδες, δηλαδή με το μήκος του άξονα x. Ο άξονας y είναι αντίστροφος, συνεπώς το έδαφος έχει y=160. Έτσι για παράδειγμα, η κάτω αριστερά γωνία έχει συντεταγμένες προέλευσης (14,140) και συντεταγμένες προορισμού x=image.shape[1]/2 (=160) – dst_size = 155 , y=image.shape[0] (=160) – bottom_offset = 154. Τέλος, δημιουργούμε την μεταβλητή warped όπου ορίζεται ως η κάτοψη της εικόνας grid_img και την rock_warped που είναι η κάτοψη της εικόνας rock_img.

Κατώφλι Χρώματος

Στο επόμενο βήμα, χρησιμοποιούμε 3 συναρτήσεις για να εντοπίσουμε το πλοηγήσιμο έδαφος, τα εμπόδια και τις πέτρες. Στο διαδραστικό παράθυρο matplotlib μπορούμε να δούμε ότι το κατώφλι για το έδαφος και τα εμπόδια στα κανάλια RGB είναι (160,160,160) Έτσι, στην συνάρτηση ground_thresh όταν κάποιο pixel έχει τιμή μεγαλύτερη από 160 σε κάθε κανάλι RGB, τότε γίνεται λευκό, ενώ στην συνάρτηση obstacle_thresh όταν κάποιο pixel έχει τιμή μικρότερη από 160 σε κάθε κανάλι RGB, τότε γίνεται λευκό. Στην συνάρτηση rock_thresh, μετατρέπουμε την εικόνα rock_img όπου φαίνεται η πετρά από RGB σε HSV καθώς έτσι είναι πιο εύκολο να εντοπιστεί το κατώφλι για την πέτρα. Συνεπώς όταν κάποιο pixel είναι ανάμεσα στις τιμές 0-179 στο κανάλι H(Hue), 200-255 στο κανάλι S(Saturation) και 100-255 στο V(Value), γίνεται λευκό. Τέλος, εκτελούνται οι συναρτήσεις ground_thresh και obstacle_thresh που παίρνουν σαν όρισμα την εικόνα warped (την κάτοψη της grid_img) και οι κατωφλιοποιημένες εικόνες αποδίδονται στις μεταβλητές ground_select και obstacle select. Ομοίως εκτελείται και η rock_thresh που παίρνει σαν όρισμα την warped_rock και αποδίδεται στην μεταβλητή rock_select.

Μετασχηματισμός Συντεταγμένων

Στο συγκεκριμένο βήμα, πρέπει να μετατρέψουμε τις συντεταγμένες που έχουμε στις εικόνες κάτοψης, σε ρομποκεντρικές συντεταγμένες. Αυτό πραγματοποιείται με την συνάρτηση rover_coords όπου δημιουργείται ένα πλαίσιο συντεταγμένων που το rover βρίσκεται στο (x, y) = ( 0, 0). Έπειτα μετατρέπουμε τις ρομποκεντρικες συντεταγμένες, από καρτεσιανές σε πολικές και εφαρμόζουμε μια περιστροφή ακολουθούμενη από μια μετατόπιση. Δηλαδή, περιστρέφουμε τις ρομποκεντρικές συντεταγμένες έτσι ώστε οι άξονες x και y να είναι παράλληλοι με τους άξονες στον χώρο και μετατοπίζουμε τις περιστρεφόμενες θέσεις με τις τιμές θέσης x και y που δίνονται από την τοποθεσία του rover (διάνυσμα θέσης) στον κόσμο. Στην συνάρτηση pix_to_world , εκτελείται η περιστροφή και η μετατόπιση και τέλος η κλιμάκωση της τάξης του 10, αφού όπως αναφέρεται κάθε pixel στον χάρτη του περιβάλλοντος θέλουμε να είναι 1 τετραγωνικό μέτρο , ενώ μέχρι τώρα κάθε pixel απεικόνιζε 0.1 x 0.1 m

Συνάρτηση process_image

Στο βήμα αυτό καλούμε τις συναρτήσεις που ορίσαμε προηγουμένως για να δημιουργήσουμε ένα βίντεο. Αφού έχουμε υπολογίσει τις συντεταγμένες περιβάλλοντος όπως περιγράψαμε στα προηγούμενα βήματα, πραγματοποιούμε ενημέρωση του χάρτη του κόσμου όπου στο πρώτο κανάλι (red) θα φαίνονται τα εμπόδια με κόκκινο, στο δεύτερο (green) θα φαίνονται οι πέτρες με πράσινο και τέλος στο τρίτο κανάλι (blue) θα φαίνεται το πλοηγήσιμο έδαφος με μπλε

robond-rover-project's People

Contributors

janudis avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.