Assignment 4, Part 1 (Updated)

Introduction

This exercise is to be completed in the lab session.  A partially completed Python script is provided for you to complete.  All instances of the string “???” should be filled in appropriately.  Where multiple lines are to be filled in you will see the following:

???
???
???

This indicates a block of code that needs to be written, not necessarily three lines.

The task is to utilize elements from the previous two assignments (Assignment 2 on control and Assignment 3 on line extraction) to control the robot to follow the walls of its environment.  A new ROS node called ‘wall_follow’ will subscribe to the lines extracted by the ‘extract_all_lines’ node from Assignment 3 (actually the modified version in package comp4766_a3_mod).  It will select the closest line within a certain range of angles corresponding to the area in front-of and to the right-of the robot.  It will then generate a goal position described in the robot reference frame and continually attempt to reach this goal.  Note that we will constantly re-define the goal, so it will never actually be reached.

Step 1

Delete the existing version of comp4766_a3_mod on your ARbot’s netbook.  Replace it with this updated version.  The display_lines.py script has been updated to allow the topic subscribed to (formerly ‘/extracted_lines’) to be set via a ROS parameter.  Similarly, the visualization topics are now set via ROS parameters.  This was done to allow the script to show the particular line chosen by the wall following algorithm below.

Re-visit the instructions on the ARbot page to make sure that your robot is functional and you are able to control it and see the lines extracted by the comp4766_a3_mod package using rviz.

Step 2

You are recommended to do all of the following steps on the desktop computer, connected to your ARbot’s netbook using ssh (or using ssh -Y if you prefer a graphical editor).

Within the ~/catkin_ws/src directory on your netbook, execute the following to create the comp4766_a4_p1 package:

catkin_create_pkg comp4766_a4_p1

Now enter this directory and create a scripts subdirectory.  Download wall_follow_template.py and rename it to wall_follow.py.  Similarly, download smooth1_template.py and rename to smooth1.py.

Read through both scripts.  The majority of the work to complete is in the lines_callback function of wall_follow.py.

Step 3

Complete the first line of code in wall_follow.py labelled with question marks.  The comments in the file indicate the intent.   Test your code so far by launching wall_follow.launch.

You should test that you have selected the right line by adding a new “Marker” in rviz with its topic set to ‘/visualization_lines_wf’.  This marker will display only the line selected in wall_follow.py.  In order to see this line you will have to de-select the marker set to ‘/visualization_lines’ which displays all lines extracted.  Adjust your code until the only line selected is always to the right or ahead of the robot.  Manually shift the robot to test this.  Demonstrate this capability to the TA or instructor.

Step 4

Proceed to the next block of code required in wall_follow.py.  Follow the comments to set goalx and goaly.  The instructor will provide a diagram on the board to explain the required calculations.  Note that the robot should not move yet.  The idea here is to set the goal position and utilize rviz to display this position as published on topic ‘/goal’.  Demonstrate this capability to the TA or instructor.

 

Step 5

We will now let the robot actually move!  Just above where the goal of the smooth controller is set are two lines that set the goal position to (0, 0).  Comment out these lines so that the goal position computed in step 4 can be used.  Before proceeding to test the wall following behaviour, you will first need to adjust a couple of parameters in smooth1.py.  Start out by setting both to 1.  Then experiment and adjust.  Demonstrate the capability of your robot to follow the wall of the environment in the lab to the TA or instructor.