Add some readme files, start fixing docker build.

Docker (and CI in general) build currently isn't generating protobuf files.
Docker image also needs to check that pigpio works.
This commit is contained in:
Piv
2020-08-30 15:16:15 +09:30
parent 2c84b1bc80
commit 622ed0911e
6 changed files with 117 additions and 1 deletions

View File

@@ -16,6 +16,13 @@ RUN apt-get install -y \
libpq-dev \
&& rm -rf /var/lib/apt/lists/*
# PIGPIO - used to control servos.
RUN wget https://github.com/joan2937/pigpio/archive/master.zip \
&& unzip master.zip \
&& cd pigpio-master \
&& make \
&& make install \
&& cd .. && rm -rf pigpio-master master.zip
ARG PYPI_USERNAME
ARG PYPI_PASSWORD

51
pycar/README.md Normal file
View File

@@ -0,0 +1,51 @@
# PyCar
This module is the original project for RC Car control, and as such contains the most functionality.
Note that only python 3+ has been tested for support (up to and including python 3.8).
## Build
Before building with python or Docker, you should generate protobuf code. If you have Java installed, the easiest way to do this is with the :pycar:copyPythonCode gradle task
`./gradlew :pycar:copyPythonCode`
Build using setup tools.
The easiest way to build is using the gradle task. This will also generate protobuf code if it hasn't already been generated.
`./gradlew :pycar:build`
Otherwise you can run:
`python setup.py bdist_wheel`
### Docker
A docker image has been created to ease deployment on the raspberry pi.
The docker image is always built on a tag in GitLab CI.
Otherwise, the image can be built by running
`docker build --build-arg PYPI_USERNAME=$PYPI_USERNAME --build-arg PYPI_PASSWORD=$PYPI_PASSWORD .`
or running the gradle task (which will also generate protobuf code)
`./gradlew :pycar:buildDocker`
## Runtime environment variables
There are two key environment variables that should probably be configured at runtime:
CAR_VEHICLE
- This variable can have two values, and is used to control whether
- Possible Values:
- CAR_MOCK (Default, log changes to stdout)
- CAR_2D
- Use gpiozero and pigpio to control steering/throttle servos)
CAR_LIDAR
- This variable controls whether an RPLidar will be used, or a file to load LiDAR scans from.
- Possible Values:
- LIDAR_MOCK (Default)
- {Serial Port}
- You must have an RPLidar connected via this port to access. For most linux systems such as raspberry pi, this will probably be /dev/ttyUSB0

View File

@@ -20,6 +20,12 @@ task build(type: Exec, dependsOn: copyPythonCode) {
args 'setup.py', 'bdist_wheel'
}
task buildDocker(type: Exec, dependsOn: copyPythonCode) {
executable 'docker'
workingDir projectDir
args 'build', '--build-arg', "PYPI_USERNAME=$System.env.PYPI_USERNAME", '--build-arg', "PYPI_PASSWORD=$System.env.PYPI_PASSWORD", '-t', 'vato.ddns.net:8082/pycar:latest', '.'
}
task clean {
doLast {
delete 'dist'

View File

@@ -31,7 +31,7 @@ def _is_pin_valid(pin):
class Vehicle:
def __init__(self, motor_pin=19, servo_pin=18):
subprocess.call(['sudo', 'pigpiod'])
subprocess.call(['pigpiod'])
Device.pin_factory = PiGPIOFactory()
print('Using pin factory:')
print(Device.pin_factory)