# Robot assembly

This file contains assembly instructions for building the robots and soldering the electronics.

Here is how the finished robot will look like:
![finished robot](https://imaginaerraum.de/git/Telos4/RoboRally/raw/branch/master/docs/images/finished_robot_2.jpeg)

## Components

The robot consists of the following components:

* [Adafruit Mini 3-Layer Round Robot Chassis Kit](https://www.adafruit.com/product/3244)
* [Wemos D1 mini](https://aliexpi.com/41SY)
* [Wemos D1 mini battery shield](https://aliexpi.com/sNwB)
* [Wemos D1 mini motor shield (v1.0.0)](https://aliexpi.com/wngF)
* LiPo battery

In addition you will need the following tools:

* A soldering iron
* Solder wire
* Heat shrink tube
* Some wires
* Battery connectors (fitting your battery)
* Velcro tape
* Self adhesive tape
* Isolation tape
* Pin headers

For the camera based position detection of the robots you will need:

* A camera
* A printer
* Paper
* Cardboard

## Assembly instructions

### Robot chassis
Assemble the chassis according to the instructions provided by adafruit ([see here](https://learn.adafruit.com/tri-layer-mini-round-robot-chassis-kit)).

### Soldering the electronics
####Preparing Wemos D1 mini and shields

| Description | Image|
|--------------|---------------|
| Solder on two rows of 8 male pin headers to the D1 mini | ![D1 mini](https://imaginaerraum.de/git/Telos4/RoboRally/raw/branch/master/docs/images/d1_mini_pins.jpg) |
| Solder on two rows of 8 female pin headers to the motor shield . | ![Motor shield](https://imaginaerraum.de/git/Telos4/RoboRally/raw/branch/master/docs/images/motor_shield_1.JPG) ![Motor shield](https://imaginaerraum.de/git/Telos4/RoboRally/raw/branch/master/docs/images/motor_shield_2.JPG)|
| Also solder a single row of bent pins to the motor shield. Make sure they are soldered on the right way around.| ![Motor shield](https://imaginaerraum.de/git/Telos4/RoboRally/raw/branch/master/docs/images/motor_shield_3.JPG)|
| Solder a jumper to the motor shield to connect the RTS and 3V pin. This will become important later on. Also solder the I2C bridge. | ![Motor shield](https://imaginaerraum.de/git/Telos4/RoboRally/raw/branch/master/docs/images/motor_shield_jumper.jpeg)|
| Solder on two rows of 8 female pin headers with long pins to the battery shield | ![Battery shield](https://imaginaerraum.de/git/Telos4/RoboRally/raw/branch/master/docs/images/battery_shield_1.JPG) ![Battery shield](https://imaginaerraum.de/git/Telos4/RoboRally/raw/branch/master/docs/images/battery_shield_2.JPG) |
| Cut off the tips of the long pins such that the battery shield nicely fits into the motor shield | ![Mind the gap](https://imaginaerraum.de/git/Telos4/RoboRally/raw/branch/master/docs/images/battery_shield_3.JPG) ![Cut off tips](https://imaginaerraum.de/git/Telos4/RoboRally/raw/branch/master/docs/images/battery_shield_4.JPG) ![Nice fit](https://imaginaerraum.de/git/Telos4/RoboRally/raw/branch/master/docs/images/battery_shield_5.JPG) |

#### Connecting battery shield and motor shield for motor power supply
In the next step we connect the battery connector pins of the battery shield to the + and - pins of the motor shield. In addition we will add a connector to the motor shield where we can plug in the battery. Here is a schematic:
![Motor shield and battery shield sketch](https://imaginaerraum.de/git/Telos4/RoboRally/raw/branch/master/docs/images/motor_battery_stack_bb.jpg) 

*Note: I added a new connector instead of using the one already on the battery shield because the plug of my battery wouldn't fit in the on on the shield*

- First, solder two wires to the + and - pins of the battery shield and isolate them with heat shrink:

| Description | Image|
|--------------|---------------|
|Cut two small pieces of wire (about 4 cm), remove the isolation on both ends and cover them with a bit of solder            |   ![Battery Shield Wires](https://imaginaerraum.de/git/Telos4/RoboRally/raw/branch/master/docs/images/motor_batter_stack_2.jpeg)|
|Solder the first wire to the + pin of the battery shield |  ![First wire soldered](https://imaginaerraum.de/git/Telos4/RoboRally/raw/branch/master/docs/images/motor_battery_stack_3.jpeg) |
| Solder the second wire to the - pin            |  ![Second wire soldered](https://imaginaerraum.de/git/Telos4/RoboRally/raw/branch/master/docs/images/motor_battery_stack_4.jpeg) |
| Cover both wires with small pieces of heat shrink tube           |  ![Heat shrink](https://imaginaerraum.de/git/Telos4/RoboRally/raw/branch/master/docs/images/motor_battery_stack_5.jpeg) |
| Heat the shrink tube with a lighter  |  ![I see fire](https://imaginaerraum.de/git/Telos4/RoboRally/raw/branch/master/docs/images/motor_battery_stack_6.jpeg) |
| This is how the battery shield should look like with the two wires           |  ![Two wires with heat shrink](https://imaginaerraum.de/git/Telos4/RoboRally/raw/branch/master/docs/images/motor_battery_stack_6.5.jpeg) |

- Next, we create a connector for the battery. In my case the battery had a male JST 2-Pin connector, so I soldered a female JST 2-Pin connector for plugin it in: 

| Description | Image|
|--------------|---------------|
| Cut two small pieces of wire (about 3 cm), remove the isolation on both ends and cover them with a bit of solder  | ![DIY JST connector](https://imaginaerraum.de/git/Telos4/RoboRally/raw/branch/master/docs/images/motor_battery_stack_7.jpeg) |
| Solder the first wire to the JST connector |![First wire soldered](https://imaginaerraum.de/git/Telos4/RoboRally/raw/branch/master/docs/images/motor_battery_stack_8.jpeg) |
| Solder the second wire to the JST connector | ![Second wire soldered](https://imaginaerraum.de/git/Telos4/RoboRally/raw/branch/master/docs/images/motor_battery_stack_9.jpeg) |
| Cover both wires with heat shrink | ![Heat shrink cover](https://imaginaerraum.de/git/Telos4/RoboRally/raw/branch/master/docs/images/motor_battery_stack_10.jpeg) |
| Solder the wires to the motor shield, paying attention to the polarity *(make sure it matches the polarity of your batteries!)*  | ![Battery connector to motor shield](https://imaginaerraum.de/git/Telos4/RoboRally/raw/branch/master/docs/images/motor_battery_stack_11.jpeg) |

- Now, stack the battery shield on top of the motor shield and solder the battery connector:

| Description | Image|
|---|---|
|  Connect the + pin of the battery shield to the + pin of the motor shield. Be sure to isolate the connection with heat shrink. Then repeat the same for the - pins. | ![Motor shield and battery shield connection](https://imaginaerraum.de/git/Telos4/RoboRally/raw/branch/master/docs/images/motor_battery_stack_15.JPG)|
|  This is how it should look like in the end. | ![Side view](https://imaginaerraum.de/git/Telos4/RoboRally/raw/branch/master/docs/images/motor_battery_stack_12.jpeg) ![Top view](https://imaginaerraum.de/git/Telos4/RoboRally/raw/branch/master/docs/images/motor_battery_stack_14.jpeg) |

### Next steps

This concludes the main steps for the robot assembly. The next step is to fix a problem with the firmware on the motor shield in order to use it via I2C. Head over to [2_MOTOR_SHIELD_FIX.md](https://imaginaerraum.de/git/Telos4/RoboRally/src/branch/master/docs/2_MOTOR_SHIELD_FIX.md) for the instructions.
