Skip navigation

Raspberry Pi Projects

1 Post authored by: russm24

To start things off, I'd recommend you go through the basics first. Much of the hardware and testing parts have been covered in the post below Mr. Frederick Vandenbosch. I'll be tackling the basic scheme of things to get started with the robot using the Pi.

 

Rapiro: Putting it together and getting it to work

 

Note: Almost all of this information can be found around the net individually, but I decided to compile them here for accessibility and ease of use for everyone who's starting out and to avoid the headache of going through translations originally written in Japanese. The purpose of this guide is to serve as a starting point and reference for the users of the product.

 

Materials Used:

 

RAPIRO

Raspberry Pi

Raspberry Pi Camera Board

Any compatible WiFi USB dongle

5x Sanyo Eneloop Rechargeable Batteries

1x AC/DC adapter (Specs to be expounded upon below)

Any compatible Bluetooth USB dongle (Optional for this guide)

PS3 Controller & USB Connector (Optional)

Sensors, Speakers, and other peripherals (Optional)

 

IMG_9071.JPG

 

 

I. General Guidelines/Troubleshooting - Before you connect the Raspberry Pi

 

 

// Fine angle adjustments (degrees)
int trim[MAXSN] = { 0,  // Head yaw
                    0,  // Waist yaw
                    0,  // R Sholder roll
                    0,  // R Sholder pitch
                    0,  // R Hand grip
                    0,  // L Shoulder roll
                    0,  // L Shoulder pitch
                    0,  // L Hand grip
                    0,  // R Foot yaw
                    0,  // R Foot pitch
                    0,  // L Foot yaw
                    0}; // L Foot pitch





 

                                                     When you first turn it on:

D3S_7030-eneloop.jpg

-If you have a twitching issue, most likely the batteries are your problem. For that, the RAPIRO manufacturers recommend Rechargeable Ni-Mh batteries. Sanyo Eneloop works well in my experience. They last 45-90 minutes depending on what you're doing with the robot. As for the power supply, they recommend an AC/DC Adapter ranging from 6-12v with current of 4000mAH or more. I am using a switching power supply rated at 12v and 6000mAH. Anything beyond that might fry the board or cause it to overheat. Wouldn't want to risk it.

 

-If the robot is contorting unusually and buzzing when you turn it on, you might have to re-calibrate. Connect the RAPIRO to the computer using the Arduino IDE and upload the initial code which can be found here: https://github.com/Ishiwatari/RAPIRO

 

     Servo adjustments will be made using the chunk of code above. All of them are at '0' degrees by default. Change the values and adjust them accordingly so that the robot can stand on its own. The creator of the RAPIRO, Shota Ishiwatari says that the adjustment value should not exceed 23 degrees. If you go beyond that to set it to its initial position, it is generally recommended that you re-assemble the robot so as not to cause any problems in the long run.

 

 

When you're sure that all of these issues have been resolved, you can turn on the battery switch or connect your power supply to the DC jack to test it out. Open up the serial monitor and set the baud rate to 57600.

 

To make the robot move, use the sample commands:

 

#M0 - Make the robot cease all movement and return to its initial position
#M1 - Make the robot move forward

#M2 - Make the robot move backward

#M3 - Make the robot turn to the left

#M4 - Make the robot turn to the right

#M5 to #M9 - A series of commands that make the robot do different kinds of waving motions + changing LED colors.


When you've played around with it and tested all the functions, you're now ready to connect it to the Raspberry Pi.

 

 

II. Initial Configuration of the Raspberry Pi

 

         When you're done with the initial configuration of the robot,  the Pi needs to be configured a bit before it can be used with the RAPIRO. Before connecting the Pi to the motor board, we need to hook it up to a television set, with a mouse, keyboard and an internet connection. I'll assume you have the WiFi dongle fixed up already. If you haven't, there are lots of guides out there. You might want to set up the camera as well. For that, you can refer to: Camera | Raspberry Pi

 

A. Installing SSH

 

When you've set up the camera, the next thing you want to do is to Enable SSH. What this does is it enables you to transfer files/send commands to the Pi remotely via a secure shell. To do that, you need to install SSH.

 

sudo apt-get install ssh





 

When that's finished, you need to start it up.

 

sudo /etc/init.d/ssh start





 

Of course, we'd want this to be enabled from the get-go so we don't have to type that out every time. To do that, type in the following command:

 

sudo update-rc.d ssh defaults





 

Afterwards, you need to reboot.

 

sudo reboot





 

Next up, you have to find the Pi's IP address.

 

sudo ifconfig





 

ifconfig.png?1355172416

