Learning how to program a Mars rover, one week at a time.
There are 15 weeks in a semester, so this crash course aims to complete the new member training in 10-ish weeks to give some leeway. These bullet points are meant to be in order of how we want to teach things. Feel free to make revisions as desired. :)
- Get people on GitHub and the Teams programming channel. Decide on a programming meeting time
- Explain which repos we have in our GitHub organization
- Create profiles on Shatterdome for all new users
- Get everyone set up with
xrdp
using our "Remote Desktop with xrdp" guide
- Command structure (
$ command [-options] [arguments]
), basic filesystem,pwd
,mkdir
,ls
,cd
,nano
,cp
,mv
,rmdir
,rm
,man
. See our Bash & Linux Crash Course for more details.
- Using Python's turtle library
- Drake got it to work with just Ubuntu WSL2,
sudo apt-get install python3-tk
, and an Xserver running - Start with this code:
import turtle # setup scrn = turtle.getscreen() turt = turtle.Turtle() # vvv YOUR CODE GOES BELOW HERE vvv # ^^^ YOUR CODE GOES ABOVE HERE ^^^ # leave the screen open until clicked scrn.exitonclick()
- Use these functions:
forward(amount)
,backward(amount)
,right(angle)
,left(angle)
,fillcolor(color_name)
,begin_fill()
,end_fill()
,penup()
(picks up the turtle's pen), and/orpendown()
(puts down the turtle's pen). More info and a few more functions can be found here. Make sure to call these functions from the Turtle object we instantiated in the starter code. - Challenges - make these drawings:
-
Write the body for a function named
def colored_square(my_size, my_color):
, which draws a square of sizemy_size
and colormy_color
. Then draw two squares using these lines:# call function several times with different arguments colored_square(100, "blue") colored_square(50, "red")
^^ Click to reveal a possible solution (try it yourself first!) ^^
import turtle # setup scrn = turtle.getscreen() turt = turtle.Turtle() # define function to draw colored square def colored_square(my_size, my_color): turt.fillcolor(my_color) turt.begin_fill() for i in range(4): turt.forward(my_size) turt.left(90) turt.end_fill() # call function several times with different arguments colored_square(100, "blue") colored_square(50, "red") # leave the screen open until clicked scrn.exitonclick()
-
In a separate python file, write the body for a function named
def draw_polygon(num_sides):
, which draws a regular polygon with the requested number of sides (Hint: the angle to turn for each shape is360.0 / num_sides
). The side lengths are all100
in the example image. Then call the function in a for-loop to draw everything from a triangle to an octagon.^^ Click to reveal a possible solution (try it yourself first!) ^^
import turtle # setup scrn = turtle.getscreen() turt = turtle.Turtle() # define function to draw polygon with some number of sides def draw_polygon(num_sides): turn_angle = 360.0 / num_sides for side in range(num_sides): turt.forward(100) turt.left(turn_angle) # draw polygons with the same starting point for num_sides in range(3, 9): draw_polygon(num_sides) # leave the screen open until clicked scrn.exitonclick() </details>
-
- Drake got it to work with just Ubuntu WSL2,
- read What is Git?
- Have each member clone this CrashCourse repo, create a new branch named
<firstname>-hello-word
, commit their Python code from previous weeks, push to their branch, and then make a pull request to merge intomain
(but don't actually merge)- Explain the workflow of git (
git pull
-> make changes ->git add <files>
->git commit -m "what I did"
->git push
)
- Explain the workflow of git (
- Explain useful commands, e.g.
git status
,git diff
,git log
Weeks 7-10: ROS2 Beginner Tutorials: CLI Tools & Client Libraries (but slightly out of order). Drake tentatively proposes the following tutorials order:
Note, connect over
xrdp
for these steps. Shatterdome should have ROS2 installed for all profiles.
Note, to get ROS2 working on your computer, start your X-server, SSH into shatterdome withssh -X <username>@<shatterdome_ip>
, and then it should work. If off the campus's WiFi, first SSH into your Turing/Hopper account usingssh -Y <username>@turing.cs.niu.edu
orssh -Y <username>@hopper.cs.niu.edu
, and thenssh -X
to shatterdome as described above.
Note, since we're working on shatterdome which is a Linux machine, always use the Linux instructions, even if you're a MacOS or Windows user!!!
- Some of the "Beginner: CLI Tools" tutorials:
- Configuring your ROS 2 environment (Skip the instructions about installations, ROS2 is already installed on shatterdome!)
- (Do we need to set
ROS_DOMAIN_ID
? I guess ignore for now) - challenge: run
ros2 doctor
. Do you get a bunch of output and thenAll 4 checks passed
at the bottom?
- (Do we need to set
- Introducing turtlesim and rqt
- challenge: some "check your understanding" questions. Can hide answer like so:
click to reveal answer
hello world
- challenge: some "check your understanding" questions. Can hide answer like so:
- Understanding ROS 2 nodes
- Understanding ROS 2 topics
- Configuring your ROS 2 environment (Skip the instructions about installations, ROS2 is already installed on shatterdome!)
- Some of the "Beginner: Client Libraries" tutorials:
- Creating a workspace
- Creating your first ROS 2 package
- Writing a simple publisher and subscriber (Python)
- challenge: modify the publisher so it says a different message
- challenge: write a publisher that controls the turtlesim to make shapes similar to what we did with the Python
turtle
library (color fill not necessary though)
- For reference, here are some diagrams explaining the structure of workspaces and packages (source https://www.youtube.com/watch?v=lN4_-l7FCWk):
- understanding services
- writing a simple service and client (python)
- challenge: comment out AddTwoInts code, and create a SubtractTwoInts service
- challenge: uncomment AddTwoInts code, and make a way for client to request one service or the other (modify the challenge if this is bad use of services)
running a demo in Docker container (on shatterdome?) to verify integrity (and cuz it's cool)(crossed out since we're no longer using Webots through Docker)- quick intro to scene tree
- writing code to communicate with robot controller
- not in crash course, but further reading: https://cyberbotics.com/doc/guide/tutorials?tab-language=python
This area is for plans we decided to drop, but that we don't want to necessarily delete or bury in the commit history. Ideally, any sections added here should include a note for why they've been banished to The Shadow Realm™️.
- (Banished because we discovered Docker was unnecessary for ROS2. Instead, we can just
ssh -X
into shatterdome with an X-server running locally, and it will work just fine.) - read What is Docker?
- Install and test Docker in your terminal by following our Installing Docker guide
- running one of our ROS2 containers: follow the README instructions for running our
ros2_foxy
Docker container (you'll need to clone thatNIURoverTeam/Dockerfiles
repo in your WSL)- check integrity with
ros2 doctor
- check integrity with
- (Banished because we've decided to only use
xrdp
and not bother with WSL2 for speed and consistency reasons.) - TODO should we skip this and use
xrdp
instead? "Remote Desktop with xrdp" guide - If using Windows 10:
- Install WSL2 using this guide.
If instructed to download your Linux distribution of choice, choose Ubuntu from the Microsoft Store. As of September 2021 however, I don't think this is part of the linked guide.
- If you don't see
Ubuntu
when you search for it in your Start Menu, go ahead and install it from the Microsoft Store as well. Choose the one named justUbuntu
, without any numbers after.
- Install WSL2 using this guide.
- Regardless of your operating system:
- To set up an X-server for yourself, follow our Installing an X-Server guide