Simple Pi Robot aims to put robot control in simple form.
The part list
(1) Raspberry pi (Any model) but with the recent launch of pizero or pi 2 shall be a good option, my current model employs B+.
(2) 40 pin GPIO cable (if using pi B+ or pi 2).
(3) Breadboard (for quickly assembly various sensors).
(4) A 2wd chassis.
(5) Distance sensor (Ultrasonic HC SR04).
(6) Power bank (for powering up the pi).
(7) Rechargeable batteries AA (preferably 2100 mAH).
(8)Jumper wires both Male & female type, Resistors.
(9) WiFi adapter (EDUP/EDIMAX for communicating wirelessly with pi).
(10) Memory card (4GB and higher for running the OS on pi).
(11) Motor drivers (L298 ).
(12 )servo motor.
(13) Miscellaneous - cable ties (for tying the jumper wires) and foam tape (for holding servo or any other sensor where screw assembly cannot be used).
Step 1: Choosing the Motor drive shieldCurrently there are very few motor drive shield available for raspberry pi, to name some:-
(1) RTK Motor controller shield
(2) Pololu DRV8835 Dual Motor Driver Kit for Raspberry Pi
(3) Adafruit DC and Stepper Motor HAT for Raspberry Pi
(4) Raspirobot board made by Adafruit
and recently underdevelopment like ZEROBORG
One of the most common problem building any robot, is to minimize the wiring requirement and the same can be achieved by using the shields/hat. I tried building my robot, first with one of the shield equivalent to Raspirobot from the manufacture ALSROBOT. The kits ships from china but the problem was i was unable to increase the motor input voltage. The maximum was less than 5 Volts, with slight unbalance between the voltages, still one can check the following link - ALSROBOT - PI Motor driver shield
Anyhow In my current tutorial i have used the cheap and versatile L298 motor driver - L298.
The advantage with the above board apart from being cheap, is that there is regulated 5Volts output is available.
I have used the L298 board to drive two DC motors and 1 servo motors.
Step 2: The L298 Motor DriverI have Mounted L298 Motor driver at the bottom of my chassis, now to connect the DC motor and servo motor connect
(i) DC Motor -A to output -A (+ & -).
(ii) DC Motor -B to output -B (+ & -).
(iii) Servo motor +ve to + 5V regulated supply of L298 Board & servo motor -ve to GND of L298 Board.
Keep the enable pin jumper as it is, if you don't want speed control, else remove the jumper. The jumper in place ensures +5V supply to enable pin which in turn drives motor at rated speed.
Now connect 4 nos jumper wires to the control inputs, connect other end of jumper wires to GPIO pin as designated in next step.
For servo motor connect one no. jumper wire for control to GPIO pin as in next step
Step 3: The servo MotorThe servo has a 3 wire connection: power, ground, and control. The power source must be constantly applied.
The control signal is pulse width modulated (PWM), but here the duration of the positive-going pulse determines the position of the servo shaft. For instance, a 1.520 millisecond pulse is the center position for a Futaba S148 servo. A longer pulse makes the servo turn to a clockwise-from-center position, and a shorter pulse makes the servo turn to a counter-clockwise-from-center position.
I have used Futuba s3003 servo - the connection is very simple the "+" & "-" goes to the L298 Board as outlined earlier. It's important to look at the operating voltage of servo ( in my case its 4.8 - 6 V see image above), the signal wire is to be connected to GPIO output , normally its white or orange.
Controlling servo motors in raspberry pi might be tricky, but then there is very powerful library hosted @ RPIO.PWM ,to install it on pi use the following code.
sudo apt-get install python-setuptools
sudo easy_install -U RPIO
To know more about RPIO.PWM and the DMA used , please refer to the link https://pythonhosted.org/RPIO/pwm_py.html
Step 4: The Robot chasisI have used Ellipzo Robot chassis with 2wd, 2wd are simple and easy to control.
The kit comes included with DC Motors, pan kit for servo motors and all necessary hardware's to assemble the kit.
The detailed link is available at - Ellipzo Robot chaisis kit.
Pl. refer to video for assembly of Raspberry Pi, along with L298 motor driver, the Breakout board, camera module and the power bank.
Step 5: The Distance sensorIntegrating the distance sensor is easy and we need just 1k resistor, along with jumper wires. Connect VCC & GND to pi +5Volts & GND respectively.
The other two pins TRIG & ECHO are to be connected to GPIO pins as in preceding steps. Remember to connect the resistor as shown in image.
The Python code to measure distance is included in the last step.
Step 6: Raspberry Pi -camera - Video streaming using VLC playerHere I have used Pi camera module, the set up is quite easy and you can refer the link :Raspberry pi Camera setup
For video streaming, with VLC begin with installing VLC on raspberry pi
sudo apt-get install vlc
To start streaming the Camera Video Using RTSP enter following
raspivid -o - -t 0 -n | cvlc -vvv stream:///dev/stdin --sout '#rtp{sdp=rtsp://:8554/}' :demux=h264
or with proper width & height use following code
raspivid -o - -t 0 -n -w 600 -h 400 -fps 12 | cvlc -vvv stream:///dev/stdin --sout '#rtp{sdp=rtsp://:8554/}' :demux=h264
Now to view the stream over VLC player open VLC on your remote system than open a network stream using
rtsp://###.###.###.###:8554/
where ###.###.###.### is the address of your pi given by the network router.
Now as the pi moves inside your home see the video stream on your remote system.
Step 7: Raspberry pi pin-out & python code
Comments