Coder Social home page Coder Social logo

adeept_rasptank's Introduction

Getting Started with Raspberry Pi Robot and Python

1. Premise

1.1 STEAM and Raspberry Pi

STEAM stands for Science, Technology, Engineering, Arts and Mathematics. It's a type of transdisciplinary education idea focused on practice. As a board designed for computer programming education, Raspberry Pi has lots of advantages over other robot development boards. Therefore, Raspberry Pi is used for function control of the robot.

1.2 About the Documentation

This documentation is for software installation and operation guide for the Python robot product. It describes every detail of the whole process of fulfilling the robot project by Python and Raspberry Pi from scratch as well as some precautions. Hope you can get started with the Raspberry Pi robot on Python and make more creations with this documentation.

mermaid

2. Getting to Use the Raspberry Pi

2.1 Write the Raspberry Pi image to an SD card

2.1.1 Method A: Write 'Raspbian' to the SD card by Raspberry Pi Imager

Raspberry Pi Imager is an image writing tool to SD card developed by the Raspberry Pi Organization. It comes with many versions working on different systems and it's quite easy to use; all you need is choose the operating system and SD card, Raspberry Pi Imager will download the corresponding image file for the system and install it to the SD card.

Step-by-Step Overview

  1. Prepare an SD card (16G or larger) and an SD card reader
  2. Download the Raspberry Pi Imager on the official website Official Raspberry Pi website
  3. Install the Raspberry Pi Imager
  4. Write the operating system for Raspberry Pi to the SD card with Raspberry Pi Imager Raspbian Full - A port of Debian with desktop and recommended application
  5. Leave the SD card connected after writing is completed, we'll use for configuring SSH and WiFi connection later.

Detailed Steps:

  • Open a web browser on your computer, go to the Raspberry Pi website Official Raspberry Pi website, find and download the Raspberry Pi Imager for your computer OS, or click on the links above for the corresponding system to directly download and install.

    imagerDownload

  • Insert the SD card into the card reader, connect the card reader and your computer.

  • Run the Raspberry Pi Imager, select CHOOSE OS -> Raspbian(other) -> Raspbian Full - A port of Debian with desktop and recommended applications.

  • Click on CHOOSE SD CARD for the SD card to write the Raspbian Full, please be noted that the image writing will automatically delete all files on the SD card if any.

  • Click on WRITE, wait for the writing. The Raspberry Pi Imager needs to download the Raspbian image file during the process. You can download the file following the step in 2.1.2.

    imagerUse

  • Do not remove the SD card connected when writing is completed, we'll use for configuring SSH and WiFi connection later. Otherwise, if you remove the card, insert it into the Raspberry Pi and boot, WiFi configuration without any peripherals may fail in the following process.

2.1.2 Method B: Download the image file Raspbian and write it to the SD card manually

Since the image file is downloaded with the Raspberry Pi Imager in 2.1.1, it can take a long time due to a slow network in some places. You may then manually download the image file Raspbian and write it to the SD card with th Raspberry Pi Imager.

Step-by-Step Overview

  1. Prepare an SD card (16G or larger) and an SD card reader
  2. Download the Raspberry Pi Imager on the official website Official Raspberry Pi website
  3. Install the Raspberry Pi Imager
  4. Download the image file Raspbian
  5. Unzip the file, be noted that the path should be in English for the .img file extracted, no special characters allowed.
  6. Write the image file Raspbian downloaded to the SD card with Raspberry Pi Imager
  7. Leave the SD card connected after writing is completed, we'll use for configuring SSH and WiFi connection later.

Detailed Steps:

  • Open a web browser on your computer, go to the Raspberry Pi websiteOfficial Raspberry Pi website, find and download the Raspberry Pi Imager for your computer OS, or click on the links above for the corresponding system to directly download and install.

    imagerDownload

  • On the Raspberry Pi website Official Raspberry Pi website, select through Downloads -> Raspbian -> Raspbian Buster with desktop and recommended software, and click on the torrent or zip file to download. Unzip the file after download, be noted that the path should be in English for the .img file extracted, no special characters allowed; otherwise Raspberry Pi Imager may not open the .img file. It's recommended to save the .img file to the root directory of the C:\ or D:\ disk, but do not save .img on the SD card.

    RPiDownload

  • Insert the SD card into the card reader, connect the card reader and your computer.

  • Run the Raspberry Pi Imager, select CHOOSE OS, and then Use custom to find the .img extracted, click Open.

  • Select CHOOSE SD CARD for the SD card to write the Raspbian, please be noted that the image writing will automatically delete all files on the SD card if any.

  • Click on WRITE, wait for the writing.

    imagerUse

  • Do not remove the SD card connected when writing is completed, we'll use for configuring SSH and WiFi connection later. Otherwise, if you remove the card, insert it into the Raspberry Pi and boot it up, WiFi configuration without any peripherals may fail in the following process.

2.1.3 Method C: Manually download the image file provided by us and write it to the SD card (not recommended)

The Raspbian image file downloaded in 2.1.1 and 2.1.2 is the official source with some preinstalled software. To operate the robot, you may need many dependent libraries. Though we provide the simple script to install them (see details later), failure can happen during installation if the library is not the latest version. Therefore, despite we provide the downloading of the Raspbian image file, it may happen that our image file and the dependent libraries are not most updated versions. Please only use when you encounter the most troublesome situation.
Step-by-Step Overview

  1. Prepare an SD card (16G or larger) and an SD card reader
  2. Download the Raspberry Pi Imager from the official website Official Raspberry Pi website
  3. Install the Raspberry Pi Imager
  4. Download the image file Raspbian
  5. Unzip the file, be noted that the path should be in English for the .img file extracted, no special characters allowed.
  6. Write the image file Raspbian downloaded to the SD card with Raspberry Pi Imager
  7. Leave the SD card connected after writing is completed, we'll use for configuring SSH and WiFi connection later.

