Skip to content

Commit

Permalink
lille
Browse files Browse the repository at this point in the history
  • Loading branch information
EParisot committed Mar 16, 2019
1 parent 80480ef commit e8ffcbe
Show file tree
Hide file tree
Showing 11 changed files with 831 additions and 104 deletions.
File renamed without changes.
457 changes: 457 additions & 0 deletions Data_processing/Training/5_directions_models_Obstacle.ipynb

Large diffs are not rendered by default.

384 changes: 282 additions & 102 deletions Data_processing/Training/5_directions_models_Opti.ipynb

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion Data_processing/Training/Validation.ipynb
Expand Up @@ -489,7 +489,7 @@
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.6.3"
"version": "3.6.5"
}
},
"nbformat": 4,
Expand Down
2 changes: 1 addition & 1 deletion Data_processing/Training/Visualisation.ipynb
Expand Up @@ -305,7 +305,7 @@
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.6.3"
"version": "3.6.5"
}
},
"nbformat": 4,
Expand Down
Binary file added Data_processing/Training/model_bigrace_opti_5.h5
Binary file not shown.
Binary file added Data_processing/Training/model_lille.h5
Binary file not shown.
Binary file added Data_processing/Training/model_lille_3.h5
Binary file not shown.
13 changes: 13 additions & 0 deletions README.md
Expand Up @@ -52,10 +52,17 @@ pip install -r requirement.txt

## Collect Data (manual drive + take images/labels) (RPi) :

With Xbox Gamepad
```
cd Data_processing
sudo python Auto_datamining_pad.py 0.1
```

Or with a Keyboard
```
python Auto_datamining_key.py 0.1
```

to take one picture every 0.1 sec (to just control without taking pictures, don't specify any value)

If you don't have Xbox Gamepad, you can use the computer keyboard
Expand Down Expand Up @@ -102,3 +109,9 @@ jupyter notebook
cd Patate
python patateScript5_threaded.py [myModel.h5]
```

## Rpi CLI / Desktop
```
sudo raspi-config
```
-> boot option -> Desktop / CLI = Destop autologin
Binary file added model_lille_3.h5
Binary file not shown.
77 changes: 77 additions & 0 deletions patateScript3_threaded.py
@@ -0,0 +1,77 @@
from pivideostream import PiVideoStream
from keras.models import load_model
import Adafruit_PCA9685
from const import *
import numpy as np
import sys
import time

#Load model
model = load_model(sys.argv[1])
print("Model loaded")

# Init engines
speed = SPEED_FAST
direction = DIR_C
pwm = Adafruit_PCA9685.PCA9685()
pwm.set_pwm_freq(50)

# created a *threaded *video stream, allow the camera sensor to warmup
vs = PiVideoStream().start()
time.sleep(2.0)

from PIL import Image
frame = vs.read()
img = Image.fromarray(frame)
img.save("test.png")


# Starting loop
print("Ready ! press CTRL+C to START/STOP :")
try:
while True:
pass
except KeyboardInterrupt:
pass

# Handle START/STOP event
try:
head = H_UP
# loop over some frames...this time using the threaded stream
while True:
# grab the frame from the threaded video stream
frame = vs.read()
image = np.array([frame]) / 255.0
## # Model prediction
preds_raw = model.predict(image)
preds = [np.argmax(pred, axis=1) for pred in preds_raw]
## # Action
if preds[1] == 0:
speed = SPEED_NORMAL
direction = DIR_L
elif preds[1] == 1:
if preds[0] == 1:
if speed == SPEED_FAST:
head = H_UP
speed = SPEED_FAST
else:
speed = SPEED_NORMAL
direction = DIR_C
elif preds[1] == 2:
speed = SPEED_NORMAL
direction = DIR_R
## # Apply values to engines
pwm.set_pwm(0, 0, direction)
pwm.set_pwm(1, 0, speed)
## # Move Head
pwm.set_pwm(2, 0, head)

except:
pass

# Stop the machine
pwm.set_pwm(0, 0, 0)
pwm.set_pwm(1, 0, 0)
pwm.set_pwm(2, 0, 0)
vs.stop()
print("Stop")

0 comments on commit e8ffcbe

Please sign in to comment.