In today’s webots tutorial video, we are doing a fun project of line follower robot. A line following robot is a great way to get started with robotics and only requires level 1 coding skills.

We will start by setting up our environment in webots. Next we will add a robot from the webots library which is e puck and add IR sensors. Then we will write our code which is controller in webots in python. I will go over how to detect the line using IR sensors and use those values to make a line following robot in Webots.

========== TIMINGS ==========

0:00 Intro
0:54 Set up the environment
1:12 Add e-puck robot
1:40 Adding IR sensors
3:26 Adding Line (Track)
4:55 Writing controller (Python)
6:04 How IR sensors work?
6:40 Reading IR values
7:50 Line follower robot
9:27 Common problems with line follower

If you enjoyed this video, give it a like and tell me your thoughts in the comment below.

========== USEFUL RESOURCES ==========

๐Ÿ‹ Link to download track one (proto node)
https://github.com/KajalGada/Youtube-Tutorial-Download-Material/tree/main/Line%20Follower%20Webots%20Tutorial

๐Ÿ‹ Track one was created from CAD model by DragerDG Robotics. Link to youtube channel:
https://www.youtube.com/user/DrakerDG/videos

๐Ÿ‹ List of functions available inside controller in Webots for Python:
https://cyberbotics.com/doc/reference/robot?tab-language=python#wb_robot_get_device

๐Ÿ‹ Information about distance and infra-red (IR) sensors in Webots:
https://cyberbotics.com/doc/reference/distancesensor

๐Ÿ‹ Catch the entire webots tutorial video series here:

๐Ÿ‹ How to write a controller in Webots in Python to enable motors and drive a differential drive robot?

๐Ÿ‹ How to drive (straight, turn in place, wide turn) differential drive robot in Webots?

========== RELATED VIDEOS ==========

๐Ÿ‹ Webots Line Follower Code in C++ // Webots Tutorial

๐Ÿ‹ Webots Tutorial Series in Python // Get started with Robotics using Webots

๐Ÿ‹ Webots Tutorial Project Wall follower robot using e-puck // Controller code in Python

๐Ÿ‹ Webots ROS2 Tutorial

========== CONNECT WITH ME ==========

๐Ÿ‹ If you have a question or doubt about this video, use the comment section.

๐Ÿ‹ If you have questions about Robotics, job search, Webots, etc, read this on
how to contact me: https://kgada.info/contact/

My social media links:

๐Ÿ‹ LinkedIn: https://www.linkedin.com/in/kajalgada/

๐Ÿ‹ Instagram: https://www.instagram.com/kajalgada/

๐Ÿ‹ Facebook page: https://www.facebook.com/Kajal-Gada-Youtuber-112066216999576/

๐Ÿ‹ For more on studying robotics and working in the USA, join our facebook community: https://www.facebook.com/groups/roboticsinusa/

========== ABOUT ME ==========
I am a Robotics Engineer. My goal is to develop algorithms for realizing robot operations in the real world. And it is just absolute fun to code and solve problems. Read more about my projects work at https://kgada.info/

I started my journey in Robotics by working on small personal projects such as a line follower with an arduino. I then pursued and graduated with a Masters in Robotics from University of Maryland in 2017.

After graduation, I have worked at Reality AI, Qualcomm and Brain Corp. With 3 years of professional experience, I understand that one of the biggest challenge in Robotics is implementation of algorithms in the real world and that is where my expertise are. Digging in at ground zero to implement solutions.

I spoke about my experience as a roboticist at Brain Corp on the RoboHub podcast, check it out here: https://robohub.org/commercializing-robot-brains/

I am also a YouTuber, it is my way of giving back and helping the community grow. As a women and an international student in the US, I am aware of the challenges to break through and have a successful career. I share my insights and also teach robotics through my youtube channel.

Subscribe to my youtube channel: http://youtube.com/kajalgada?sub_confirmation=1

========== Gear I usually use ==========

๐Ÿ‹ Camera: YI 4K Action and Sports Camera
๐Ÿ‹ Camera: iPhone XS
๐Ÿ‹ Tripod: Ravelli APLT6M 72″ Light Weight Aluminum Tripod
๐Ÿ‹ Lights: Neewer Ring Light Kit
๐Ÿ‹ Mic: SoLID Lavalier Lapel Microphone
๐Ÿ‹ Recording: Voice Memo App on iPhone or Mac
๐Ÿ‹ Editing Software: Final Cut Pro X
๐Ÿ‹ Thumbnail Designs: Canva

========== Credits ==========
๐Ÿ‹ Like & subscribe short clip in the end:


, https://i.ytimg.com/vi/D0jhvFZJ5Ok/hqdefault.jpg

source

35 Comments

  1. the same project while I'm doing and running, facing indentation errors ma'am. The same program only I'm typing. Then how ma'am? @kajalgada ma'am. facing problems in lines 21 and 34

  2. What would happen if use this code for the 2 wheel differential drive robot? Will it work?

  3. Hi kadjal, did you ever try to transfer code from webot to real epuck cause I'm having communication problem

  4. I followed the tutorial but my robot doesn't follow the line instead it goes straight (I imported my own track from thinkercad) don't know if that effects it. Please help

  5. INFO: my_controller: Starting controller: python -u my_controller.py
    File "my_controller.py", line 27
    left_speed = max_speed
    ^
    SyntaxError: invalid syntax
    WARNING: 'my_controller' controller exited with status: 1.

    I am getting this?

  6. Hi, anyone knows how to make your robot go to one point to another. I've been trying a lot of things but can't do it. There isn't much tutorials of webots on the internet so there isn't much i can do. If anyone knows, if they can help me pls ๐Ÿ˜€

  7. i have tried implementing your tutorial in webots but both my infrared sensors are showing the exact same value and it does not follow th liner can you help

  8. this is excellent tool and nice explanation, I am in search of any such tool thanks for sharing..

  9. Thx for sharing. but I have some problem about syntax error. The console says me (left_speed = max_speed * 0.25

    ^

    SyntaxError: invalid syntax)
    this error. I wrote same code as you. Can you help me?

  10. If obstacle are there , how to do the controller for the robot to detect the obstacle and get back to the line again?

  11. How can we get the robots position and orientation directly and then set some coordinate (x,y,theta) so that our robot moves towards that coordinate directly instead of setting speed.

  12. Where is the error?
    left_ir_value = left_ir.getValue()
    ^
    IndentationError: expected an indented block
    WARNING: 'my_controller_line_follower' controller exited with status: 1.

    python code:
    while robot.step(time_step) != -1:

    left_ir_value = left_ir.getValue()
    right_ir_value = right_ir.getValue()

  13. Hello, when I download the track, it downloads as a text file so I cannot open it on webots. What can I do?

  14. Thx for sharing. Would be great to add also obstacles so that robot avoid them and get back to the line.

  15. Hi Mam, another very helpful tutorial!
    At 8:02, you have reset the simulation, however when I do so, e puck and track disappears from the simulation, what can be the reason?

  16. Traceback (most recent call last):

    File "controller_linefollower.py", line 5, in <module>

    from controller import Robot

    File "D:Webotslibcontrollerpython37controller.py", line 31, in <module>

    import _controller

    ImportError: DLL load failed: The specified module could not be found.

    WARNING: 'controller_linefollower' controller exited with status: 1.

    im getting this error. please help

Leave a Reply

Your email address will not be published. Required fields are marked *