Lab 1 will give you instructions to build, calibrate, and run your Duckiebot. At the end of this lab, you should be able to run ROS code on your robot using your class container.

Please read all instructions in the Duckiebot documentation carefully. Some items are optional and NOT required.

NOTE: Students enrolled in EECE.4560 only need to complete PART I. Students enrolled in EECE.5560 will need to complete PART I and PART II of the lab.

Instructions

PART I

  1. Please ensure your Duckiebot battery is charged. You can plug it in now as it will not be needed until Step 6.
  2. You should already have Duckietown Shell set up correctly. If not, refer to HW1.
  3. If you are using a virtual machine, you probably need to check or change a few settings.
    1. First, change your networking settings such that you can connect to the Duckiebot. Your adapter should be set to “bridged.” If you use VirtualBox, refer to this page and the lecture notes to set this correctly: https://www.virtualbox.org/manual/ch06.html
    2. Second, you likely need to install the Virtualbox Extension Pack: https://www.virtualbox.org/wiki/Downloads. Once you have installed this, go into the machine settings for your VM -> Ports tab -> USB tab and ensure the USB 3 controller is selected. This will help to flash your SD card in Step 5. This tutorial steps through the process https://www.tecmint.com/enable-usb-in-virtualbox/.
  4. Set up a duckietown account on their website. Choose the Massachusetts community. https://docs.duckietown.org/daffy/opmanual_duckiebot/out/dt_account.html
  5. Assemble your duckiebot using the link below and tips from the slides in class. Demonstrate your assembled Duckiebot to the instructor in class or office hours. Please do this even if you are borrowing a robot to verify there is no damage.
    DB18: https://docs.duckietown.org/daffy/opmanual_duckiebot/out/assembling_duckiebot_db18.html
    DB19: https://docs.duckietown.org/daffy/opmanual_duckiebot/out/assembling_duckiebot_db19.html
    DB21:
    https://docs.duckietown.org/daffy/opmanual_duckiebot/out/assembling_duckiebot_db21m.html
    You should demonstrate this step as soon as you complete it so that we can catch problems early!
    Suggested completion: Feb 8, 2022
  6. Now we need to initialize your duckiebot. This involves flashing data to your sd card, inserting it into the raspberry pi, and leaving it running, connected to internet, for some time. During this process, your duckiebot will download updates and new packages. Follow the instructions in this link through step 3.6 then STOP and move on to the next step in the lab
    WARNING: Be careful when you select which partition to flash to! You very likely want to select /dev/sdb, which should be exactly the size of your SD card. It is very unlikely that you want to select /dev/sda as that probably contains your root partition. This can be confusing in Linux so post on slack or ask in person if you have any questions. It may be best to start this step in the lab (just make sure you have enough time for it to run).
    https://docs.duckietown.org/daffy/opmanual_duckiebot/out/setup_duckiebot.html
    NOTE: if using a vm make sure adapter is bridged (Step 3). You will also need to share your USB SD card adapter with your VM.
    NOTE: Give your robot a unique name. (NOT “duckiebot”)
    NOTE: This step may take considerable time. It is best to start booting your robot with a FULL battery and in a location where it can be connected to the internet for several hours. It may only take 5 min, depending on internet speed. It could take a few hours.
    You will ultimately be running the commands below:

    dts init_sd_card --hostname <duckiebot_name> --wifi duckietown:quackquack,<myhomenetwork>:<myhomepassword>
    ping <duckiebot_name>.local

    (if running this from a VM and it fails, try from your host system as well).

    dts fleet discover
    ssh <duckiebot_name>

    If ssh doesn’t work, then you don’t have your ssh configured correctly. Refer to course slides to set it up properly.
    Suggested completion: Feb 10, 2022

  7. Your duckiebot has several tools to help you debug problems and setup configurations. The dashboard allows you to see basic information about your robot. Finish setting it up and learn about it here: https://docs.duckietown.org/daffy/opmanual_duckiebot/out/duckiebot_dashboard_setup.html
  8. The portainer interface lets you see which Docker containers are running on your robot from a web browser. Learn about it and other dashboard features here: https://docs.duckietown.org/daffy/opmanual_duckiebot/out/duckiebot_dashboard_use.html
  9. Now it’s time to make your robot move.
    NOTE: if your robot does not move forward when you press the up arrow, left when you press left, etc, then it is wired incorrectly! Review the assembly instructions again and fix it. Follow Option 1 on these instructions to make your robot move https://docs.duckietown.org/daffy/opmanual_duckiebot/out/rc_control.html
  10. At this point, it’s helpful to learn how to connect to the ROS master running on your Duckiebot. You can use dts start_gui_tools to get a terminal interface to your robot that lets you use command line ROS tools. You can also set it up so that you can connect to a GUI interface via a web browser (if in a VM, you can use a browser outside of the VM as long as you find the IP address of your VM first). Read about this interface here: https://docs.duckietown.org/daffy/opmanual_duckiebot/out/using_no_vnc.html
  11. Calibrate your camera so that your duckiebot can see the world around it. Ensure that it is in focus first by twisting the lens while looking at the initial calibration window in the instructions below until the image is sharp. https://docs.duckietown.org/daffy/opmanual_duckiebot/out/camera_calib.html
  12. Calibrate your wheels so your duckiebot can drive straight: https://docs.duckietown.org/daffy/opmanual_duckiebot/out/wheel_calibration.html
  13. (Optional) Use the following instructions to create some Duckietown tiles. Pay attention to the lane sizes! You will need a ruler. For best results, you should make a loop, preferably 2 tiles by 3 tiles in size or bigger. This will be four corner tiles and two straight tiles.  https://docs.duckietown.org/daffy/opmanual_duckietown/out/dt_ops_appearance_specifications.html
  14. Now let’s put it all together and start the lane following demo. We’re going to do this by manually starting a docker container on the robot and running each step by hand. At the end of these instructions, you can find a way to do it with dts tools that is simpler, but less instructive and with less feedback. To start, place your robot in a lane.
    1. Let’s see what is running on your robot first. In a terminal, run:
      $ dts start_gui_tools <duckiebot_name>

      When that starts you will have a connection to the ROS instance on the Duckiebot and can use debug tools. Run:

      $ rqt_graph

      And you should see a graph of all nodes and topics. Save an image of this graph (as legible as you can get it) to turn it in.

    2. Start keyboard control as in step 8.
    3. Open a terminal, change to your repo directory on your Linux system, and build your container on your Duckiebot using this command:
      $ dts devel build -H <duckiebot_name>.local --pull

      This step may take some time to run the first time as it is pulling images and code onto the robot. Be patient and ask on Slack if you need any help. If this step hangs for too long or your Duckiebot crashes, try running this before the above command:

      !!!OPTIONAL COMMAND BELOW!!!

      $ docker pull duckietown/dt-core:daffy
    4. Start your container on your robot with:
      $ dts devel run -H <duckiebot_name>.local -s -M --cmd bash

      The -H flag tells dts to run the container on another system, in this case, the Raspberry Pi or Nvidia Jetson on your robot. The -s flag syncs your code to the robot. We’ll cover this in more detail in Lab 2.

    5. This should look just like your container on your computer used in HW1 and HW2. We’ll follow the same steps here. Source your environment:
      $ source /code/catkin_ws/devel/setup.bash
    6. Instead of running “catkin build” directly here, we are going to run a script created by Duckietown developers to keep the thread count low when building. This essentially runs catkin build in only two threads:
      $ dt-launcher-build
    7. Source your environment again
    8. Now start the lane following demo. This will not make your robot move until you tell it to using keyboard control (we’ll get to that in a few steps).
      $ roslaunch duckietown_demos lane_following.launch

      Wait for the messages to stop (You should see health status change to “STARTED” at the end)

    9. In your start_gui_tools terminal (Step 14a) run “rqt_graph” again. What has changed since the last time you ran it? Turn in an image of this graph as well.
    10. In keyboard control, while selecting the window, press ‘a’. The robot should now move around the track. Press ‘s’ to stop. Note that the robot does not handle intersections in this mode. Ensure that it follows lanes or recalibrate until it does.
    11. Note that you can also start the demo using the dts tools but you will not receive as much feedback: https://docs.duckietown.org/daffy/opmanual_duckiebot/out/demos.html
    12. Demonstrate lane following to your instructor in class or office hours before the due date.

