[MeetUp #3] Robots basados en Raspberry Pi: Scratch y Phyton

Step-by-step tutorials for GoPiGo: http://www.dexterindustries.com/gopigo2-tutorials-documentation/

0. Options for installing the OS image in the Raspberry Pi

  • Option 1: Download and install the Dexter Industries “Raspbian for Robots” image

  • Option 2: Modify your own image. If you want to use your own wheezy installation, you must make the following changes yourself to the Raspberry Pi. You can download and run the install script.  This will automatically download and install all the packages and dependencies required for GoPiGo to your existing Raspbian image.

git clone https://github.com/DexterInd/GoPiGo.git
cd Setup
sudo chmod +x install.sh
./install.sh

Follow the onscreen instructions and the script will install all the dependencies and will Restart upon completion. Your Raspbian should now be ready to run GoPiGo.

Main differences between Option 1 and what I actually had to do to make it work are:

I changed the password of pi user from robots1234 to raspberry (to be the same as the default in Raspbian).

Password for VNC access remains as robots1234

If you access from another Raspberry Pi you may use xtightvncviewer as VNC client side software.

Instructions for installing VNC Viewer in PC or Mac.

1. Test GoPiGo robot

    Turn your GoPiGo upside down on the table because the demo will make the motors and wheels spin. You don’t want it to fall off the table!

    Then click the “Demo GoPiGo” button. Follow the instructions on the screen.

    If everything goes as planned, you can celebrate your success – mission accomplished! Now you can proceed out the Scratch and Python examples here.

    2. Basic SCRATCH Robot

    Double click the “Scratch” icon on the desktop (identified here with the green arrow) to start Scratch for Robots, the program which communicates between the GoPiGo and Scratch.

    This will open two windows, a black terminal window called the Scratch Controller and the Scratch for Robotsinterface. Do NOT close the Scratch Controller, as that will kill all communications between Scratch and the robot!

    You can then click on “Open Examples” to find the basic robot example.

    Double click the GoPiGo_Basic_test.sb in the Examples window.

    Press the Green Flag on the top right corner to start the program. To control the GoPiGo, press:

    • Up arrow– move forward
    • Down arrow– move back
    • Left arrow– turn left
    • Right arrow– turn right
    • w-Increase speed
    • s-Decrease speed
    • o & p – control left LED
    • k & l – control right LED
    • Space– stop

    Stop the program once you are done by pressing the Red Flag.

    3. GoPiGo SCRATCH Control Panel

    Start the control panel by double clicking the GoPiGo_control_panel.sb file.

    Press the Green Flag on the top right corner to start the program.

    Press the various buttons to control the GoPiGo

    Stop the program once you are done by pressing the Red Flag.

    4. PYTHON: Mouse Control

    Open VNC and go to the Mouse control example folder:

    cd ~/Desktop/GoPiGo/Software/Python/Examples/Mouse_Control/
    
    sudo python mouse_control_movement.py

    Press Enter when you are prompted.
    To control the GoPiGo from the mouse:

    • Move the mouse up, down, left or right to control the GoPiGo
    • Press the Left mouse button to stop

    You can see the mouse movement in the X and Y directions. When you move the mouse fast enough, the GoPiGo will start moving around. Press Ctrl+C to stop.

    5. PYTHON: Browser Streaming Robot

    Connecting the Camera module

    Attach the Raspberry Pi camera module to the CSI port behing the ethernet port. For more details on how to attach the camera, refer to the official Raspberry Pi tutorial here.

    Setting up the GoPiGo

    Make sure that the GoPiGo is set up properly and you have the updated software and firmware. If you are not sure about this, follow the guide here.

    If the GoPiGo is properly set up, connect to the GoPiGo via SSH or VNC and open terminal.

    cd ~/Desktop/GoPiGo/Software/Python/Examples/Browser_Streaming_Robot/
    sudo chmod +x robot_web_server.py
    sudo ./robot_web_server.py

    Now open the browser and enter dex.local:98 in the browser and hit enter to start streaming. You’ll also see some activity in the terminal.

    http://192.168.43.178:98

    You can also stream it on a mobile device. Make sure that the device is connected on the same WiFi network. Open the browser and enter the IP address of the Raspberry Pi to start streaming the video.