-Beside the wlan0 entry, at the 2nd line you'll find the "inet addr" that usually begins with 192.168.x.x , which is your IP address. Memorize/List it down.

 

-The next step is to download an SSH interface on your computer. In my case, I prefer to use PuTTY. See: Download PuTTY - a free SSH and telnet client for Windows

 

-Open PuTTY.exe and in the Host Name field, enter your Pi's IP address and click 'Open'.

 

-If you see the 'login as: ' screen, you've successfully connected the Pi via SSH and you can now remotely control the Pi and the robot itself. Screw in the camera, and connect the Pi in this orientation:

 

Rapiro_Pi_GPIO.jpg

 

B. Failsafe for the RPi

 

Sometimes, the established connection is interrupted and you won't be able to reconnect via SSH unless you hard-reset the Pi. Doing so might corrupt the SD card and you might have to do everything again. To solve this, we have to set up the Pi to automatically reboot or shut down whenever it loses its internet connection. Refer to this guide: Easy Wireless Configuration for Raspberry Pi (wicd) :  The Unwritten Words

 

While it isn't necessary, it should be a big help in the long run and it helps prevent memory loss/corruption.

 

 

C. Serial Interfacing - Motor Board and the Pi (Thanks to Frederick Vandenbosch for this part)

 

When you're done screwing the head back in with the Pi and Camera module connected, power up the RAPIRO. Wait for about 15-30 seconds for the Pi's Wifi dongle to establish a connection. Afterwards, open up PuTTY, and connect to your Pi again. Log in, and install minicom to enable serial communication.

 

sudo apt-get install minicom





 

To make the robot move (just like with the Arduino IDE serial monitor), use the following code (Change the #M6 to your liking)

 

pi@rapiro ~ $ echo "#M6" | sudo minicom -b 57600 -o -D /dev/ttyAMA0  





 

And we're finished with the basic setup!

 

III. Extra functions - Utilizing the Robot

 

This section will be updated periodically depending on the projects I'll be working on with the RAPIRO.

 

A. Interfacing the RAPIRO with a PS3 Controller

%E5%86%99%E7%9C%9F-2-4.jpg

The original guide (In Japanese) can be found here: http://www.makuake.com/blog/crowdfunding/rapiro-dualshock/

 

On the RAPIRO downloads page: http://www.rapiro.com/downloads , you will find a sample code for the PS3 controller.

 

1. Install python-setuptools, curl and pyserial

 

sudo apt-get install python-setuptools curl pyserial





 

2. Retrieve the sample code

sudo curl -O http://www.kiluck.co.jp/rapiro/rapiro_ps3.py






3. Disable the serial console (Or else an error will pop up and the Pi will cease communication). Enter the following commands and reboot afterwards:


wget https://raw.github.com/lurch/rpi-serial-console/master/rpi-serial-console -O / usr / bin / rpi-serial-console && sudo chmod + x / usr / bin / rpi -serial-console

sudo rpi-serial-console disable

sudo reboot








4. After booting up and logging in, Run the Python code (Connect your PS3 to the Pi via USB)

sudo python Rapiro_ps3.py





 

By this time, you can try pressing any button. The window will inform you of which buttons you pressed. Each button corresponds to one of the default 'test-code' movements we tackled in Part I. The analog sticks control individual movement of the left/right arms, while the L1/R1 and L2/R2 buttons control the hands.

 

 

B. Dualshock control via Bluetooth

 

Original guide can be found here: http://www.makuake.com/blog/crowdfunding/rapiro-dualshock2/

 

1. Install the necessary libraries for bluetooth connectivity

# Apt-get install bluetooth bluez-utils bluez-compat bluez-hcidump
# Apt-get install libusb-dev libbluetooth-dev joystick checkinstall

 

2. Check to see if the bluetooth function is up and running

# / Etc / init.d / bluetooth status

 

3. Run these commands to pair it up with the controller:

 

wget "http://www.pabr.org/sixlinux/sixpair.c"-O sixpair.c

gcc-o sixpair sixpair.c-lusb

 

4. Press the PS button, and check to see if it works.

 

5. Download QtSixA and compile.

 Wget https://sourceforge.net/projects/qtsixa/files/QtSixA% 201.5.1/QtSixA-1.5.1-src.tar.gz/download-O QtSixA-src.tar.gz
# Tar zxvf QtSixA-src.tar.gz
# Make
# Make install

 

6. Type in this command to start. Press the PS button and wait for it to pair up.

 

# Sixad-start

 

7. Turn on bluetooth by default by entering the following command:

 

# Update-rc.d sixad defaults

 

8. Run the rapiro_ps3.py script again and move the robot around wirelessly.

Filter Blog

By date: By tag: