Pi-top [4] Robotics Kit Challenges - Line Follower - Help and Feedback

Hi all!

Now that the pi-top [4] Robotics Kit is out in the wild, we’re releasing challenges in Further that we’d love to get your feedback on!

The challenges are built with beginners in mind, but they should still be quite interesting regardless of your skill level. Even if you are a robotics expert, they’ll at the very least introduce you to some of the functionality available in our Python SDK that you can use in your own projects.

The first series we are releasing goes through, step-by-step, building an OpenCV-based line follower with the Alex Robot.

You can check them out here and we’ll be adding more over the coming weeks.

Feel free to ask for help on completing any of the challenges in this topic. If you spot any bugs or have any feedback we’d love to hear it! :+1:

1 Like

Performed this lesson today, enjoyed it. Had a few problems but was successful in identifying it to be a wiring problem, had tilt / pan wires crossed. The pi-top[4] rebooted in the middle of the last section, I thought it might be related to the battery, but when I powered it on there was 84% battery left. When it completed the start-up an update was loaded immediately. Looking forward to part 2 to appear.
Thanks Pi-Top Team - good job.


Hi @Korbendallaz, thanks so much for the feedback! That reboot issue is very strange, I’ve never seen that before - I wonder if it could have been related to a motor overcurrent? We have protection built-in for that but in extreme or repetitive cases it’s feasible it might cut the power to the pi-top.

Part 2 and 3 are ready to go, we’ll be putting them live today so I’ll let you know when you can access them :grin:

Hi @Korbendallaz, part 2 is live!

I’ll probably release part 3 tomorrow or Friday as I want to make sure it’s consistent with part 4 before I do - let us know what you think and if you get any issues! :+1:

Thank you for the heads up - I spent several hours on part 2. Having several problems with it, but, that may have more to do with me understanding how to accomplish the task using the knowledge gained in parts 1 and 2 than a problem with the lesson or Alex.
Wife still hasn’t seen the blue tape on the basement carpet!

1 Like

Continued working on part 2 this afternoon, powered up the Pi-Top[4] and there was an update available, installed the update, then rebooted. Pi-Top[4] came up and another update available. Updated the system and then rebooted. Pi-Top[4] is up; I started Further on my PC and connected to the Pi-Top[4]. decided to go back to part1 to review the movement commands, loaded the first example on George (my Alex) the robot started to move and then I received a connection error to George. The Pi-Top[4] had powered off.
Powered the Pi-top[4] up (no update available), restarted Part 1 movement controls, everything seems to be working fine. Open Part 2 and made changes to ‘Following the Line’ won’t even start, the following errors were displayed: (seems I can’t copy the error messages using ctrl+C), used MS 10 Snip & Sketch.
hopefully the 3 uploads work. Would have been easier if I could have copied and pasted from within Further. I pressed reset on the program so there was no editing from me and received the same errors. Yesterday it worked (not correctly) but today wouldn’t even start. Curious about the 2 updates that were available today? I updated yesterday as well.

I have further questions concerning Further, but I’ll address them in different correspondence.

Hi @Korbendallaz, thanks for the feedback - we are updating Further soon to be able to copy and paste from the console there - sorry for the inconvenience! From the errors, it looks like it’s struggling to open the SPI port for the OLED mini screen. Can you run the following:

pi-top oled spi

and also the following:

ls /dev/spi*

and send me the outputs of both? You can run these commands directly on the Pi in a terminal window.

It seems you are getting a lot of power cuts to the pi-top [4] as well - did you ever see this behaviour without the Expansion Plate attached? We could also try disconnecting all the servo motors and encoder motors to see if you still get that behaviour.

pi@pi-top:~ $ pi-top oled spi
pi@pi-top:~ $ ls /dev/spi*
/dev/spidev0.0 /dev/spidev0.1
The power cuts, have never happened before I received the new expansion plate. I have the first plate and normally ran the Pi-Top with it attached.

Well, I’ll disconnect the motors when its needed.
I have another Pi-Top if we need to try that one, it’s a DIY 8GB.

Hi @Korbendallaz try running:

pi-top oled spi 1

and then trying the Further challenge again, let me know if you get the same error!

Ran the suggested code and the error messages have disappeared - thank you!. Back to where I was trying to Follow the Line and not being very successful at it. I’ve re-performed all of part 1 (twice now) and I understand how it moves, but I keep thinking in distance instead of speed when moving forward, backwards, right or left. Have done part 2 several times up to Follow the Line and keep meeting the proverbial ‘road block’ on that step.

If I place Alex near the blue line and the camera is to the right of center; I figure Alex needs to turn (left) towards the blue line and then straighten out. The opposite coding when the camera is to the left of center. Alex starts off like a champ stays close to the line and them makes a hard right turn and goes where ever it wants to.

