Autonomy Bootcamp

Overview

Before embarking on this subteam bootcamp, please ensure you’ve completed these instructions: Bootcamper Onboarding.

This bootcamp is in effect starting 2023-09-06 . If you are doing the Autonomy bootcamp, you are at the right place! Create a post in the #auto-bootcamps forum to get started! You can ask for help there and notify the Autonomy bootcamp reviewers when you are done.

Setup

Dear WARG Bootcamper,

Congratulations and welcome to the AutoBots family! We're excited to have you on the team. I'll be sending you our onboarding documents soon, please feel free to get a head start on that.

Yours sincerely,

Jane Doe
VP of Human Resources
AutoBots

Git and GitHub

“I’m still waiting for QA to give me back my code [on the USB stick].” - Overheard at the water cooler

Forking

Create a personal copy of the repository by forking it.

  1. If you haven’t already, create an account on GitHub. You can use either your UW email or something else. Otherwise, log in with the GitHub account you would like to use with WARG.

  2. Visit: GitHub - UWARG/autonomy-bootcamp-2023: New Autonomy subteam bootcamp starting F23.

  3. Click on the Fork button (towards the top right, above the About section).

  4. Click on the green Create fork button.

  5. GitHub redirects you to your own copy of the repository.

Git setup (General for all autonomy projects)

Cloning the repository

Go to GitHub and navigate to your copy of the repository, under your account. Do not go to WARG’s copy of the repository!

Python and virtual environment

“It’s fine, it works on my machine.” - Overheard in the software development cubicle farm

Python is the programming language this bootcamp uses.

Activate the Python virtual environment

Install packages

  1. Open requirements.txt

    1. MacOS: Remove the line containing --extra-index-url [link]

    2. Windows and Linux:

      1. If you have a CUDA capable GPU but don’t want to use it for some reason, remove the line containing --extra-index-url [link]

      2. If you don’t have a CUDA capable GPU, don’t change anything.

  2. If you haven’t already, activate the virtual environment.

  3. Download and install required packages: pip install -r requirements.txt

    1. This will install in your virtual environment under venv . The rest of your system is unaffected.

  4. Done!

Directory

Now that you have everything needed to start, take a quick look at what you’re working with.

The repository is divided into 3 sections:

  • modules/ 's free floating files contains the common classes that are passed around the interfaces.

  • modules/bootcamp/ is where you will write your code.

  • modules/private/ is the black box to control. The bootcamp is completable without ever looking here. In fact, we encourage you to hold off until after completing all the tasks.

Each file has a docstring header that will contain one of the following:

  • BOOTCAMPERS DO NOT MODIFY THIS FILE. : Do not modify this file! Your submission will not be accepted if these files are modified.

  • BOOTCAMPERS TO COMPLETE. : Search for BOOTCAMPERS MODIFY BELOW THIS COMMENT (there may be multiple) and follow the instructions.

Do not commit extra files! Your submission will not be accepted if you have extra files.

Do not import any additional libraries. The bootcamp is completable as is.

Development

Every time you want to change code in your repository.

  1. If you haven’t already, activate the virtual environment.

  2. Follow the instructions in the tasks below.

  3. Code away! Run the tests! Please follow our style guide: Python Style Convention

    1. Ask questions if you need help!

    2. Make sure the linter and formatter pass:

      1. Running Black is sufficient for it to pass: black .

      2. Flake8 outputting nothing is a pass: flake8 .

      3. Pylint outputting a code rating of 10.00/10 is a pass (9.99/10 is not passing): pylint modules

  4. Make a commit:

    1. Check which files have changed: git status

    2. Run: git add [files you changed] , where [files you changed] are the files you want to add to the commit.

      1. Use git add . if you want to add all of them (the dot means wildcard in Git).

    3. Run: git commit -m "Your commit message"

    4. When you’re ready to push your latest commits to GitHub: git push

      1. No harm in doing this after every commit.

  5. When you’re done, make sure to either close the terminal or run:

    1. Windows command prompt: venv\Scripts\deactivate.bat

    2. Everything else: deactivate

    3. This is important to avoid going to a different project and then accidentally polluting your current project’s virtual environment.

