Programming Elegoo Smart Robot Car v4.0 | Part 2

Поделиться
HTML-код
  • Опубликовано: 4 окт 2024
  • In the 2nd episode of my bots4all series, I am going to describe how to program the Elegoo Smart Robot Car V4.0 in Python. I will show how to get the camera images, the distance measured by the ultrasonic unit, and the MPU data from the car into Python through WiFi. I will also show how to code a simple obstacle avoidance mode in Python.
    The code is in
    github.com/bot...

Комментарии • 24

  • @erik6165
    @erik6165 Год назад +1

    Oh, boy, you are genius! Keep going!

  • @martianvenusian6894
    @martianvenusian6894 7 месяцев назад +1

    This is a great tutorial love it

  • @ezrakoper
    @ezrakoper 5 месяцев назад +1

    What is missing in the intro is that you will use the car as a dumb instrument with all the intelligence running in the PC on python

  • @giorgioguglielmone6528
    @giorgioguglielmone6528 Год назад

    I managed to create 2 programs, which I then want to merge into one, to pilot the rover robot and see the camera images, using Qt 6.5 in C++ , inserting command strings without using Json. If you're interested, I can pass them on to you, so if you want you can get your hands on them :-)

    • @elmehdieladraoui6264
      @elmehdieladraoui6264 7 месяцев назад

      Hi Giorgio,
      Is there anyway I can contact you about the code? I'll be happy to hear from you!

  • @thomas2004ch
    @thomas2004ch Год назад

    great!

  • @elmehdieladraoui6264
    @elmehdieladraoui6264 7 месяцев назад

    Hello, Thanks for the Video.
    I just have one question please, the car comes with an installed (arduino) code. So when you started to programing it with Python, what happens to the pre-installed Code (Arduino)? Is it overwritten through Python?
    Thanks in advance.

    • @bots4all
      @bots4all  7 месяцев назад

      The embedded Arduino code is still there and used by microcontroller to control its functions like WiFi communication, responses to commands and sensor inputs, etc. It's like the brain of the car. The Python code on my laptop is just an interface between me and the car, telling the car what to do in different scenarios as a sequence of commands sent over WiFi to the car microcontroller. The Arduino code understands those commands and converts them into actions.

  • @jorgeyama9170
    @jorgeyama9170 Год назад

    I have a problem, it desconects from the server when it starts to move; ConnectionAbortedError: [WinError 10053] An established connection was aborted by the software in your host machine, I dont what it is the problem

  • @anandchougule4012
    @anandchougule4012 7 месяцев назад

    what kind of basic knowledge is required before programming the robot in python and all the image processing stuff??

    • @bots4all
      @bots4all  7 месяцев назад

      You can start with zero knowledge of Python and learn it on the go, by setting small goals, finding code examples, and trying them. For example, I started with a goal to make my laptop talk to the Elegoo robot car. I didn't know anything about WiFi or Python programming. But I found several Python codes that seem to fit my goal. Through trial and error, I made my WiFi communication code work. Next, I set the goal to get the images from the car camera. Again, I found code examples and made them work. I still don't understand every single line in my codes. ChatGPT became a valuable tool to get Python snippets by telling it what I want the code to do.

    • @anandchougule4012
      @anandchougule4012 7 месяцев назад

      @@bots4all would you suggest which videos are those
      Could you please send me the link to few of these videos

  • @KevinDane-np4dg
    @KevinDane-np4dg 4 месяца назад

    When I launch the spyder script, the car moves for half a second and then it stops with the error message: ConnectionAbortedError: [WinError 10053] An existing connection was terminated by the host computer under software control. Any idea how to fix this?

    • @bots4all
      @bots4all  4 месяца назад

      You need to fix the ESP32 Arduino code as described in Part 1, 4 minutes and 36 seconds into the video (Change 3: Disable Checking for Heartbeats).

  • @softnessoverloaded7369
    @softnessoverloaded7369 Год назад

    Hi when you run your obstacle avoidance code, which mode is your car on (like the car has 4 default modes)?

    • @bots4all
      @bots4all  Год назад

      When I use my Python code, the car is in the standby mode. I just simply turn on the car's battery and then launch my Python obstacle avoidance code. The internal obstacle avoidance code is bypassed. All commands of moving, turning, stopping, and measuring the distance are coming from the Python code.

  • @giorgioguglielmone6528
    @giorgioguglielmone6528 Год назад

    When I send the command to turn the robot to the right or left, it executes it but for a short period of time, so it executes an angle of about 25 degrees. How can I turn it 90 degrees ?

    • @bots4all
      @bots4all  Год назад

      I was planning to have another episode describing how to do turning very accurately. The present way to rotate the car by giving a certain time for rotation is dependent on the car speed, which can vary a lot with the battery charge level. I made a new command in my Python code, which sends a -180 to 180 degree angle to which the car should rotate in place. In ApplicationFunctionSet_xxx0.cpp, I created a new mode yaw_control. When the car receives the command to rotate by the desired angle, first it measures its present yaw angle, let's call it yaw0. Then the speed of either the left wheels (if turning to a negative angle) or the right wheels (if turning to a positive angle) is set to max and the speed of other wheels is set to zero. The car starts rotating. The rotation is stopped when the present yaw is different from the starting yaw0 by the desired angle. The whole loop in ApplicationFunctionSet_xxx0.cpp is running pretty fast, at about 10ms each run. So, you get the yaw measurements every 10ms. However, in those 10ms, the car can still overshoot the desired angle by a few degrees. Measure the overshoot and subtract it from the desired angle. In may case, the overshoot is 12 degrees.

  • @RelaxAmbientMusic
    @RelaxAmbientMusic Год назад

    When I import "cv2", It tell me that there isn't any module name's cv2. Can you help me? Thanks so much

    • @bots4all
      @bots4all  Год назад +1

      Python comes with standard modules preinstalled. The other modules such as OpenCV have to be installed manually. To install OpenCV, please follow instructions here: pypi.org/project/opencv-python/.
      The installation of OpenCV or other modules in Python depends on how you installed Python. In most cases, starting Windows cmd and typing "pip install opencv-python" (without quotes) would do the job. If you use Anaconda or Miniconda as your Python environment, you need to start Anaconda Prompt (instead of Windows cmd) and type "conda install -c conda-forge opencv".
      I am now using Anaconda 3 in Windows 10 because Anaconda seems to be more successful at installing packages with dependencies that work. The whole process of installing Anaconda, Python and Spyder for me was something like this.
      1. Install Anaconda 3 first from here: www.anaconda.com/products/distribution. It will come with its own Python (Anaconda's current Python version is 3.9 even though the latest stand alone Python installation is version 3.10)
      2. Open Anaconda prompt and install Spyder by typing "conda install -c anaconda spyder". The Spyder icon will appear in the Windows start menu under Anaconda3 folder. I moved it to the task bar for easy access. (for more info on installing Spyder see here docs.spyder-ide.org/current/installation.html)
      3. Install all modules that your Python code in Spyder would use by typing "conda install -c " in the Anaconda prompt.
      If you installed Spyder as a stand-alone application, it came with its own Python (I think current version of that Python is 3.8). And if you use the Spyder's Python, you need to install all modules in the Spyder console window. For example, for cv2, you would type "pip install opencv-python" in the Spyder's console.
      Because of many ways to install Python on your computer, all of which use different file locations, it may become very confusing where to install all additional modules. You need to know which Python your environment is using and install all additional modules in THAT environment. To add to the confusion, in Spyder you can freely switch between different Pythons on your PC by going into the Tools/ Preferences / Python interpreter menu and switch from the default interpreter to any other Python installation. But you have to be careful to make sure that those Python installations have the modules that you need installed.

    • @bots4all
      @bots4all  Год назад +1

      One word of advice: don't install "opencv-python-headless". The "headless" modules had some collisions with other modules I installed later.

  • @adammachacek8536
    @adammachacek8536 Год назад

    anybody has code i can copy
    also what if you want to use arduino IDE

  • @cheikhkallaseck6503
    @cheikhkallaseck6503 Год назад

    can u send me the url of the code

  • @DevSanghavi-h3i
    @DevSanghavi-h3i 10 месяцев назад

    Hi