Self-learning AI robot

This is a work in progress. The idea is to build an autonomous mobile robot (most likely a quadruped) which would use deep learning (AI) to figure out how to accomplish tasks, without any pre-training (so-called "deep reinforcement learning"). The trick is to make it fully autonomous - no external power or computer, everything it needs it carries on itself.

In a simple case, each leg would have two joints (two servos), so there would be 8 servos in total. Also, the simplest case would have a 3-axis accellerometer as the only source of data. This can be used to figure out the current speed and perhaps even the location, detect falls and bumping into obstacles. In the future other sensors could be added (like a supersonic distance sensor). No vision planned at this point, to minimize the data stream (and make self-learning more realistic).

## Parts

* NVIDIA Jetson Nano (2GB version).
	+ Weight: 125g
	+ 3.3V logics
	+ Selectable 10W or 5W consumption modes
	+ Pinout
* Power bank EAFU BE-E1:
	+ Two 5V/3A outputs
	+ Provides 6.7 Ah.
	+ Weight: 186g
	+ Size: 10.16 x 6.35 x 2.29 cm
* MPU-9250 GY-9250 9-axis Triaxis Gyroscope Accelerometer
* ~~ADXL345 3-Axis Digital Accelerometer Module~~
	+ Will not work for this project - I need a 6-axis device (accelerometer + gyrometer) to compute current robot's velocity.
	+ MEMS accelerometer
	+ 3.3V power and logics
	+ SPI or I2C interface
	+ 13-bit accuracy, selectable ranges (from 2g to 16g max)
	+ It measures the static acceleration of gravity in tilt-sensing applications, as well as dynamic acceleration resulting from motion or shock.
	+ Its high resolution (3.9 mg/LSB) enables measurement of inclination changes less than 1.0°.
	+ https://learn.sparkfun.com/tutorials/adxl345-hookup-guide/all
	+ RPi tutorial
	+ https://learn.adafruit.com/circuitpython-libraries-on-linux-and-the-nvidia-jetson-nano/i2c-sensors-devices
	+ https://learn.adafruit.com/adxl345-digital-accelerometer/python-and-circuitpython
* SG90 servo x8
	+ Weight (with the wire): 10.35g
	+ Power: 5V
	+ Signal: 5V PWM (will likely work from 3.3V)
	+ Torque: 2.5 kg\*cm
	+ Current: 100-250mA (normal), 360 mA (stalled)
* Servos control:
	+ Either this: PCA9685 PWM driver for servos
		- Up to 16 servos
		- I2C interface
		- 12-bit resolution
		- Power and logics: 3-5V
		- https://www.jetsonhacks.com/2019/07/22/jetson-nano-using-i2c/
		- Connecting to Jetson
	+ Or two of these: 3 x Logic Level Converter
		- 4 bi-directional signal lines
		- 3.3V to 5V and 5V to 3.3V signal conversion at max. 28800 bps (??)
	+ Or one of these: TXS0108E Logic Level Shifter Converter
		- Full-Duplex 8-Channel Level Conversion
		- 1.2 Mbs (!!)
	+ ~~Or perhaps nothing (feeding directly from Jetson)~~
		- Apparently not possible!
		- SG90's might work with 3.3V logics

## Testing

### ADXL345 accelerometer

* Connected ADXL345 to Jetson using I2C interface.
* Did the following on Jetson Nano:

```
sudo apt-get update
sudo apt-get upgrade
i2cdetect -r -y 1  -> address 53
sudo apt-get install python3-pip
pip3 install adafruit-circuitpython-adxl34x

```

* Then ran the following Python script:

```
import time
import board
import busio
import adafruit_adxl34x
i2c = busio.I2C(board.SCL, board.SDA)
accelerometer = adafruit_adxl34x.ADXL345(i2c)
while True:
   print("%f %f %f"%accelerometer.acceleration)

```

* I discovered that I am getting ~100 unique measurements per second. Trying to figure out how to increase the number using the adxl34x library.
* More importantly, Python produces maximum 1000 measurements per second. I need many more for accurate velocity/coordinates integration.
* Trying to find C/C++ support for either I2C or SPI. This should produce much higher speed.