making a robot head with a raspberry pi insi
Poppy Robot Project files
Poppy Robot Head stls from the poppy opens source project
- Servo and servo mount
Cheap Ali express servos and
servo pan tilt
- Raspberry Pi 4
- 90 degree USB C adapter to power pi
90 Degree Right Angle USB-C Male to USB-C Female Adapter
- Stereo Camera
I used this one from Amazon but shop around.
- Arducam TOF camera
- breadboard (just broke off the side for the 5v and earth rail)
- perf board
- 2 x white leds (but you can use any colour you like)
- 2 x 220 ohm resistors
- tiny cylinder magnets I used these ones from Amazon
Mound the stereo camera, the time of flight camera and the leds on the pef board. The LEDs are should be in series with 220 ohm resistors and connected to pins 17 and 26 on the pi. I use 220 ohms because the pi gives 3.3 volts. Also, I drilled 2.5mm holes to mount the electronics on the perf board.
Print the following three robot head pieces from the Poppy Robot Project files listed above. Poppy Robot Head
The work for this was done by 3 students of the ENSAM Bachelor of technology at Bordeaux, France: Damien MARTY, Clément GEA and Éléa CHARPNTIER, under the supervison of Jean-Luc CHARLES and Cécile DELARUE, professors at ENSAM Bordeaux. I have included the STL files in this repo (in the directory STL), just incase they become unavaiable on the original repo.
- The eva_head_frontBottom
- The head_RPi4Support
- The head_top-part
They also provide some connectors to attach the tft for the face, but I'm using a pef board instead of a tft, so I just used hot glue.
This is where my design differs from the original design. Print the servo_head_connection-Body_v2.stl file. This is used to connect the head to the serov pan-tilt. I've also included the freecad file incase you want to adjust the position of the holes. It uses m2 screws. The original project has the head mounted directly to dynamixel servos, but the dynamixel servos were a bit expensive for me, so I went with the cheap ones. Although, with servos you do get what you pay for.
Build the servo pan-tilt. See for example https://youtu.be/3_fsS4YQ5Aw?si=ct7GD8LKidqGTTAt
Assemble printed files and push magnets into divets (see steps in original project as well).
- Connect the +ve of the LED & resistors to pins 17 and 26 of the pi and the -ve to earth. I soldered on some dupont female jumper wires.
- Connect the servo pan tilt to the bottom of the head.
- Connect the servo data (middle) wires to pins 18 and 27 of the pi.
- Connect the servo +ve and -ve to the plus 5v and earth on the breadboard rail (see photo).
- Connect the earth of the breadboard rail to one of the earths of the pi.
- Place the perfboard in the face opening of the printed front of the head. You can cut this down to size. I used hot glue for this.
- Connect the Arducam TOF camera to the pi camera input.
- Connect the stereo camera to the usb pi input.
Put the back on and mount on neck. I used a piece of actobotics channel with a pillow mount that I had lying around. This has since been replaced by U-channel, which you can get from serocity or gobilda. But you can just use whatever you have lying around, whether it's an old piece of aluminium extrusion from a 3d printer or even a chari leg.
Get the code running.
- Install the ArducamDepthCamera. If you are on bookwork, you should do this in a virtual environment. To get the camera working see Arducam getting started https://docs.arducam.com/Raspberry-Pi-Camera/Tof-camera/Getting-Started/ and Arducam github
- Note, for the getting started code from Arducam, the index of the camera is set to 0. Since we are using two cameras we need to find the index at run time. There is a function in my python code for this.
- To run my code, make sure the python file
robot_head.py
and the html fileindex.html
are in the same directory. - Since the code serves a webpage, you need to run with sudo, but for some reason, at least for me, I had to qualify the python3 command with the full path of the virtual environment. So I had to type
sudo path/to/venv/python3 robot_head.py
- Go to the pi ip in your browser. I tested this from a computer and a tablet but not a smart phone. You can find the ip by typing ifconfig, or you can just enter the piname.local.