Introduction: Portal 2 Sentry Turret

Have you ever wanted to recreate the fun little turret from Portal 2? We'll guide you through the step by step process in order to make a fully working human tracking Portal 2 sentry!

The inspiration of this project is of course from the game developed by Valve, Portal 2. We watched this video on YouTube, and wanted to also create a human tracking turret.

Team Contributors: Aryan, Krish, Ethan

Thanks to PrawnSoup for helping majorly with the project!

The supplies and tools necessary for this project were provided by Ms. Berbawy of Berbawy Makers for our SIDE project.

Supplies

1 kg of total filament of any color (depending on what color you prefer for legs & body)

Arduino Uno

Jumper Wires

Breadboard

3 Positional Servos (HS-485HB 180 degrees)

Arduino Camera 07V7670 (or a USB camera)

Speaker

3D Printers (Prusa XL 3D, Prusa i3 MK3S+ 3D, MarkForged Onyx Pro)

3D Printing Filament (PLA, Onyx, PETG, etc.)

  • 1 kg of total filament

Resistors for the camera (not needed for USB Camera or webcam)

  • 2 10k Ohm Resistors
  • 1 1k Ohm Resistor
  • 1 680 Ohm Resistor

M3x10 screws (5)

Barrel Plug Power Supply

Adafruit Music Shield w/ stack headers

Step 1: Modeling

To get started, download any CAD software onto your computer. For our project we used Autodesk Fusion 360 to model our turret. The first step is to model the legs. For smaller designs, you can make your legs thinner than our current model. The bigger the model, the thicker the legs should be in order to support the weight of the entire turret.

The legs are connected to a bottom plate, which has the dimensions of our servos extruded into it. Make sure to do this for your own model. You can find CAD models of your specific parts online using websites such as GrabCad. With the servo at the bottom of the turret, this would allow the turret to turn its entire body in both directions.

We then modeled the main body by extruding the shape of an oval, then splitting the body. We also designed a wing crank that would open and close the sides of the turret, with the help of a servo and rods attached to the wings.

Finally we designed a pitch that would be connected to the previous crank. This pitch would be responsible for moving the sides of the turret up and down.

When designing the model, we made sure that there was enough space in between the pitch and the bottom of the main body to place both the Arduino Uno with an Adafruit Music Shield stacked on top with a bread board.

Step 2: 3D Printing

For printing, due to our design being very big, we used several different printers in order to ensure stability and strength of our turret.

For our legs, main body and our sides, we printed them in PLA on a Prusa XL 3D printer, since these were the biggest objects. Since the legs were supporting the entire weight of the turret, we gave them a relatively high infill at around 30% in order to ensure they were strong enough to hold the weight. For the main body and the sides, we decreased the infill by a significant amount, down to around 5%, in order to reduce the amount of weight the legs would have to support.

For the baseplate, we used a Prusa i3 MK3S+ 3D using Recycled PLA. Make sure to have PrusaSlicer updated to the latest version for both of these printers for some useful new features.

Finally, for the rods and both cranks, we used the MarkForged Onyx Pro, using Onyx filament. Onyx is a type of nylon that is mixed with chopped carbon fiber, which is stronger than ABS. The reason for this choice is that we wanted the cranks to support a lot of weight without the risk of it possibly breaking. PLA was simply too weak, and PETG was a risk. Thus, we decided to print these parts in Onyx to ensure that they wouldn't break when holding up the sides of the turret.

In order to print on a MarkForged printer, we had to use a web-based 3D printing slicer called Eiger.

Step 3: Wiring

It was important to have enough space to place all the wires, Arduino, and breadboard inside the turret without affecting any mechanical parts. To best use our limited space, we placed the Arduino above the bottom servo and the breadboard along the front wall, below the camera. We used the front wall to hold the wires for the speaker and the top two servos. Solid core wires will be extremely useful for keeping your breadboard wiring compact and simple.

We then connected the 3 servos and the camera to the breadboard. As seen in the images above, the servos are wired with one cable each for signal, voltage supply, and ground.

For help wiring an Arduino Camera we recommend following this guide on how to wire the camera properly.

As for the speaker, we followed this guide (provided by Adafruit) on wiring the speaker to the music shield.

Step 4: Programming

The sentry runs code in both Python and Arduino. The Python code tracks facial movement and sends the coordinates to the Arduino. Arduino then reads the coordinates and moves the servos accordingly, turning the sentry.

The Python Code generates a window on the computer and uses the Python package, "OpenCV" to track faces. This is seen in the computer interface as a red box and is based on Shubham Santosh's arduino face tracking project. The red box follows faces and writes the coordinates to the window. The coordinates are then sent to the Arduino.

The Arduino code starts by establishing a connection to all the servos in the sentry, allowing them to rotate in accordance with the code. The code then rotates "servoz," the servo connected to the crank of the sentry, allowing the sentry to open. Then, the Arduino reads the coordinates of a face from the Python code. It turns "servox," the servo attached to the bottom of the body, left and right based on the x coordinates from Python. It also turns "servoy," the servo attached to the pitch, up and down based on the y coordinates from Python. The combined servo rotations allow the sentry to move in accordance to the position of a face, creating a face tracking sentry!

Step 5: Troubleshooting

Some major issues we faced included the following:


Legs

The biggest struggle with the legs was the design itself. The Bottom Plate's connection to the Legs is horizontal, a terrible way to hold weight. Though the angle between the leg and the ground/table was close to a right angle, the horizontal connection pushed the legs down and out, decreasing the angle at which they touched the "floor". As the angle decreased, the static friction holding up the Main Body became weaker and weaker, until the stress completely snapped the legs. This happened several times.

To combat this issue, we printed our legs with a higher infill. To increase the static friction, which holds everything up, we increased the coefficient by using rubber on the ends of each leg.


Wings

The inner mechanism with the crank was slipping a lot, preventing the opening function from working properly. In order to fix this issue, we superglued the ends of the rods into the wings so that they can no longer slip out, and will be able to hold onto the wings with a lot more strength.


Wiring

The Camera proved to be a big issue due to complicated wiring, since each pin in the Arduino Camera needed to be connected to the Arduino in some way. The first time we wired the camera, it didn't work, so we ditched it for the time being for the webcam on a laptop, which was much easier to work with.

Initially, we used three servo motors for each mechanical part. But these servos were not controlled by angle, but rather speed and time, which was inconvenient for us. Since we needed precise turns of specific angle measures, we switched to positional servos, which move based on given angles and delays. We did not necessarily need a motor that turns 360 degrees, so positional servos did the trick.

We also had trouble with the speaker. According to guides we found online and help from peers, we wired the speaker to the music shield correctly, however after running some test codes to play sound, nothing came out. We believe that either or code isn't working, or that we soldered the speaker on incorrectly. So as for now there is no sound coming from the turret but we are currently working on fixing the issue.

Step 6: Demo

This is our video!