üApp: picar-s: basic integration of line-following and object avoidance

This task will focus on a basic integration of the existing line-following and object-avoidance scripts for the picar-s.

The following are the associated repositories:

  1. https://github.com/uberspark/uapp-SunFounder_PiCar-S.git branch uobjcoll
  2. https://github.com/uberspark/uobjcoll-SunFounder_Line_Follower.git branch uobjcoll

We will work on a new folder example/line_obstacle_integrated on the repository https://github.com/uberspark/uapp-SunFounder_PiCar-S.git



Once you make a new folder you will need to create symbolic links to the Python modules that are used by the Python script. You can use ln -s /folder/folder symbolic_name for this.
The original script is line_follower.py, but the modified one is line_follower_clib.py.
The second script uses a shared library written in C for the sensor reading calls.
This shared library needs to be built and the .so file needs to exist in the respective folder.
https://github.com/uberspark/uobjcoll-SunFounder_Line_Follower.git can be cross compiled on a Linux machine and the .so transferred to the Raspberry Pi with scp.
https://github.com/uberspark/uapp-SunFounder_PiCar-S.git has to be cloned on the Pi, because this is where it is run. If you need more information please post questions, because it is hard to anticipate what information you may need for your progress. Any question that saves you time and takes two minutes to answer is a step forward.

Hi @Arbalest1027 ,

Please use the following steps to build your bangbang-integrated controller feature branch and to submit PRs

  • On your fork of uobjcoll-SunFounder_Line_Follower.git create a feature branch feature-bangang-integrated based off the uobjcoll branch
  • add the required code changes
  • add a README and add your initial graphs for measurement
  • push your feature branch to your fork’s remote (e.g, git push origin feature-bangbang-integrated)
  • go to github web UI on your fork and the feature-bangbang-integrated branch and the UI will give you the option to do a compare and pull-request to the upstream uobjcoll-SunFounder_Line_Follower.git on branch uobjcoll

Let me know if that helps.

I have just made a pull request for review.

Thanks @Arbalest1027 !

I gave the PR a quick review and have added a comment to the PR. Please check and resolve on the PR.

@antonhristozov : Can you please give this a test on your track when you get a chance? I can merge once you confirm this is working on your side.


Can you please point to the fork that you have so that I can test it out quickly?
I assume you have a README and everything is in a separate folder.

I added the PR to the OP. I believe there is a README here: example/SensorIntegration_sonic_linefollowing/README.md

There is a missing part that also needs to be checked in and the README.md needs
to be updated.
Here is the error that I get:

pi@raspberrypi:~/uapp-SunFounder_PiCar-S/example $ python3 Ultrasonic_stopandgo.py
Traceback (most recent call last):
File “Ultrasonic_stopandgo.py”, line 1, in
from SunFounder_Ultrasonic_Avoidance import Ultrasonic_Avoidance
ImportError: cannot import name ‘Ultrasonic_Avoidance’

@Arbalest1027 : Can you please address this when you get a chance?

@antonhristozov Updated the Readme a bit as the previous one got some mistakes. I saw previous people put Readme in their own folders so that’s what I did.
I can run it perfectly fine on my side. Would you be able to check if the folder SunFounder_Ultrasonic_Avoidance is empty after downloading from github, because this is the reason I cannot import anything at the beginning.

Yes, the problem is that SunFounder_Ultrasonic_Avoidance is empty and should not be.
We need to add files in it. You can add them to your fork/branch and they should be part of the PR that you have.

I believe this folder is a submodule and should be automatically populated when you do a git clone. The option to use for git clone in this case will be git clone --recurse-submodules. i.e.,

git clone --recurse-submodules https://github.com/uberspark/uapp-SunFounder_PiCar-S.git

Of course you have to modify the above command to use your fork instead of the upstream repository.

Thanks Amit!

Yes, I knew I could get this module, but if the repository existed on the Pi I had to get it on the PC and copy it over to the Pi, so that I can preserve the rest of the working stuff.
Was able to test the functionality and the car is moving and stopping if I put an obstacle.
My observations show that the speed is slow and most likely could be increased in future versions, but this code is good to be checked in as a base line.


PR merged upstream. Plugged merge info into OP. Closing task/topic thread.

Thanks @antonhristozov and @Arbalest1027 !