Detailed Steps:

  • Open a web browser on your computer, go to the Raspberry Pi website Official Raspberry Pi website, find and download the Raspberry Pi Imager for your computer OS, or click on the links above for the corresponding system to directly download and install.

    imagerDownload

  • Go to our official website, find and download the image file - Image file for the Raspberry Pi Robot. Unzip the file, be noted that the path should be in English for the .img file extracted, no special characters allowed. otherwise Raspberry Pi Imager may not open the .img file. It's recommended to save the .img file to the root directory of the C:\ or D:\ disk, but do not save .img on the SD card.

  • Insert the SD card into the card reader, connect the card reader and your computer.

  • Run the Raspberry Pi Imager, select CHOOSE OS, and then Use custom to find the .img extracted, click Open.

  • Select CHOOSE SD CARD for the SD card to write the Raspbian, please be noted that the image writing will automatically delete all files on the SD card if any.

  • Click on WRITE, wait for the writing.

    imagerUse

  • Do not remove the SD card connected when writing is completed, we'll use for configuring SSH and WiFi connection later. Otherwise, if you remove the card, insert it into the Raspberry Pi and boot it up, WiFi configuration without any peripherals may fail in the following process.

2.2 Enable SSH Server of Raspberry Pi

  • By SSH (Secure Shell) server, you can use the command line of Raspberry Pi remotely on another device. In the subsequent operation and when using the Raspberry Pi, you don't have to connect a mouse, keyboard, or monitor to it, but simply control it on a computer in the same LAN.
  • As of the November 2016 release, Raspbian has the SSH server disabled by default. You will have to enable it manually. 
  • The method to enable the SSH in this documentation can be referred to the Raspberry Pi official website SSH(Secure Shell)

2.2.1 Method A: Enable SSH with peripherals

  • If you've connected a mouse, keyboard, or monitor to the Raspberry Pi, follow these steps to enable SSH.

    1. Remove the SD card from the computer, insert it to the Raspberry Pi, connect a mouse, keyboard, and monitor to the Raspberry Pi, boot it up.
    2. Go to Preferences menu, select Raspberry Pi Configuration.
    3. Go to Interfaces option.
    4. Select Enable next to SSH.
    5. Click on OK.

    configSSH