Using the edit function in Further is a Royal PAIN!!! Why is it when I go back to the Console and want to change something, the default location of the cursor seems to be at the EOF (end of file) always! I can scroll up using arrow keys or mouse; enter a character and the character is displayed and the next position available is back down to the EOF. Only way I have figured to work around this is create the code using mu on pi-top and having further opened on a PC connected to Alex. I copy and paste from Pi-Top to PC, Can’t wait until I can figure out how to replace the Further Module so I can just create code using Thonny or Mu.

I’m done venting - it sucks to be 70!

Hi @Korbendallaz, glad the fix worked - thanks for finding this as I’ve now raised a bug report so that this can be fixed for users in the future! :+1:

Here’s some sample code that you can use to compare results with your own:

from pitop import AlexRobot
from time import sleep
from further_link import send_image
from signal import pause
from pitop.processing.algorithms.line_detect import process_frame_for_line

def process_new_camera_frame(camera_frame):
    line_data = process_frame_for_line(camera_frame)
    robot_view = line_data.robot_view
    center = line_data.line_center
    if center is None:
        print(f"Line is lost!")
        x, y = center
        alex.forward(0.25, hold=True)

        if x < 0:
        elif x > 0:
        elif x == 0:

alex = AlexRobot()

alex.pan_servo.target_angle = 0
alex.tilt_servo.target_angle = 35

alex.camera.on_frame = process_new_camera_frame


Make sure your servos are calibrated - especially the pan servo. If it’s not in the centre when you set the angle of zero you’ll get strange line following behaviour.

That’s very strange behaviour with the EOF cursor issue, which browser are you using? If you stop the code running and then edit it should be just like any other IDE - at least it is on my end, I’m using Google Chrome.

@Korbendallaz I’m also seeing the cursor issue now - this must have been introduced on a recent update. We’ll get this fixed ASAP, sorry for the inconvenience!


Ok, performed the ‘ Calibrating your Servo Motors ’, both were off by -5. Ran ‘ Follow the Line ’ using your sample code (which was different from mine). Alex moved to the left and then the right while moving forward for about 5 seconds and Alex made a sharp 90 degree turn to the right and stopped. Message displayed was Code Run Successfully ! Placed Alex back on the blue line and ran the sample code again, watching Alex move. Right, Left, then the pan server turned to the right and Alex took off in that direction and Code Run Successfully!

Placed Alex back on my desk and ran the calibration program – both servo motors were off by -5. After the calibration completed. I ran it again and both servos were off by -5 again?

Shut Down Pi-Top 4GB, replaced with Pi-Top 8GB on Alex’s expansion plate. Performed System Update. Rebooted and connected Further to Alex. Ran the calibration process of the Servro Motors (first time). Calibrated. Ran the process again - they were both off by -5? Reset and process completed. Looked back to Alex and the Pan Servo was turned to the right about 45 degrees and the Tilt was looking up about 45 degrees. Confused?

Placed Alex on the floor started Follow the Line program, Pan and Tilt reset; Alex moved forward then Right, Left, for a few seconds then made a drastic turn to the left over the line then stopped. Code Run Successfully!

What am I doing wrong…. Getting ready to shoot Alex!


Hi @Korbendallaz

Does “Line is lost” get printed out at all? Is the video feed coming back to Further showing that the blue line is being successfully detected?

The servos shouldn’t be moving at all during the program running, they should move once at the start and that’s it - the code should then keep running until you press the stop button. Could you send me a photo of your robot’s pan-tilt mechanism? And also ensure that the pan servo is connected to S0 whilst the servo is connected to S3.

Alternatively, I’m happy to have a call to go through the issues and resolve them - send me a direct message and we can set one up :+1:


Powered-up, system update - Yes, Tried running Follow the Line step 2 and received errors:
Loaded up Step 1 to run the Calibration of the Servo Motors. exact same error. I’m stymied until the calibration problem is identified.

In response to our last conversation, The ‘Line is lost’ is printed if I move Alex away from the blue lines, the message ‘Line is lost’ is printed about 5 times before Alex stops. When Alex starts from the position I set him down on, Right is printed 5 times, then left is printed 12 times, right is printed 6 times; by then it has traveled away from the line and has stopped on its own. Middle is rarely printed and if it is printed, it is once or twice only. When the robot moves off the line ‘Line is Lost’ is not printed Alex just stops.

20210123_121532 20210131_180218 20210131_180253 20210131_180321

Tried to upload an mp4 file but unable to, the mp4 file was a 1:56 clip of Alex in action. The jpg’s are the views of the pan & tilt servos.