PART II

  1. Start your robot but do not start the lane following demo.
  2. Look at the topics running on the robot. Pay special attention to the topics that move the wheels. Use rqt_graph and the rostopic tools to investigate.
  3. Find a topic and message type that make the wheels move. There are a few options here. Use the rostopic pub tool to move the wheels using the topic and message you found. Any topic that results in moving the wheels is acceptable.
    1. Which topic did you use?
    2. What message makes the wheels move straight?
    3. What message makes the wheels stop?
    4. What message makes the wheels turn right?
    5. What message makes the wheels turn left?
  4. Now start the lane following demo. Do NOT start the robot moving (do not press ‘a’). Does your topic above still make the wheels move?
  5. While the lane following demo is running, look at the topics carefully. There should be two “control” topics that a node called “car_cmd_switch_node” listens to. Experiment with your Duckiebot in both lane following and manual control. How do the two topics change? Which topic is used when? What do you think this node does?

Submission

PART I

  1. The name of your duckiebot
  2. Demonstration of your assembled robot
  3. Demonstration of your robot lane following
  4. The output of rqt_graph in 14a and 14i
  5. Write a few sentences about what happens on the robot when you run lane following. Which nodes start and how are they connected to what was running on the robot before? What do you think each of these new nodes does?

PART II

  1. Answers to Step 3 questions.
  2. Answers to Step 5 questions.

 

NOTE: you must demonstrate your robot in person to get full credit! If you are unable to schedule a time in person please contact the instructorASAP.

Rubric

PART I

  • Demonstrations:
    • Assembled Duckiebot: 25 points
    • Video of lane following: 45 points
  • Graphs from steps 14a and 14i: 20 points
  • Answer to question 5 above: 10 points

PART II

  • Answers to Step 3 questions: 25 points
  • Answers to Step 5 questions: 25 points