2.2.2 Method A: Enable SSH without peripherals

  • If you haven't connected any monitor to the Raspberry Pi, follow these steps to enable SSH.

    1. Do not remove the SD card after Raspberry Pi Imager writes the image file.

    2. Create a file named ssh under any directory, without any extension name. You may create a ssh.txt and delete the .txt (make sure under Folder Options the box of Hide extensions for known file types is unchecked. Then you have an ssh file without extension name.

    3. Copy the ssh file and paste to the root directory of the SD card. The Raspberry Pi will auto search for the ssh file when booting, and enable SSH if the file is found. You only need to copy for one time because the Raspberry Pi then will automatically enable SSH at every boot.

    4. Do not remove the SD card if you need to configure WiFi.

2.3 Configure WiFi on Raspberry Pi

There are many ways to connect WiFi for Raspberry Pi. Two methods are provided in this documentation; you may visit the official Raspberry Pi website for more: Wireless connectivity.

2.3.1 Method A: WiFi connection with peripherals

  • If you've connected a mouse, keyboard, or monitor to the Raspberry Pi, follow these steps to configure WiFi.

    1. Remove the SD card from the computer, insert it to the Raspberry Pi, connect a mouse, keyboard, and monitor to the Raspberry Pi, boot it up.
    2. Select the WiFi icon at the top right corner on the monitor, find the WiFi to connect and select.
    3. Type in the password for the WiFi, connect.
    4. After it's connected successfully, the WiFi will be saved and the Raspberry Pi will auto connect for next boot, so you don't need to connect peripherals every time.

2.3.2 Method A: WiFi connection without peripherals

  • If you haven't connected any monitor to the Raspberry Pi, follow these steps to configure WiFi.

  • This method is based on the official documentation

    1. Do not remove the SD card after Raspberry Pi Imager has written the image file. (This method works for the situation that the Raspbian image file has just been written to the SD card; if you've already plugged the SD card into the Raspberry Pi and got it rebooted after the image file being written, the configuration may fail.)

    2. Create a file named wpa_supplicant.conf anywhere in your computer.

    3. Open the file wpa_supplicant.conf created with Textbook, enter the following code:

    ctrl_interface=DIR=/var/run/wpa_supplicant GROUP=netdev
    update_config=1
    country=Insert country code here
    network={
     ssid="Name of your WiFi"
     psk="Password for your WiFi"
    }
    
    1. TYpe in your own information for Insert country code here, Name of your WiFi, and Password for your WiFi. Pay attention to the capitalization. Refer to the example below:
    ctrl_interface=DIR=/var/run/wpa_supplicant GROUP=netdev
    update_config=1
    country=US
    network={
     ssid="MyName"
     psk="12345678"
    }
    
    1. Save and exit. Copy the wpa_supplicant.conf to the root directory of the SD card.

    2. If you've alreay copied the file ssh to the SD card as instructed in 2.2, then both the WiFi and SSH settings without peripherals are done. You may remove the SD card, insert it into the Raspberry Pi, and boot it up.

    3. For more about the file wpa_supplicant.conf, refer to the official documentation WIRELESS-CLI

3. Software Installation & Operation on Raspberry Pi

  • If you followed the steps in 2.2.1 and 2.3.1 for SSH and WiFi configuration, you may remove the peripherals now and use SSH to remotely control the Raspberry Pi later on.

  • If you followed the steps in 2.2.2 and 2.3.2, you may now insert the SD card into the Raspberry Pi and boot it up. The Raspberry Pi will auto boot and connect WiFi when powered on, with no need of peripherals.

  • Some steps mentioned below are based on the official Raspberry Pi documentation SSH.

  • For power supply of the Raspberry Pi, refer to the official documentationPower supply.

  • The Robot HAT board of the Adeept Raspberry Pi Robot can supply power for the Raspberry Pi via GPIO port. However, since it may take a long time to install software on the Raspberry Pi, it's not recommended to supply with the batteries during this process. You may skip the installation of the Robot HAT board or camera during software installation; though you need to make sure the driver board and camera for the Raspberry Pi when it's ready yto run the software installed, or a program error will occur.

3.1 Log into Raspberry Pi (Windows 10)

  • For Windows 10, SSH is built in the versions after October 2018, so you don't need any third-party software.

  • For lower versions of Windows OS, SSH is not built in, and you may log into the Raspberry Pi by referring to the official documentation SSH using Windows.

  • Before connecting the Raspberry Pi via SSH, you need to know the IP address of the Raspberry Pi. Check the Management interface for your router, or download the app Network Scanner -> search for a device named RASPBERRY or Raspberry Pi Foundation to get the IP address.

  • For other methods of obtaining the IP address of Raspberry Pi, refer to the official documentation IP Address

  • Press the keys win+R, type in cmd, and press enter.

  • The default user is pi, and the password is raspberry

  • Type in ssh pi@<IP> in the command line, replace the <IP> with the IP address of your Raspberry Pi, as shown below:

    ssh [email protected]

  • Press Enter key and a prompt will appear: Are you sure you want to continue connecting (yes/no)?

  • Type in yes, press Enter and it'll show [email protected]'s password:, type in the initial password of the Raspberry Pi, raspberry (pay attention to capitalization). There's no change on the screen when you're typing in, but it doesn't mean you're not entering the information. Press enter after you finish typing in.

  • So now you've logged into the Raspberry Pi.

winSSH

3.2 Log into Raspberry Pi (Linux or Mac OS)

  • Before connecting the Raspberry Pi via SSH, you need to know the IP address of the Raspberry Pi. Check the Management interface for your router, or download the app Network Scanner -> search for a device named RASPBERRY or Raspberry Pi Foundation to get the IP address.

  • For other methods of obtaining the IP address of Raspberry Pi, refer to the official documentation IP Address

  • Open the terminal window (or command line)

  • The default user is pi, and the password is raspberry

  • Type in ssh pi@<IP> in the command line, replace <IP> with the IP address of your Raspberry Pi as shown below:

    ssh [email protected]

  • Press Enter key and a prompt will appear: Are you sure you want to continue connecting (yes/no)?

  • Type in yes, press Enter and it'll show [email protected]'s password:, type in the initial password of the Raspberry Pi, raspberry (pay attention to capitalization). There's no change on the screen when you're typing in, but it doesn't mean you're not entering the information. Press enter after you finish typing in.

  • So now you've logged into the Raspberry Pi.

3.3 Log into Raspberry Pi (Windows)

  • For lower versions of Windows OS, SSH is not built in, and you may log into the Raspberry Pi by referring to the official documentation Raspberry PiSSH using Windows.
  • Before connecting the Raspberry Pi via SSH, you need to know the IP address of the Raspberry Pi. Check the Management interface for your router, or download the app Network Scanner -> search for a device named RASPBERRY or Raspberry Pi Foundation to get the IP address.
  • For other methods of obtaining the IP address of Raspberry Pi, refer to the official documentation IP Address
  • You may need to download the PuTTY version for your OS and log into Raspberry Pi with the tool. Click here to download PuTTY
  • Run PuTTY, type in the IP address of Raspberry Pi for Host Name, and click Open.
  • If a prompt of Network error: Connection timed out appears, possibly you've entered an incorrect IP address.
  • When the connection works you will see the security warning shown below. You can safely ignore it, and click the 'Yes' button. You will only see this warning the first time PuTTY connects to a Raspberry Pi that it has not seen before.
  • You will now see the usual login prompt. Log in with the same username and password you would use on the Pi itself. The default login for Raspbian is pi with the password raspberry.
  • You should now have the Raspberry Pi prompt which will be identical to the one found on the Raspberry Pi itself.

putty

3.4 Download Program of the Raspberry Pi Robot

  • The code for the robot product has been uploaded to GitHub, you may need to download to your Raspberry Pi and install the corresponding dependent libraries to run the program.

  • In the previous section you've logged into the Raspberry Pi, and here type in the follow command in the terminal window:

    sudo git clone https://github.com/adeept/adeept_rasptank.git

  • Press enter to start downloading the program of the robot from GitHub. It may take some time, please wait until it's done.

3.5 Install Corresponding Dependent Libraries

  • Follow the steps below to install the libraries if you wrote the image file to the SD card based on 2.1.1 Write 'Raspbian' to the SD card by Raspberry Pi Imager and 2.1.2 Download the image file Raspbian and write it to the SD card manually.

  • But you should skip this section if you wrote the image file to the SD card based on 2.1.3 Manually download the image file provided by us and write it to the SD card; refer to 2.4.5 for configuration of auto start program.

  • Here a script is provided for installing all dependent libraries needed and configuration of starting the camera and other auto start programs.

  • Type in the code below in the terminal window to run the dependent libraries for the script setup.py:

    sudo python3 adeept_rasptank/setup.py

  • Press enter and the script will auto run. This may take minutes or hours, depending on the network status. Please wait until it's done.

  • After installation is completed, the following prompts will appear:

    The program in Raspberry Pi has been installed, disconnected and restarted.
    You can now power off the Raspberry Pi to install the camera and driver board (Robot HAT). After turning on again, the Raspberry Pi will automatically run the program to set the servos port signal to turn the servos to the middle position, which is convenient for mechanical assembly.

  • When installation is completed, the Raspberry Pi will automatically disconnect SSH and reboot. If you used puTTy to connect the Raspberry Pi, there can be an error prompt like Network error:Software caused connection abort. You can just ignore and close it.

3.6 Run the Raspberry Pi Robot's Program

  • Raspberry Pi auto runs the program for the robot when rebooting every time, which is the part [RobotName]/server/webServer.py (replace [RobotName] for the name of the folder for your robot product's program). However, if the Raspberry Pi camera or RobotHAT is not connected, the webServer.py can't run well. It makes sense because the robot's program needs the camera and the chipset PCA9685. RobotHAT controls servo with PCA9685; the Raspberry Pi communicates with PCA9685 via I2C; so if Robot HAT is not connected to Raspberry Pi, a program error will occur when instantiating dependent libraries for PCA9685 due to communication failure.

  • Power off the Raspberry Pi, connect camera module and RobotHAT, reboot it up and now webServer.py can run.

  • Generally you don't need to manually run webServer.py since it's auto run by Raspberry Pi at every boot.

  • Open a web browser (Google Chrome for example), in the address bar type in the IP address of the Raspberry Pi, add :5000 to the end as shown below, and press enter to redirect to the webpage of the Raspberry Pi:

    http://192.168.3.161:5000/

  • If it fails to enter the page, log into the Raspberry Pi via SSH, type in the command below to end the program auto run at boot to release resources, or else issues like camera initialization failure or occupied ports.

    sudo killall python3

  • Type in the command below to run webServer.py:

    sudo python3 adeept_rasptank/server/webServer.py

  • Check whether there's any error and solve them based on instructions in the Q&A section below.

4. Precautions for Structure Assembly

4.1 Documentation for structure assembly

4.2 Precautions for Structure Assembly

  • Since many servos are used in the product, the servo installation is critical for the robot. Before installing the rocker arm to the servo, you need to connect the servo to power and make the servo shaft rotate to the central position, so the rocker arm installed at the designated degree will be in the central position.

  • Generally Raspberry Pi will auto run webServer.py when booting, when webServer.py will control all the ports connected to servos to send a signal of rotating to the central position. When assembling the servo, you can connect it to any servo port anytime. After connecting the servo to the port, the gears will rotate to the central position; assemble the rocker arm to the servo, disconnect the servo from the port, and insert more servos to repeat rocker arm assembly (all servos will be in the central position).

  • When the servo is connected to power, try moving the rocker arm. If it can't be moved, it indicates the program for the servo works; otherwise there's error for the servo program. Run the line [RobotName]/initPosServos.py (replace [RobotName] with the folder name of your robot's program) to make the servo rotate to the central position.

  • When booting (it may take 30-50s), it takes a while for the Raspberry Pi to control PCA9685 to set signal of all servo ports for central position rotating.

5. Controlling Robot via WEB App

  • The WEB app is developed for common users to control the robot in an easier way. It's convenient to use WEB app; you may use it to wirelessly control the robot on any device with a web browser (Google Chrome was used for testing).

  • Generally Raspberry Pi will auto run webServer.py when booting and establish a web server in the LAN. You may then use any other computer, mobile or tablet in the same LAN to visit the webpage and control the robot.

  • How to tell whether the robot has run the webServer.py or not: If the WS2812-LED lights up with the breathing effect, it means the robot has booted and runs the program automatically.

  • If the program is not run when the robot is booted, try to connect Raspberry Pi via SSH, manually run webServer.py with code and check the errors. Refer to the Q&A below or email us for help (before manually running webServer.py, you need to end the program possibly auto run in the backend to release resources.

    sudo killall python3
    sudo python3 RobotName/server/webServer.py

  • If the webServer.py is auto run successfully, open a web browser (here Google Chrome), type in the IP address of the Raspberry Pi, with :5000 added to the end, and go to the next step, as shown below:

    192.168.3.161:5000

  • If no image is displayed, try manual running webServer.py as described in the step above.

  • If image is shown, you can control the robot to move now. You may check the description for keyboard shortcuts Instruction at the bottom and control the robot based on its general functions with the keyboard.

  • Video window shows the image captured by the robot's camera in real time.

  • Move Control window is to control the basic movements of the robot.

  • Arm Control window controls the servo movement.

    • GRAB LOOSE: Control the claws of the robotic arm to open and close
    • HANDUP HANDDOWN: Control the robotic arm to move up and down
    • LEFT RIGHT: Control the claws rotation of the robotic arm
  • CVFL Control window is to control the visual line following function of the robot. Here only an overview for the function is described; more details will be provided in the OpenCV section:

    • START: Enable or disable the visual line following function.
    • COLOR: Switch between white and black line following. By default the robot follows white lines; click the button to switch to black line following.
    • The line following function analyzes two pixels in parallel and utilizes the information detected; the positions of these two pixels are L1 and L2.
    • SP is the threshold of the turning command based on the visual analysis results. A bigger SP value means a big deviation; though a particularly small SP value may stop the robot from moving as it can't aim the target and find the direction.
    • When the visual line following function is enabled, the video screen will automatically become binarized results, making the visual analysis clearer.
  • Hard Ware window displays CPU temperature, CPU occupancy rate, and memory usage of the Raspberry Pi.

  • Actionswindow control unique functions of the robot:

    • MOTION GET: Motion detection function based on OpenCV. When objects move in the view of the camera, the program will circle the part in the Video window, and the LED light on the robot will show respective changes.
    • AUTO MATIC: Obstacle avoidance function based on ultrasonic. When the ultrasonic module on the robot detects an obstacle, it will automatically turn left, and take a step backward before turning if it's too close to the obstacle.
    • POLICE LIGHT: WS2812-LED light control based on multithreading. It makes the WS2812-LED light on the robot blink red and blue alternately.
    • TRACK LINE: Line tracking function by using the 3-channel infrared module. By default it tracks black lines on a white surface (a white background that reflects infrared, and 1-cm wide black lines that do not reflects infrared). Performance of the line tracking varies from surface and line materials as well as the height of the robot chassis; you may need a cross screwdriver to adjust the potentiometer on the line tracking module.
  • FC Control window controls the color lock function of the robot:

    • START: Enable or disable color searching and tracking function.
    • COLOR: Select the color to track.
    • When the function is on, the robot will automatically lock one particular color in the camera view. By default it tracks bright yellow objects. You can change the color as you want. When an object is locked, the LED on the robot will turn orange. As the robot's head can only move up and down, the program does not involve tracking colors horizontally. If you have interest in this part, you may add the motor control based on the openCV section to realize effect.

webControl

6. Q&A

  • Where to find the IP address of the Raspberry Pi?

    • Before connecting the Raspberry Pi via SSH, you need to know the IP address of the Raspberry Pi. Check the Management interface for your router, or download the app Network Scanner -> search for a device named RASPBERRY or Raspberry Pi Foundation to get the IP address.

    For other methods of obtaining the IP address of Raspberry Pi, refer to the official documentation IP Address

  • Errors occur with permission denied prompt when I manually run server.py or webServer.py.

    The Raspberry Pi needs the root permission to run the dependent libraries for WS2812 LED lights control. You need to add sudo to the beginning of server.py or webServer.py to run the program. sudo python3 [PATH]/server.py sudo python3 [PATH]/webServer.py

  • I can't create the hotspot for the robot.

    You need to use the open source project create_ap to setup the robot's hotspot. Prior to use, disconnect WiFi network but DO NOT turn the WiFi module off, or the create_ap will show an error of hardware being blocked.

  • The servo rotates to an abnormal degree.

    Before assembling the rocker arm and servo, you need to make the servo gears rotate to the central position of its rotating range. Then assemble the rocker arm based on the angle instructed in the documentation. There can be a deviation of less than 9° due to the structure of the servo (number of teeth is 20 for the servo gears). For better performance, you may refer to the servo control documentation for initial degree adjustment by code.

  • The servo is shaking.

    Probably the servo reducing gear is broken.

  • Raspberry Pi can't boot.

    Remove all parts on the driver board. Only connect the board to Raspberry Pi and power supply, reboot.

  • "Remote side unexpectedly closed network connection" shows on a popup window.

    There can be error prompts during installation because the Raspberry Pi will auto reboot after the installation, which will disconnect the board.

  • Program crashes after double clicking on client.py or GUI.py.

    Run the script by python client.py or python GUI.py in cmd and check the error reports.

  • How to initialize the servo's angle?

    If you've finished software installation on the Raspberry Pi, just boot it up and the servo will be initialized.

  • I can connect to the Raspberry Pi terminal via SSH \ Raspberry Pi failed to connect a WiFi.

    The power supply methods will not influence control by SSH. Check whether you've created the file wpa_supplicant.conf for multiple times. If yes, that's problem causing SSH errors.

  • Can I supply the Robot HAT and Raspberry Pi via USB?

    A 2A output is required for a Raspberry Pi 3B, when at least 3A is needed for a Raspberry Pi 4. You can use the USB power for software installation and testing, but it's not suitable for high power module like servo or motor adjustment as it may result in low voltage. It's recommended to use battery for power here.

  • After installation, the robot shows no response when booting.

    The server.py or webServer.py may not run due to some reasons. Try to manually run server.py or webServer.py and check whether there's any error prompt.

  • The servo doesn't return to the central position when connected to the driver board.

    In general, the Raspberry Pi will auto run webServer.py when booting, and webServer.py will run and control the servo ports to send a signal of rotating to the central position. When assembling the servo, you can connect it to any servo port anytime. After connecting the servo to the port, the gears will rotate to the central position; assemble the rocker arm to the servo, disconnect the servo from the port, and insert more servos to repeat rocker arm assembly (all servos will be in the central position).

    When the servo is powered on, try moving the rocker arm. If it can't be moved, it indicates the program for the servo works; otherwise there's error for the servo program. Run the line [RobotName]/initPosServos.py (replace [RobotName] with the folder name of your robot's program) to make the servo rotate to the central position.

    When booting (it may take 30-50s), it takes a while for the Raspberry Pi to control PCA9685 to set signal of all servo ports for central position rotating.

  • “no cv2" error occurs when I manually run server.py or webServer.py.

    OpenCV is not installed correctly. Type in the command sudo pip3 install opencv-contrib-python in the Raspberry Pi to manually install OpenCV.

adeept_rasptank's People

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

adeept_rasptank's Issues

config.txt will only be copied if /home/pi/adeept_rasptank folder is used for installation

If a different folder than /home/pi/adeept_rasptank is used for installation copying the config.txt doesn't work anymore.

Please use

try:
	os.system("sudo cp -f " + thisPath + "/adeept_rasptank/server/config.txt //etc/config.txt")
except:
	pass

instead of

os.system("sudo cp -f //home/pi/adeept_rasptank/server/config.txt //etc/config.txt")
see

os.system("sudo cp -f //home/pi/adeept_rasptank/server/config.txt //etc/config.txt")

(not tested in regards of typos, please test before committing the change)

in guide missing a22 2 times

in step 13 and step 14 the ervos are assembl to their acrylic parts without using a placeholder A22 in between - there is also 2 A22 too many at the end - so i assume thats where they are supposed to be

Missing Library

It looks like libharfbuzz0b is missing from the installation script and should be added as one of the dependencies.

apt install libharfbuzz0b should take care of it if you run into this issue.

Raspbian Bookworm 64-bit

The setup.py was not working with the latest Raspbian OS, and the image file provided by Adeept was not working with the Raspberry PI 4.
I wrote this script to install the dependencies, and to set up the init script. Now everything seems to work, I get video from the camera, the motors/servos react to button presses on the web UI.
I still need to assemble the robot, so I can't say for sure this fixes everything, but here is the script if anyone needs it.

#!/bin/bash

# RaspTank setup script for Raspberry Pi 4, OS: Bookworm 64-bit

if [ $(id -u) -ne 0 ]
then
    echo "Please run this script as:"
    echo "sudo ${0}"
    exit 1
fi

set -e
set -x

apt update
apt upgrade -y
apt install -y python-dev-is-python3 python3-pip libfreetype6-dev libjpeg-dev \
    build-essential i2c-tools python3-smbus libatlas-base-dev libgstreamer1.0-0 \
    util-linux procps hostapd iproute2 iw haveged dnsmasq libqt5gui5 libqt5webkit5 \
    libqt5test5 libhdf5-dev libhdf5-serial-dev libatlas-base-dev opencv-data \
    python3-opencv libcamera-v4l2 libcamera-tools
apt clean

pip3 install --break-system-packages luma.oled adafruit-pca9685 rpi_ws281x \
    mpu6050-raspberrypi flask flask_cors websockets RPi.GPIO numpy opencv-contrib-python \
    picamera2 imutils zmq pybase64 psutil

cd /opt
git clone https://github.com/oblique/create_ap
cd create_ap 
make install

cd /opt
git clone https://github.com/adeept/Adeept_RaspTank.git
cd Adeept_RaspTank

cp -vaf ./server/config.txt /etc/config.txt

STARTER=$(readlink -e ./server/webServer.py)
# libcamerify will make legacy opncv code work
LEGACY_CAM=$(which libcamerify)
PY_RUNTIME=$(which python3)

sed -i /etc/rc.local -e "s@^exit 0@${LEGACY_CAM} ${PY_RUNTIME} ${STARTER}\nexit 0\n@"


# updating boot config to enable i2c
echo -ne "\ndtparam=i2c_arm=on\n" >> /boot/config.txt

# fix conflict with onboard Raspberry Pi audio
echo "blacklist snd_bcm2835" > /etc/modprobe.d/snd-blacklist.conf

Issue running on MacOS

Hi I'd like to run this on my mac. I was wondering if you are seeing the same thing. If so, can this be resolved in the future?

2019-05-21 20:36:07.488 Python[7232:70423] *** Terminating app due to uncaught exception 'NSInternalInconsistencyException', reason: 'NSWindow drag regions should only be invalidated on the Main Thread!'
*** First throw call stack:
(
0 CoreFoundation 0x00007fff2ced4f15 __exceptionPreprocess + 256
1 libobjc.A.dylib 0x00007fff59040efb objc_exception_throw + 48
2 CoreFoundation 0x00007fff2ceeec41 -[NSException raise] + 9
3 AppKit 0x00007fff2a3e2c8e -[NSWindow(NSWindow_Theme) _postWindowNeedsToResetDragMarginsUnlessPostingDisabled] + 324
4 AppKit 0x00007fff2a3e007c -[NSWindow _initContent:styleMask:backing:defer:contentView:] + 1488
5 AppKit 0x00007fff2a3dfaa6 -[NSWindow initWithContentRect:styleMask:backing:defer:] + 45
6 AppKit 0x00007fff2a6b2ad4 -[NSWindow initWithContentRect:styleMask:backing:defer:screen:] + 52
7 libopencv_highgui.3.4.dylib 0x0000000109125d02 cvNamedWindow + 419
8 libopencv_highgui.3.4.dylib 0x0000000109125725 cvShowImage + 109
9 libopencv_highgui.3.4.dylib 0x0000000109122d9b _ZN2cv6imshowERKNS_6StringERKNS_11_InputArrayE + 429
10 cv2.cpython-37m-darwin.so 0x00000001077ee4ee ZL18pyopencv_cv_imshowP7_objectS0_S0 + 306
11 Python 0x0000000106f79668 _PyMethodDef_RawFastCallKeywords + 545
12 Python 0x0000000106f78bd3 _PyCFunction_FastCallKeywords + 44
13 Python 0x000000010700e5f0 call_function + 636
14 Python 0x0000000107007231 _PyEval_EvalFrameDefault + 7016
15 Python 0x0000000106f78fae function_code_fastcall + 112
16 Python 0x0000000107007548 _PyEval_EvalFrameDefault + 7807
17 Python 0x0000000106f78fae function_code_fastcall + 112
18 Python 0x000000010700e665 call_function + 753
19 Python 0x0000000107007218 _PyEval_EvalFrameDefault + 6991
20 Python 0x0000000106f78fae function_code_fastcall + 112
21 Python 0x000000010700e665 call_function + 753
22 Python 0x0000000107007218 _PyEval_EvalFrameDefault + 6991
23 Python 0x0000000106f78fae function_code_fastcall + 112
24 Python 0x0000000106f79931 _PyObject_Call_Prepend + 150
25 Python 0x0000000106f78ce1 PyObject_Call + 136
26 Python 0x0000000107075eee t_bootstrap + 71
27 Python 0x000000010703c847 pythread_wrapper + 25
28 libsystem_pthread.dylib 0x00007fff5a2fb305 _pthread_body + 126
29 libsystem_pthread.dylib 0x00007fff5a2fe26f _pthread_start + 70
30 libsystem_pthread.dylib 0x00007fff5a2fa415 thread_start + 13
)
libc++abi.dylib: terminating with uncaught exception of type NSException
Abort trap: 6

shutdown instead of reboot

Instead of rebooting and telling the user the Pi can be powered off, a
os.system("sudo shutdown now")
should be done

Adeept_RaspTank/setup.py

Lines 146 to 148 in f4a9dab

print('The program in Raspberry Pi has been installed, disconnected and restarted. \nYou can now power off the Raspberry Pi to install the camera and driver board (Robot HAT). \nAfter turning on again, the Raspberry Pi will automatically run the program to set the servos port signal to turn the servos to the middle position, which is convenient for mechanical assembly.')
print('restarting...')
os.system("sudo reboot")

Remote I/O Not Found

Using Raspberry PI 3. my servo.py and webServer.py are not working due to the following error:

pi@raspberrypi:~ $ python3 adeept_rasptank/server/servo.py 
Traceback (most recent call last):
  File "adeept_rasptank/server/servo.py", line 15, in <module>
    pwm = Adafruit_PCA9685.PCA9685()
  File "/usr/local/lib/python3.7/dist-packages/Adafruit_PCA9685/PCA9685.py", line 75, in __init__
    self.set_all_pwm(0, 0)
  File "/usr/local/lib/python3.7/dist-packages/Adafruit_PCA9685/PCA9685.py", line 111, in set_all_pwm
    self._device.write8(ALL_LED_ON_L, on & 0xFF)
  File "/usr/local/lib/python3.7/dist-packages/Adafruit_GPIO/I2C.py", line 114, in write8
    self._bus.write_byte_data(self._address, register, value)
  File "/usr/local/lib/python3.7/dist-packages/Adafruit_PureIO/smbus.py", line 333, in write_byte_data
    self._device.write(data)
OSError: [Errno 121] Remote I/O error

Here is what I tried

webServer.py starts but is not responding on port 5000

I have cloned the repo on Dec 26 2020 and ran into issues. I have a fully assembled RaspTank (powered by micro USB adaptor on Raspberry Pi 3b+, no batteries.
When I run boot the Raspberry the web interface does not become available so I followed instructions.
killall python3 and manually started the webServer.py as sudo. The following was shown:

......................pause..........................
Starting camera thread.
OLED disconnected
OLED没有连接
Exception in thread Thread-9:
Traceback (most recent call last):
  File "/usr/lib/python3.7/threading.py", line 917, in _bootstrap_inner
    self.run()
  File "/home/pi/adeept_rasptank/server/OLED.py", line 49, in run
    with canvas(device) as draw:
NameError: name 'device' is not defined

......................pause..........................
 * Serving Flask app "app" (lazy loading)
 * Environment: production
   WARNING: Do not use the development server in a production environment.
   Use a production WSGI server instead.
 * Debug mode: off
192.168.0.96
waiting for connection...
 * Running on http://0.0.0.0:5000/ (Press CTRL+C to quit)

With netstat I made sure something was listening

Proto Recv-Q Send-Q Local Address           Foreign Address         State       PID/Program name    
tcp        0      0 0.0.0.0:8888            0.0.0.0:*               LISTEN      1026/python3        
tcp        0      0 0.0.0.0:5000            0.0.0.0:*               LISTEN      1026/python3  

Trying to access the web site with Google Chrome ran into a timeout/no reply.
A couple of questions:

  1. Is there any way to increase logging/debug info to pinpoint the error?
  2. As there was no OLED component I would expect no error to be thrown by a missing OLED screen.
  3. Could it be that the power supply is too weak and therefore I cannot get an answer by the web server on port 5000 (I doubt it, but maybe it's somehow connected)?

side LEDs of the RaspTank are blinking in blue, so some power is available.

Debugging issues

Im trying to debug my servo's as some are backwards. Do I have to reboot the raspberry pi everytime I make an edit for the changes to take effect?

typo in move.py

pwn_A = 0

should be

pwm_A = 0

My file is heavily modified or I would upload it for you.

[Errno 121] Remote I/O error

Quick question: Can you test serverTest.py with just the raspberryPi? Or did you need the rasptank fully assembled when you're testing for the first time? What is serverTest.py supposed to do? Check if the servos are working properly?

This is the output I got when I tried to test it:

pi@raspberrypi:~/Adeept_RaspTank $ sudo python3 server/serverTest.py
Traceback (most recent call last):
File "server/serverTest.py", line 14, in
pwm = Adafruit_PCA9685.PCA9685()
File "/usr/local/lib/python3.7/dist-packages/Adafruit_PCA9685/PCA9685.py", line 75, in init
self.set_all_pwm(0, 0)
File "/usr/local/lib/python3.7/dist-packages/Adafruit_PCA9685/PCA9685.py", line 111, in set_all_pwm
self._device.write8(ALL_LED_ON_L, on & 0xFF)
File "/usr/local/lib/python3.7/dist-packages/Adafruit_GPIO/I2C.py", line 114, in write8
self._bus.write_byte_data(self._address, register, value)
File "/usr/local/lib/python3.7/dist-packages/Adafruit_PureIO/smbus.py", line 322, in write_byte_data
self._device.write(data)
OSError: [Errno 121] Remote I/O error

Reading the motor control board LEDs from the pi?

The motor control board has a set of LEDs that seem to indicate the current battery capacity - there are 4 LEDs and they appear to turn off as the batteries drain. Is there any way that the pi could query the current battery capacity readout so that it could be displayed in the web interface?

If these lights are not indicating the battery capacity, what do they indicate?
Screen Shot 2022-03-21 at 4 06 29 PM

Path to server/requirements.txt incorrect

The path in the setup file is server/requirements.txt

The path should be ~/adeept_rasptank/server/requirements.txt

If you run into this error you will have to delete the create_ap folder and start over.

Can't make work picamera

Dear friend.
As the adeept rasptank has a very Interesting tutorial, I have been trying to explore all the possibilities and yesterday tried to make work just the camera trough the indications written in the tutorial but when I texted -sudo app.py-after install flack video streaming, an error came out: command not found.
What’s wrong?

Issues with install

Hello!

When installing using the base os and then downloading this repo, several pieces of the install fail.

Trying to get the provided image at the link provided in 2.1.3 step 4 leads to a sharepoint login which i do not have

Is there an update to the install script or an alternate link that i can follow to get your image?

OpenCV 3.4.3.18 Not Found

Getting this error when I try to install OpenCV

From Line #95

ERROR: Could not find a version that satisfies the requirement opencv-contrib-python==3.4.3.18
ERROR: No matching distribution found for opencv-contrib-python==3.4.3.18

Not sure if this solves the problem sudo apt install python3-opencv.

There's also this but it didn't work for me here.

pip install --upgrade pip setuptools wheel
Full Error ``` Looking in indexes: https://pypi.org/simple, https://www.piwheels.org/simple, https://www.piwheels.org/simple Ignoring numpy: markers 'python_version == "3.6"' don't match your environment Ignoring numpy: markers 'python_version == "3.7"' don't match your environment Ignoring numpy: markers 'python_version >= "3.9"' don't match your environment Collecting numpy==1.17.3 Using cached numpy-1.17.3-cp38-cp38-linux_armv7l.whl Collecting cmake Using cached cmake-3.18.4.post1.tar.gz (28 kB) Installing build dependencies: started Installing build dependencies: finished with status 'done' Getting requirements to build wheel: started Getting requirements to build wheel: finished with status 'done' Preparing wheel metadata: started Preparing wheel metadata: finished with status 'done' Collecting pip Using cached https://www.piwheels.org/simple/pip/pip-20.3.3-py2.py3-none-any.whl (1.5 MB) Collecting scikit-build Using cached https://www.piwheels.org/simple/scikit-build/scikit_build-0.11.1-py2.py3-none-any.whl (72 kB) Collecting wheel Using cached https://www.piwheels.org/simple/wheel/wheel-0.36.2-py2.py3-none-any.whl (35 kB) Collecting distro Using cached https://www.piwheels.org/simple/distro/distro-1.5.0-py2.py3-none-any.whl (18 kB) Collecting packaging Using cached https://www.piwheels.org/simple/packaging/packaging-20.8-py2.py3-none-any.whl (39 kB) Collecting pyparsing>=2.0.2 Using cached https://www.piwheels.org/simple/pyparsing/pyparsing-2.4.7-py2.py3-none-any.whl (67 kB) Collecting setuptools Using cached https://www.piwheels.org/simple/setuptools/setuptools-51.0.0-py3-none-any.whl (785 kB) Building wheels for collected packages: cmake Building wheel for cmake (PEP 517): started Building wheel for cmake (PEP 517): finished with status 'error' ERROR: Command errored out with exit status 1: command: /home/pi/Projects/Adeept_RaspTank/.venv/bin/python3 /home/pi/Projects/Adeept_RaspTank/.venv/lib/python3.8/site-packages/pip/_vendor/pep517/_in_process.py build_wheel /tmp/tmpo261ax7y cwd: /tmp/pip-install-now4wr4m/cmake_94b0d2c195904c07b0146c7a946b6caf Complete output (9 lines): File "/tmp/pip-build-env-ll_oe_qt/overlay/lib/python3.8/site-packages/skbuild/setuptools_wrap.py", line 560, in setup cmkr = cmaker.CMaker(cmake_executable) File "/tmp/pip-build-env-ll_oe_qt/overlay/lib/python3.8/site-packages/skbuild/cmaker.py", line 95, in __init__ self.cmake_version = get_cmake_version(self.cmake_executable) File "/tmp/pip-build-env-ll_oe_qt/overlay/lib/python3.8/site-packages/skbuild/cmaker.py", line 81, in get_cmake_version raise SKBuildError( Traceback (most recent call last):
Problem with the CMake installation, aborting build. CMake executable is cmake
----------------------------------------
ERROR: Failed building wheel for cmake

Failed to build cmake
ERROR: Could not build wheels for cmake which use PEP 517 and cannot be installed directly

ERROR: Command errored out with exit status 1: /home/pi/Projects/Adeept_RaspTank/.venv/bin/python3 /home/pi/Projects/Adeept_RaspTank/.venv/lib/python3.8/site-packages/pip install --ignore-installed --no-user --prefix /tmp/pip-build-env-sc9tf_w5/overlay --no-warn-script-location --no-binary :none: --only-binary :none: -i https://pypi.org/simple --extra-index-url https://www.piwheels.org/simple -- setuptools wheel scikit-build cmake pip 'numpy==1.13.3; python_version=='"'"'3.6'"'"'' 'numpy==1.14.5; python_version=='"'"'3.7'"'"'' 'numpy==1.17.3; python_version=='"'"'3.8'"'"'' 'numpy==1.19.3; python_version>='"'"'3.9'"'"'' Check the logs for full command output.

</details>

Integration with DepthAI

Hi there!

Your robot looks great! We're about to buy 2x of them and try integrating DepthAI into your codebase.

So just wanted to give a heads up on this. The idea with depthAI is it real-time gives you 3D object detection, so what objects are and where they are in physical space, example below:
image

Our hardware and software is open source and runs well with Pi, so it seems like an ideal pairing for this platform.

https://github.com/luxonis
https://www.crowdsupply.com/luxonis/depthai

Thoughts?

Best,
Brandon

Raspbian Bullseye

Everything running fine on raspbian 10 buster 32-bit

I am trying to experiment on raspbian 11 bullseye 64-bit

gettng this output with webServer.py

......................pause.......................... Starting camera thread. The camera has not read data, please check whether the camera can be used normally. Use the command: 'raspistill -t 1000 -o image.jpg'. Close the self-starting program webServer.py Use the command: 'raspistill -t 1000 -o image.jpg' to check whether the camera can be used correctly.

anyone able to successfully use it with bullseye 64bit?

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.