This readme file tends to teach you how to use GoPiGo's camera to record the image data and label data. And then you can use those data to train your CNN using Tensorflow. The server.py file in this repository is programmed to use your trained CNN to control your GoPiGo robot to do a simple and low level autonomous driving. Youtube video here to see an example Some path in the py files might need to be changed according to your preference.
-
create socket and listening.
-
Build the trained network using .pb file and txt file.
-
run the network and output a label with either 'w' for go front, 'a' for go left, 'd' for turn right.
-
Send the output label to the client (GoPiGo) through TCP connection.
-
Capture an image in front and save it as jpg file.
-
connect to the socket.
-
Send image to server.
-
Receive output command from server through TCP.
-
excute command to control the robot.
GoPiGo package installed
1.remote connect your GoPiGo through ssh
2.Start remote desktop control
tightvncserver
vncserver :1 -geometry 1920x1080 -depth 24
start Remote Desktop Viewer on your PC. Then login your GoPiGo.
- Open a terminal using your Remote Desktop Viewer on GoPiGo
- create a folder called
Data
, and three subfolders calleda, w, d
respectively. - run
python datacollection.py
- Control your GoPiGo to follow the "road" you've built using either white paper or other materials.
- The images will be saved in
a, w, d
folders. - Copy or scp your
Data
folder to PC or Laptop and trained them by following @petewarden Tensorflow for Poets
1.Run server.py on laptop or desktop with wifi by typing:
python server.py --model=LOCATION of YOUR .pb FILE --labels=LOCATION of YOUR .txt LABEL FILE
2.Run client.py on GoPiGo:
python client.py
3.You should be able to see your GoPiGo drive itself. The larger your training data set is, the better its performance will be. So collect as more data as you can !!!
- When you collect data, it's faster to turn the camera of the GoPiGo to the left and label the corresponding images as 'right' or 'd'. Vice versa for the 'left' or 'a'. This requires some revise of the saving folders in the datacollection.py file.