Sokoban Robot Using L0Cost Robot Controller With ESP32-CAM Camera for FPV

by tekyinblack in Circuits > Robots

609 Views, 5 Favorites, 0 Comments

Sokoban Robot Using L0Cost Robot Controller With ESP32-CAM Camera for FPV

IMG_9240.JPEG
pic4.png
pic1a.png
pic2.png
pic3.png

Sokoban is a computer game of rearranging boxes or crates in a warehouse, but instead of a computer screen, this robot has been made to play the game physically, by pushing polystyrene blocks around on a marked out course.

The robot has been designed on TinkerCAD and can be viewed and copied here. Constructed to provide an easily modified base to both enable learning and play it was designed on the TinkerCAD platform so it can be quickly modified with additions and feature changes while the use of the L0Cost Robot Controller enables the robot to be up and running quickly with customisable scripts, webpages and easy expansion routes.

The robot includes a camera, making for interesting play with first person view control from a web page or just giving a video while the robot navigates from a script. Control can be browser based, scripted or from a handheld games controller. The robot needs to be used on a very smooth surface and the robot arena described in the instructable Portable Robot Arena would make a good games arena and prevent robots accidentally being damaged from falling off tables or being trodden on.

Because TT motors are sometimes supplied with 68mm wheels, an alternative design is available here. The only printed part change is the size of the skids, more details of this in a later step.

Supplies

ESP32-CAM

FDTI programmer or ESP32-CAM-MB see programming step later

SDcard (max spec is up to 4GB, but your board may take larger)

Stripboard

PCB pins and sockets

Dupont leads

2 x TT motors and 40mm or 68mm wheels

6 x AAA batteries or 2 x LiPo batteries with holders and connectors

L293D DIL chip

7400 quad NAND gate

14pin and 16 pin IC sockets

Latching push switch

3D printed parts, see list of files later

M3 bolts and nuts

Zip cable ties

optional: digital voltmeter

2 x ball bearings

Print Robot Components

Chassis pic.png
Battery box pic.png
Camera stand.png
camera mount vertical.png
Camera mount.png
voltmeter mount.png
Buffer.png
Ball Bearing Skid.png
Basic skid.png
Shims.png
LiPo battery box.png
LiPo voltmeter.png

The attached '.stl' files will build the Sokoban robot but some modification may be needed if the components obtained don't quite match. The robot was designed on TinkerCAD and the published design can be found here and is available to copy, modify and download.

Four areas that will need a decision by the builder are:

  1. Orientation of the camera, which will be discovered in Step 3, will need different camera brackets printing. Select the one for the camera to be used once Step 3 is complete and then print that item.
  2. The robot is intended to be used with either NiCad or LiPo batteries. Print the version of the battery box, and voltmeter holder, that will be used.
  3. The robot is intended for use on a smooth surface, so either a ball bearing or a fixed skid might be used. Files for both are provided.
  4. Will 68mm wheels be used instead of 40mm wheels. See the version of the design on TinkerCAD here for 68mm wheels.

When following this instructable, printing of the parts can run in parallel to the other steps up to assembly.

L0Cost Robot Controller Introduction

Sokoban ass 11.JPEG

The L0Cost Robot Controller is an ESP32-CAM board containing dual core processor, Wi-Fi, Bluetooth, an SD card reader, a high intensity LED and a digital camera. All of these features make for a unit which is capable of a lot of processing, but limited physical interfaces so it has been utilised to provide a communication and control feature to other robots where another microcontroller provides dedicated control features. Instead of being dedicated, a configured controller is intended to be reusable and can be moved between different robot chassis to provide an interface.

In it's most basic form, the controller can provide local control for two servos or two motors, as in this instructable.

An SD card is used to store configuration information, which describes the mode of remote access, hand held controller or webpage, Wi-Fi or Bluetooth, client or access point and holds a web page which can be coded or customised by the user to provide the features required. The attached pdf document describe the SD card contents and the simple command syntax.

Code and a further description of the controller are held on github here.

Test the ESP32-CAM

