Lane following (LF)#

What you will need

What you will get

  • A Duckiebot driving autonomously in a Duckietown city loop, without other vehicles, intersections, or obstacles.

Expected results#

Outcome of the lane following demo.

A Duckiebot following the lane. from Duckietown on Vimeo.

Duckietown setup notes#

Before getting started, make sure your Duckietown is ready to go:

  • The layout adheres to the The Duckietown Operation Manual;

  • The lighting is “good”: ideally white diffused light. This demo relies on images from the camera and color detections, so avoid colored lights, reflections or other conditions that might confuse or blind the onboard image sensor;

Duckiebot setup notes#

Pre-flight checklist#

  • Place the Duckiebot inside a lane (driving on the right-hand side of the road), making sure it sees the lane lines;

  • Make sure no containers are running on the Duckiebot which use either the camera or the joystick. We will run these ROS nodes in a new container.

Demo instructions#

Start the lane following demo#

To start the lane following (LF) demo:

dts duckiebot demo --demo_name lane_following --duckiebot_name ![DUCKIEBOT_NAME] --package_name duckietown_demos

It will take a minute for the demo to launch. You can check Portainer if all the containers started successfully, and their logs if any issues arise.

Start driving autonomously#

Run the keyboard controller (not necessary if you have a joystick set up instead) and press the indicated key to initialize the driving behavior:

dts duckiebot keyboard_control ![DUCKIEBOT_NAME]
Table 2 Lane following demo start and stop commands#

Controls

Joystick

Keyboard

Start Lane Following

R1

a

Stop Lane Following

L1

s

In case intersections and/or red lines are present in the city layout, they will be neglected. The Duckiebot will drive across them like it is a normal lane.

You can regain control of the Duckiebot at any moment by stopping the demo using the (virtual) joystick. The demo can be resumed by pressing the start button.

Visualize the detected line segments#

This step is optional, and it provides a visualization of the line segments that the Duckiebot detects, and is useful to debug eventual weird behaviors.

  • Make the lane_filter_node publish all the image topics. The start_gui_tools will provide a shell that is connected to the ROS agent:

dts start_gui_tools ![DUCKIEBOT_NAME]
  • Run rqt_image_view and select the /ROBOT_NAME/line_detector_node/debug/segments/compressed. You should see something like this:

Outcome of the line detector node.

Line segment detections from Duckietown on Vimeo.

Troubleshooting#

Troubleshooting

SYMPTOM

The demo does not respond why pressing the start or stop buttons

RESOLUTION

Make sure the keyboard controller window is actively selected

Troubleshooting

SYMPTOM

The Duckiebot does not move

RESOLUTION

  • Check if you can manually drive the Duckiebot

  • Try re-launching dts duckiebot keyboard_control ![hostname]

  • Check if ROS messages are received on the robot on the ![hostname]/joy topic

Troubleshooting

SYMPTOM

The Duckiebot does not stay in the lane, or overall exhibits a bad driving behavior

RESOLUTION

This can be due to a number of issues, e.g.: bad robot calibrations, bad perception of lines due to inappropriate lighting or non-respected appearance specifications of the town, and/or bad tunining of the lane PID controller. The best way to debug this is to:

  • Check rqt_image_view and look at image_with_lines.

  • Check if you see enough segments. If not enough segments are visible, reset the Anti-Instagram filter.

  • Check if you see more segments and the color of the segments are according to the color of the lines in Duckietown

  • Check your camera calibrations are good.

Troubleshooting

SYMPTOM

The Duckiebot does not drive nicely through intersections

RESOLUTION

For this demo, there should not be any intersections in the city layout. Duckiebots will interpret intersections as “broken” lanes, perceiving less salient features, potentially compromising the state estimate hence causing the driving troubles.

Troubleshooting

SYMPTOM

The Duckiebot does not drive nicely through intersections

RESOLUTION

For this demo, there should not be any intersections in the city layout. Duckiebots will interpret intersections as “broken” lanes, perceiving less salient features, potentially compromising the state estimate hence causing the driving troubles.

Troubleshooting

SYMPTOM

The Duckiebot cuts white line while driving on inner curves (advanced)

RESOLUTION

This might be due to wrongly constructed lanes or bad Duckiebot calibrations. Fortunately, feedback control should take care of most of these problems.

While running the demo modify the PID controller gains from the base station through:

rosparam set /![DUCKIEBOT_NAME]/lane_controller_node/k_d -45
rosparam set /![DUCKIEBOT_NAME]/lane_controller_node/k_theta -11