Optionally, you can also create new branches for yourself if you want to be more organized. You can search for git branch information online.

Windows Subsystem for Linux (WSL)

We do not recommend using WSL at this time because of several environment issues. You are free to make the attempt if you’re willing to encounter them (and if you solve them, please tell us). All Autonomy projects are currently cross platform so using Windows is perfectly fine.

CUDA issues:

If you have a CUDA capable GPU, you may encounter this error: Can't initialize NVML in torch/cuda/__init__.py:497

The current workaround is to hide the GPU: export CUDA_VISIBLE_DEVICES=-1

This is not ideal since you are removing a hardware advantage.

MobaXterm display issues:

If you are using MobaXterm, we suggest using a different display server. MobaXterm's display window flashes and moves towards the bottom right as OpenCV redraws the image.

This issue does not occur with a different display server: Xming version 6.9.0.31 (most recent we could find) and running: export DISPLAY=:0

This may not be necessary depending on whether you have WSLg already.

Submission and pull request

Once your submission is ready for review, open a pull request (PR) from your fork to the WARG repository.

  1. Navigate to WARG’s copy of the repository: GitHub - UWARG/autonomy-bootcamp-2023: New Autonomy subteam bootcamp starting F23.

  2. At the top, click Pull requests.

  3. To the right, click the green New pull request button.

  4. Under Compare changes, click the “compare across forks” link.

  5. The 3rd from the left: Click the head repository dropdown and select your repository (you can search for your username).

  6. The 4th from the left: Click the compare dropdown and select the branch you want to submit.

    1. Do not open more than 1 pull request! The branch you select should contain (or eventually contain) all tasks which will be reviewed.

    2. Once you have an open PR, you can keep updating the same branch as you get feedback. You do not need to open another PR.

  7. Click on the green Create pull request button.

  8. Once you have an open PR and are ready for review, go to your Discord bootcamp thread and send this message: @AUTO-Bootcamp Reviewer My bootcamp is ready for review: [link to your PR on GitHub]

  9. The Autonomy bootcamp reviewers will review your PR (a message will be sent on Discord, and the comments will be on GitHub).

  10. Read the feedback and go back to development. If any of the feedback is unclear or confusing, don’t hesitate to ask for clarification (make sure to send a message on Discord as well for visibility (e.g. I asked some questions as replies on GitHub ).

    1. Please do not click on Resolve conversation for any of the comments that the reviewers may leave! It causes confusion for the reviewers since they use the resolved/unresolved state to confirm that the code meets the quality to their satisfaction. Instead, you can use a reaction or reply to the comment for your own tracking purposes.

    2. If you are ready for another review, repeat step 8 (you do not need to open a new PR).

  11. Once your review is fully complete and you’re done with the bootcamp, please follow the steps in New Member Onboarding to onboard to the team.

Tasks

Do not raise exceptions. The only exception are assertions, and only for quieting the linter (e.g. assert value is not None on Pylance). An assertion used in this way must be impossible to fail.

Task 1: Implementing ML inference

From the repository root, try running pylint modules . You will notice that there are no issues and the code is rated 10.00/10 . Remove the Pylint ignore near the top of the file and run the command again. You will notice that the linter now reports several issues.

From the repository root, try running pytest modules/bootcamp/tests/test_detect_landing_pad.py . You will notice that some of the unit tests fail.

Your task is to implement the code in run() to correctly identify landing pads.

Once your code is correctly implemented, all tests should pass.

The linters and formatters should also pass.

Name

Command

Description

Passing criteria

Name

Command

Description

Passing criteria

Black

black .

Black is a formatter that edits the code layout (e.g. indentation, multiline).

Running Black is sufficient for it to pass.

Flake8

flake8 .

Flake8 is a linter that reports whether function and methods are correctly type annotated.

Flake8 outputting nothing is a pass.

Pylint

pylint modules

Pylint is a general linter.

Pylint outputting a code rating of 10.00/10 is a pass. It must be exactly 10.00 , so 9.99/10 is not passing.

Task 2: Running the simulator

The simulator is composed of 5 pipelined stages:

  • Simulation: Simulates a physical drone.

  • Detection: Detects landing pad on camera image.

  • Geolocation: Converts bounding boxes to locations.

  • Display: Displays the camera image and drone information.

  • Decision: Commands the drone.

Information moves from each stage to the next, and the loop is completed with commands from Decision to Simulation. Simulation requires a command to be sent from Decision every time step, making the simulator synchronous (in lock step, as opposed to asynchronous). The Decision stage is where you’ll write code for task 3 and task 4.

From the repository root, try running python -m modules.bootcamp.tests.run_decision_example . It should take about 12.5 seconds wall clock time for the drone to complete its first command (it will be obvious when it does). If the simulator is running too slowly, try increasing the time step size in modules/bootcamp/tests/run_decision_example.py (reducing the FPS). Take a look at modules/bootcamp/decision_example.py as well.

The simulator should exit after the drone lands, which occurs about 100 seconds after start. Ctrl-c to stop the simulator early. If the simulator exits early or has some error, then you should go through your task 1 code again and make sure there aren't any bugs. You are encouraged to use the debugger and/or print statements in conjunction with the simulator, as long as you do not breakpoint or step into modules/private/ .

Task 3: Making the drone move to and land at a waypoint

From the repository root, try running python -m modules.bootcamp.tests.run_decision_simple_waypoint . You will notice that the simulator starts but doesn’t do anything before exiting. This is because of the raised NotImplementedError exception.

The drone reports a status, which you will use to implement the drone decision logic to decide which command to send:

  • Halted: The drone is not moving.

  • Moving: The drone is moving.

  • Landed: The drone has landed and the simulator is ending.

In addition, the drone report also contains its position and global destination (if applicable).

  • For the Halted and Landed status, the report’s destination is the same as the report’s position.

There are 4 types of commands:

  • Null: Default. Does nothing but required to advance the simulator.

  • Set relative destination: Move distance relative to current position of the drone. Requires drone to be halted. The destination must also be within the flight boundary.

    • The flight boundary is a square from (-60.0, -60.0) to (60.0, 60.0). The drone’s initial position is (0, 0).

    • The drone halts when it reaches the destination.

  • Halt: Makes the drone stop immediately at its current position.

  • Land: Lands the drone at the current position and ends the simulation. Requires drone to be halted.

If an invalid command is sent, it is ignored with a warning.

Your task is to implement the code in __init__() and run() to travel to and land at the designated waypoint if the drone is within self.acceptance_radius.

Once your code is implemented, the simulator should exit after the drone lands, which should occur within 60 seconds of start. The difference between the coordinates of the drone position and waypoint under the text file in log/ should be less than 0.1 . You can also confirm with the screenshot.

The linters and formatters should also pass.

Task 4: Putting it all together

From the repository root, try running python -m modules.bootcamp.tests.run_decision_waypoint_landing_pads . You will notice that the simulator starts but doesn’t do anything before exiting. This is because of the raised NotImplementedError exception.

You can copy and paste your code from the __init__() and run() methods of decision_simple_waypoint.py to see what happens. Do not copy the entire file, as the class name and descriptions are different.

Your task is to implement the code in __init__() and run() to travel to the designated waypoint, calculate which landing pad is closest (L-2 norm for the math nerds), and land at that landing pad. You can remove or comment out the NotImplementedError line.

Once your code is implemented, the simulator should exit after the drone lands, which should occur within 60 seconds of start. The difference between the coordinates of the drone position and the landing pad under the text file in log/ should be less than 0.1 . You can also confirm with the screenshot.

The linters and formatters should also pass.