Before completing the build of the robot, it is important to discover the orientation of the camera, which may be horizontal or vertical, otherwise it will be difficult to view the camera image on a screen. To do this, the ESP32-CAM is programmed with the controller software and the video feed viewed on a webpage.

Firstly, download the latest controller software from github here and create a new project with it in the Arduino IDE. Two libraries will also be needed to be loaded into Arduino, ESP32Servo, (by Kevin Harrington and John K Bennett) and PS3 Controller Host (by Jeffery van Pernis).

A set of SD card files also need to be loaded onto an SD card and inserted into the ESP32-CAM before rebooting. There is an example set on github marked as Sokoban. For initial testing, the WiFi.txt file needs to be edited to provide the local SSID and password. If the ESP32 will be used in access point mode, the config.txt file will need editing according to the L0Cost Robot SDcard Files pdf in the previous step to enable this option.

Once the controller has rebooted, connect to the webpage 'Sokoban', either on the local Wi-Fi network or after connecting to the access point SSID defined. View the video and note the orientation.

Assemble the Controller Circuit

Sokoban circuit 1.JPEG
L0cost Sokoban Controller V01.png
Sokoban circuit 2.JPEG
L0cost Sokoban Controller V01 reverse.png
Sokoban schematic 2_bb.png
Sokoban schematic 2_schem.png

Briefly, the motor outputs from the LRC are routed to a L293D motor controller IC via a pair of NAND gates. One output is routed directly to provide speed control. The other two are converted into four inputs to the L293D by inverting the signal using the logic gates as inverters.

The controller circuit has been assembled on a small piece of stripboard using two ic sockets, pcb pins and pcb sockets together with a switch. As far as possible, all fitted connections run across the strips, except for one fitted along a strip to avoid a mounting hole, shown in black in the picture.

The pcb pins can either be mounted standing up from the front of the board, but the connections are easier if they are mounted through the board, see picture, and connected to the rear.

Assemble the Power Supply

sokoban ass10.JPEG

There are two options available for powering the robot described here.

  1. Directly using 4xAAA NiCad batteries
  2. Using 2 x LiPo cells in the LRC power supply, documented in this instructable here.

The picture shows a 4 x AAA battery holder which is held in the NiCad battery box and connects directly to the controller board. It has had two dupont female connectors fitted to the wires to make it easy to connect and reuse.

The battery box for the LiPo power supply is provided in this instructable with the correct mounting holes, the circuit and assembly is the same as the original.

Assemble the Robot

Sokoban printed parts.JPEG
Sokoban ass 1.JPEG
Sokoban ass 2.JPEG
Sokoban ass 3.JPEG
Sokoban ass 4a.JPEG
Sokoban ass 4b.JPEG
Sokoban ass 5a.JPEG
Sokoban ass 6a.JPEG
Sokoban ass 6b.JPEG
Sokoban ass 7a.JPEG
Sokoban ass 7b.JPEG
Sokoban ass 8.JPEG
Sokoban ass 9.JPEG

The pictures are numbered to aid assembly.

  1. Solder four wires to the motors with male dupont connectors on the ends. This can be done by adding two wires and then fitting the male connectors or taking an existing dupont cable with male ends and removing the unneeded end.
  2. Fit the two motors into the chassis and fix in place with 4 x M3 x 30m bolts. The bolts may hold themselves in place against the plastic but there is sufficient length to incorporate a nut on the end of each bolt. Care needs to be taken not to overtighten and break the chassis plastic. The wire connectors can then be fastened against the motor body using zip ties to make them more resilient to breaking off in use.
  3. Fit the wheels to the axles using screws.
  4. Fit the chosen skids to the chassis, one front and one at the rear, using the printed spacers to adjust the fitting so that the chassis is almost, but not quite level, there should be 0.5-1mm of rocking to ensure that the wheels have good contact. The ball bearings must be fitted to do this if they are going to be used.
  5. If the voltmeter will be used fit it to the appropriate holder, for either NiCad or LiPo batteries. In the case of the NiCad holder, attach this to the Camera stand.
  6. Fit both the camera stand and the buffer to the front of the chassis using M3 nuts and 2 x M3 x 10mm bolts.
  7. Fit the chosen battery box, either NiCad or LiPo. The NiCad box fits over the rear skid fixing, for the LiPo box, the rear skid has to be removed and re-attached through the hole in the battery box.
  8. Attach the stripboard circuit to the appropriate camera mount using M3 nuts, bolts, and the plastic spacers printed earlier.
  9. Attach the camera mount to the camera stand using nuts and bolts, and then adjust the camera to the desired position before tightening the bolts up.

