Raspberry Pi Robot Car Lesson 1: Basic Framework Installation
by osoyooproduct in Circuits > Robots
2315 Views, 4 Favorites, 0 Comments
Raspberry Pi Robot Car Lesson 1: Basic Framework Installation
In this lesson, we will install the most important framework in the smart car and make car to do some simple movements as per our python sample code.
If you have passed the test movement of this lesson, that means Arduino, voltage meter,motor drive module(Model-PI), motors, batteries,chassis and wire connections between these parts are all functioning well.
As your experiments in future lessons are all based on frame work of Lesson One, it is very important to test the installation and sample code in this Lesson properly.
Detailed Tutorials: www.osoyoo.com/?p=12817
Buy from United State Amazon.com
Hardware Installation
Detailed Tutorials: www.osoyoo.com/?p=12817
Buy from United State Amazon.com
STEP1. Install driving wheels as follows.
STEP2. Install the universal wheel as follows.
STEP3. Install PCA9685 compatible module.
STEP4. Install the voltage meter as follows.
STEP5. Install 5 pcs tracking sensor as follows.
STEP6.Plug the 4 pin female to female cable (white, red, black, yellow) and 2 pin female to female cable(black, red) into PCA9685 compatible board as follows.
STEP7.Plug the 2 PCS 1 pin to 5 pin female to female cable (Black and Red) into PCA9685 compatible board as follows.
STEP8.Install the model pi motor driver board as follows. Then connect the PCA9685 compatible module to motor driver board via 4pin and 2 pin cable. Meanwhile, connect the voltage meter to the motor driver board via a 3pin cable.
STEP9.Install the camera module on the top car chassis as follows.
STEP10.Install the battery box on the top car chassis as follows.
STEP11.Install raspberry pi on the top car chassis as follows.
STEP12.Before installing the top chassis as follows, you need to plug the battery box into the model pi motor driver, then connect the Raspberry Pi board to PCA9685 compatible module and model Pi motor driver board, Lastly, connect 5 pcs tracking sensors to raspberry pi as follows.
STEP13.Install the top chassis as follows.
STEP14.Install the left and right wheels.
Software Installation
Software Preparation:
Imager utility: Win32DiskImager utility
OS: Raspbian(Use OS Raspbian 2018-04-18 in the subsequent tutorials)
Format Tool: SDFormatter(Optional)
SSH Tool: PuTTY(for Windows users)
Step 0: Before connecting to Raspberry Pi, you need to install Raspbian Operation System(OS) onto SD card.
You can select the latest version of RASPBIAN system on the official website: https://downloads.raspberrypi.org/raspbian/images... Write the image via Win32DiskImager utility into your microSD/TF card(minimum 16G), then plug the card into the slot on your Raspberry Pi.
Step 1: Connect Wifi
Firstly, Connect Raspberry Pi to your HDMI monitor or TV. Put a keyboard and mouse into Raspberry Pi USB ports. Insert SD card into the slot on your Raspberry Pi.
Click on the wireless icon top right on the desktop, should give a list of access points, select your wifi SSID and connect it. Once your Pi is connected to Wifi, you can hover your mouse to the wifi icon to see your IP address.
Or you can type sudo ifconfig wlan0 command in terminal. Your local IP address will show in wlan0 block(right side of the word inet addr:). It will look like 192.168......
Step 2: Open SSH connection
SSH enable user to type shell command remotely from internet so that we can control the car through wifi.In order to enable SSH function, we need type following command from terminal:
sudo raspi-config
Then select Advanced Options or Interfacing Options->SSH->Yes->Ok->Finish
Step 3: Use SSH to connect Raspberry Pi terminal remotely
In order to make the car moving freely, we need disconnect Raspberry Pi from the monitor, keyboard/mouse and use SSH to send the command to Raspberry Pi terminal remotely.
If you are using Windows to send ssh command. you need download a free software called PuTTy to connect the Raspberry Pi local IP(you got from STEP 1).
If you are using MacBook or other Linux computer, please type:ssh pi@192.168.50.7
ssh your_raspberry_pi_local_ip_address
*your_raspberry_pi_local_ip_address means the wifi IP address you got from STEP 1
When connecting ssh, you need use default user name pi and default password raspberry to login to Raspberry Pi.
Important Note:As the raspberry pi robot car image was written into SD Card, you just need to follow the step 1 to 3 and skip Step 4 to Step 5, directly run the step 6Testing Python code.
Step 4: Open I2C function(skip this step if your SD card has pre-installed Osoyoo Robot Image)
I2C is a protocol which will be used to exchange data with I2C device. In our project, I2C device is PCA9685 module.In order to use I2C function, we need type following command from terminal:
sudo raspi-config
Then select Advanced Options or Interfacing Options->I2C->Yes->Ok->Finish
Step 5: Install GPIO Library(skip this step if your SD card has pre-installed Osoyoo Robot Image)
(1)Update Rasbian Repository by typing following terminal command
cd ~
sudo apt-get update
(2)Install python-pip , python-sumbus and github
sudo apt-get install build-essential python-pip python-dev python-smbus git
(3)Install GPIO Library by typing following terminal command
git clone https://github.com/adafruit/Adafruit_Python_GPIO....
cd Adafruit_Python_GPIO
sudo python setup.py install
(4)Typing following terminal command to remove installation files and save disk space
cd ~
sudo rm -fr Adafruit_Python_GPIO
Testing Previous Installation(skip this step if your SD card has pre-installed Osoyoo Robot Image)
(5)Download testing python code by typing the following commands:
cd ~
mkdir osoyoo-robot/
cd osoyoo-robot/
wget http://osoyoo.com/driver/motor-test.tar.gz
tar -zxvf motor-test.tar.gz
Step 6: Run Testing Python code
cd ~/osoyoo-robot/motor-test python motor-test.py
Important Note: As the raspberry pi robot car image was written into SD Card, you just need to follow the step 1 to step 3 and skip others steps, directly run the step 6 testing Python code.
After running above python sample code, your car should move forward for 2 seconds, then move backward for 2 seconds, then turn left for 2 seconds and finally turn right for 2 seconds.
If your car does not move as per above scenario, the installation should have some problem. You need double check the wire connection and software installation as per our previous steps.