Rapiro – How to modify and upload the Arduino sketch

This post is meant as a first how-to for Rapiro, the Raspberry Pi robot. The goal will be to start off with some simple topics and gradually move to more complex things.

It will be a good opportunity for me to use my robot and try to discover its full potential, while getting feedback and/or requests from you.

Do you think that’s a good idea? If yes, what topics would you like to see covered? Leave a comment!


For a video version of this how-to, watch the embedded video below, otherwise, keep on reading …



The topic I’d like to cover in this how-to: modifying and uploading the Arduino sketch to Rapiro. More specifically to solve a particular issue.

It’s very likely, that after assembling Rapiro and powering it for the first time, some servos are not properly aligned.

If you look at the picture below, you’ll notice a few mistakes:

  • the arms are pointing to the back instead of being straight down
  • the head and waist are not aligned with the feet
  • the feet are not sitting flat on the table

The last one is hard to see from the picture because the robot’s weight is pushing them flat. This is however causing a lot of noise as the servo is trying to maintain its position even though it is being forced in another.

Screen Shot 2015-01-12 at 09.30.53


There are certain things you’ll need for this how-to:

  • an assembled Rapiro (obviously …)
  • a computer
  • a micro USB cable to upload the sketch
  • a power supply or batteries to power the robot

Arduino IDE

The first thing you’ll need is the Arduino IDE. This is required to modify and upload the sketch to Rapiro.
If you don’t have it installed yet, go to and download the latest version.

Screen Shot 2015-01-11 at 21.42.23

Rapiro Sketch

The second thing needed is the sketch used to program Rapiro, which we will be editing.
The sketch can be found on, in the download section.

Screen Shot 2015-01-11 at 21.45.18

Correcting Servo Position

Open the Rapiro sketch by double-clicking on the Rapiro *.ino file. This should launch the Arduino IDE and visualise the code.

Screen Shot 2015-01-12 at 18.48.36

You’ll notice a bit of code for the fine angle adjustments, that’s the part needed to fix the initial servo positions without having to take apart the robot and redo the assembly. Unless the correction exceeds 20 degrees, in which case reassembling that part is recommended.

It requires a bit of trial and error to find the right values. After corrections, you could end up with something similar:

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

Once the sketch is modified, it needs to be uploaded to Rapiro:

  • power off Rapiro
  • connect the micro USB cable to Rapiro and the computer, Rapiro’s eyes should light up
  • in the Arduino IDE:
    • select “Arduino UNO” as board type (Tools > Board)
    • select the correct serial device (Tools > Port)
    • press the “Upload” button

Rapiro’s eyes will turn off while the upload is ongoing and light up again once finished.

After having uploaded the modified sketch and powering on Rapiro, it should stand straight and be properly aligned as demonstrated below:

Screen Shot 2015-01-12 at 09.31.23

If not, repeat the process of modifying and uploading the sketch until the position is as desired.

© Frederick Vandenbosch, 2014-2021. Unauthorised use and/or duplication of this material without express and written permission from this blog’s author and owner is strictly prohibited. Excerpts and links may be used, provided that full and clear credit is given to Frederick Vandenbosch with appropriate and specific direction to the original content.