Wiring

Sokoban wire 1.JPEG
Sokoban wire 2.JPEG

The pictures show where the connections go.

  1. Connect the motors to the circuit board, be prepared to remove and swap these during testing.
  2. If using NiCad batteries, connect the voltmeter to the voltmeter terminals on the controller circuit board. If using the LiPo battery box, the voltmeter connections are in the picture.
  3. For Nicad, connect the batteries directly to the terminals on the controller board shown in the pictures, double check this is the correct orientation otherwise the circuit may be damaged. The LiPo batteries will need a double female dupont patch lead connecting between battery box and controller board.
  4. Don't tie the connections up until testing is completed.

Testing

Sokoban test1.JPEG
Sokoban test2.JPEG
  1. For testing, ensure that the robot is stood or held such that the wheels can be observed but don't touch anything. This is to stop the robot running off a workbench or table.
  2. Check that the voltage supplied to the ESP32 board is around 5V.
  3. After checking all the connections are correct and the SD card has been customised, see step 3 for basics, switch on, the motors should run briefly and the Wi-Fi connect.
  4. Using a web browser, connect to the robots web page and try-out the direction commands. If one or both motors are turning in the incorrect direction, reverse the circuit connections for that wheel.
  5. Forward - both wheels turn forward
  6. Left - Left wheel turns backwards, right wheel turns forward
  7. Right - Left wheel turns forwards , right wheel turns backwards
  8. Reverse - both wheels turn backwards
  9. Check that the video is working and that the LED controls also work.
  10. Zip tie the wires in place to improve the look and make the connections more reliable.
  11. The robot should now be ready for trials. The web page can be edited to customise it's use and a test webpage is included to allow individual commands to be tried out.

Games

IMG_9219.JPEG
IMG_9220.JPEG
IMG_9224.JPEG
IMG_9225.JPEG
IMG_9226.JPEG
IMG_9227.JPEG
IMG_9228.JPEG
IMG_9229.JPEG
IMG_9230.JPEG
IMG_9231.JPEG
IMG_9232.JPEG
IMG_9233.JPEG
IMG_9234.JPEG
IMG_9235.JPEG
IMG_9236.JPEG
IMG_9237.JPEG
IMG_9238.JPEG

A Sokoban game layout is shown in the pictures and many more could be created. The objective is to move the boxes onto the target squares by only pushing them, with the robot starting from a set position. To achieve this, the robot may push other boxes out of the way but must not push two or more boxes at once. The robot must not leave the area bounded by the black line. These limitations are currently rules for players but anyone is welcome to improve on this and add features to the robot to build them in.

The pictures show the progress of a game from the start to the final target position. It's important to ensure that there aren't any loose wires as they can catch on the blocks and snag when playing, so zip ties are important.

The LRC can process video frames so can be used to add line, shape and colour detection to support line and object following.

Alternative 68mm Wheels

pic 5.png
pic 6.png

This instructable has used 40mm wheels but frequently 65mm wheels are supplied with TT motors. The previous design instruction still hold but a different set of skids must be used to balance the robot. An stl file for these is attached and the design on TinkerCAD for these wheels is here. These wheels make the robot at bit wider so game board has to be upscaled appropriately.

Other Robots

IMG_7998.JPEG
IMG_8005.JPEG

The purpose of the L0Cost Robot Controller is to enable fun robots to be built which can provide sophisticated robots quickly but easily customisable via scripts, webpages and via TinkerCAD so that any particular robot can be unique to it's builder. Other robot designs using this concept wlll be available on instructables.com over time.