Lab 2 Open Loop Control


Lab 2 will ask you to program your robot to perform a few maneuvers using open loop control. The instructions at the end of this assignment are one way to do this but not the only way. You will be graded on whether your code, video, and other submissions meet the specifications below, not on following the instructions exactly.

This lab requires that you create:

  • A new package to hold your open loop control code
  • A node or nodes that perform the following maneuvers:
    • Drive straight for 1m then stop
    • Drive in a 1m diameter circle then stop
    • Drive in a 1m square then stop
  • A launch file to start each of these maneuvers
  • Your code MUST use the Duckietown FSM node to allow joystick control to take over. Unless you want to experiment with the config file for the FSM node (optional), your code should:
    • Publish to the same topic that lane_controller_node sends to car_cmd_switch_node
    • Listen for the mode switch from FSM node to begin your pattern

Submission Instructions

Submit a PDF to Blackboard with the following information.

Answers to the questions:

  1. Provide a link to your repo and the tag that corresponds to this code (2 points)
  2. What node selects which command (joystick or lane following) to run on your Duckiebot? Justify your answer. (2 points)
  3. What do you think car_cmd_switch_node does? (2 points)
  4. What do the inputs to car_cmd_switch_node look like? You can focus on the joystick input here. Move the robot around and watch it change. Describe the components of the message (data types) and their purpose. (2 points)
  5. At some point, the command is converted from linear/angular velocity to commands for the left and right wheels. Which node does this? (2 points)
  6. During Lab 1, you calibrated the wheels. Which node do you think accepts this calibration value and adjusts commands as needed? Justify your answer. (2 points)
  7. What difficulties did you have in tuning your robot to make a pattern? (4 points)
  8. Do you think you could make your robot reliably drive around a circular/oval track like you have at home without any feedback from the camera? Why or why not? (4 points)

Post in #demonstrations on slack and also turn in:

  1. Link to the video of your best attempt at the 1m straight line
  2. Link to the video of your best attempt at the 1m circle pattern
  3. Link to the video of your best attempt at the 1m square pattern



5 points: Package creation

20 points: Line node/launch file

5 points: Line precision (may not be completely straight)

20 points: Circle node/launch file

5 points: Circle precision (mostly graded on uniformity of shape, not scale)

20 points: Square node/launch file

5 points: Square precision (mostly graded on uniformity of shape, not scale)

20 points: Answers to questions

Detailed Instructions

  1. Apply the updated course template to your robot: Updating From Template
  2. Experiment with your robot to answer the questions above. Start it up, start the lane following demo, and move it around with keyboard_control. Refer to Lab 1 if you have any problems here.
  3. Start your container and create a new package for this lab in the “packages” folder of your repo. Note that you will need to add duckietown_msgs as a dependency. This can be added to the end of the catkin_create_package command that you used before.
  4. Create a new node in that package that publishes a command in the right format for car_cmd_switch_node to accept. Do NOT include the vehicle name in the topic, use a namespace in your launch file as shown below instead. This will allow your code to be run on any vehicle. Select values that make your robot drive ~1m in a straight line. You will have to guess in this first trial, we will test in the next few steps. Make sure that you make this node executable
    $ chmod +x <node_name>
  5. Create a launch file for your node such that it looks something like this:
      <group ns="$(env VEHICLE_NAME)"> 
      <include file="$(find fsm)/launch/fsm_node.launch">
            <arg name="veh" value="$(env VEHICLE_NAME)"/>
            <arg name="param_file_name" value="lane_following"/>

    This will start your node inside the namespace for your robot.

  6. Commit these files. At this point, you can exit your container as we will do the rest on the robot
  7. Start up your robot. We need to build the container with this new package in it, but we want to build it on the robot this time instead of on your laptop. Run:
    $ dts devel build -H <duckiebot_name>.local --pull

    The first time this command runs it may take a while. To get some additional feedback, you may want to run this first to download the core docker containers:

    $ docker -H <duckiebot_name>.local pull duckietown/dt-core:daffy-arm32v7
  8. Now we need to run the code. Start the container on your robot with:
    $ dts devel run -H <duckiebot_name>.local -s -M --cmd bash

    The -s flag copies your repo to the /code folder on the robot so that it can be mounted by the -M flag and you do not need to rebuild for every small change.

  9. Run your code within the container you just started on your robot. You should be able to see that the robot moves with joystick control but your code moves the robot when it is in autonomous mode. If not, debug! You can use
    $ dts start_gui_tools <duckiebot_name>

    to figure out what is going on using standard ROS tools.

  10. Revise your code until it can reliably drive 1m in a straight line then stop. The slides provide additional information for syncing code with your robot.
  11. Follow these instructions to create two more nodes and launch files in the same package to drive in a 1m diameter circle and 1m square. Tune them until they perform acceptably.