Some questions about AutoCar
Read your AutoRCCar, I was interested, but would like to ask you some questions about your host computer what operating system? I'm under my windows host computer to compile and run the wrong side of the python, you are using what python editor? I am using pycharm. Looking forward to your reply
Hi, I use Mac, Python 2.7 and PyCharm.
Hello, I used pycharm, established in ubuntu project, what is the whole file inclusion into? Then run rc_driver.py it? Test run, last seen a bunch of errors Date: Tue, 1 Mar 2016 20:06:20 -0800 From: [email protected] To: [email protected] CC: [email protected] Subject: Re: [AutoRCCar] Some questions about AutoCar (#2)
Hi, I use Mac, Python 2.7 and PyCharm.
― Reply to this email directly or view it on GitHub.
I need more info, what errors are you seeing? Are you using python 2? Does the IP address and port on raspberry pi match the ones on the server? Does the serial port match the one you assigned to the Arduino?
Thank you for sharing the code! How much training data is needed?
Hello, I recently to learn python opencv Raspberry pi programming, but that is not the initialization of the camera, can you help me write a little opencv camera collection of video and then displayed on the page samples ? / Look forward to your reply Date: Thu, 17 Mar 2016 16:05:33 -0700 From: [email protected] To: [email protected] CC: [email protected] Subject: Re: [AutoRCCar] Some questions about AutoCar (#2)
I need more info, what errors are you seeing? Are you using python 2?
Does the IP address and port on raspberry pi match the ones on the server?
Does the serial port match the one you assigned to the Arduino?
― You are receiving this because you authored the thread. Reply to this email directly or view it on GitHub
Hi, yashid: depends on your track, in my case it's about 300 images myxingchao: test files just added
Hi, I have similar setup like yours, trying to get car moving with rc_control_test.py, Flashed .ino to Arduino Uno which is connected to laptop (running Ubuntu) via USB. Replaced /dev/tty/usb411something with my correct device /dev/tty/ACM0. Python is 2.7 and pygame is also installed as well all requirements.
However, when running rc_control_test.py via command line (with sudo or w/o) nothing happens.
pi@E20:~/git/AutoRCCar/test$ sudo python rc_control_test.py [sudo] password for pi: (here I typed pwd, enter and then arrows). Following appears on terminal: ^[[A^[[B^[[C^[[D^[[A^[[B
And this after hitting ctrl-c:
^CTraceback (most recent call last):
File "rc_control_test.py", line 69, in
Wires are correctly connected, I wrote simple .ino to test and it works OK. int test = 6;
void setup()
{
pinMode(test, OUTPUT);
}
void loop()
{
digitalWrite(test, HIGH);
delay(1000);
digitalWrite(test, LOW);
delay(5);
}
Any ideas what I am missing? Thank you.
FYI: This was fixed by adding following line to rc_control_test.py: pygame.init() pygame.display.set_mode((100, 100)) <- This line added
MihaHoo: It works for me. I'm using Mac but I don't think there should be any difference. When you hit enter, the command line window should be grayed out, then the program starts to listen for key press. Just don't click the window.
Hi, Switched to El Capitan. pygame does not work with python 2.7.11 (no module found) With python3.5.1 pygame ja serial both are ok nyt rc_control_tst.py fails: (if i click terminal)
Traceback (most recent call last):
File "rc_control_test.py", line 69, in
RCTest()
File "rc_control_test.py", line 14, in init
self.steer()
File "rc_control_test.py", line 43, in steer
self.ser.write(chr(1))
File "/usr/local/lib/python3.5/site-packages/serial/serialposix.py", line 494, in write
d = to_bytes(data)
File "/usr/local/lib/python3.5/site-packages/serial/serialutil.py", line 63, in to_bytes
raise TypeError('unicode strings are not supported, please encode to
bytes: {!r}'.format(seq))
TypeError: unicode strings are not supported, please encode to bytes: '\x01'
And if I DON*T click terminal windows, instead of that for example safari, nothing happens. car does not move. Clicking python-icon on doc kills script with error above.
What was your version of OSX and python? From where you found working intructions to get pyjama working with python2? Thanks.
On 7 June 2016 at 05:26, hamuchiwa [email protected] wrote:
Mihahoo: It works for me. I'm using Mac but I don't think there should be any difference. When you hit enter, the command line window should be grayed out, then the program starts to listen for key press. Just don't click the window.
— You are receiving this because you commented. Reply to this email directly, view it on GitHub https://github.com/hamuchiwa/AutoRCCar/issues/2#issuecomment-224148584, or mute the thread https://github.com/notifications/unsubscribe/AS3EFUJIIdO-mrE1OsIJA5It9htMtLl-ks5qJNbugaJpZM4Hkx_c .
Moved back to Linux since managed to fix issues there :) See above
Hi again,
Managed to install pygame with this https://github.com/Homebrew/homebrew-python and now rc_control_test.py works just fine :)
Well, this is getting interesting.. for some reason collect_training_data.py behaves like rc_control_test.py did "^[[A^[[B^[[C^[[D^[[A^[[B" on screen. Weird thing is that rc_control_test.py works still. Tested on very same terminal window @OSX. And as side note, rc_control_test.py works on Ubuntu if GUI (X windows) is not running.. Environmental handling on scripts needs adjustment or something. I am now very pro with python
MihaHoo: have you tried using a python IDE, for example, PyCharm?
No I haven't tried, yet. Managed to tackle problems and proceeding. Should I take images for calibration with resolution 320x240 like you have done? I
MihaHoo: I used a Raspberry Pi model B+ at the time, I sort of had to compromise the resolution in order to achieve low latency video streaming. If you are using a newer model, probably you can go higher.
i am using windows 7 will i be able to do the project using windows 7 operating system?
rohanalwaysrocks: Yes. Please refer to read me for what software you need in this project. I have closed your other thread.
thanks. i have install python pyserial pygame numpy all in 32bit and my system is 64 bit i have also shouldered uo pins to the rc board now how do i send wireless data from rasp to my laptop?
do i need to install visual studio?
i have burned the rc_keyboard_control.ino to the audrino board by simply clicking upload on audrino software and i am running rc_control_test.py using pyCharm on windows. i have installed pygame and pyserial on windows and i have connected it to com13 but as soon as i run the program on pyCharm nothing happens when i press the keys
rohanalwaysrocks , have you made wiring between arduino and rc controller? Can you see led on arduino flashing according to your keypresses? My arduino flashes on board led marked "RX"
Oh, now i have same "^[[A^[[B^[[C^[[D^[[A^[[B" problem with collect_training_data.py and old trick, adding line "pygame.display.set_mode((100, 100))" does not help (maybe putting it into wrong place inside script..) Otherwise script seems to work, when starting stream_client.py on RasPI, collect_training_data.py echoes "Start collecting images" Well, it starts collecting immediately within 10 seconds it took 100 pics..I assumed that it takes pics only if vehicile is moving ie. user presses arrows on keyboard..
Added line to the beginning of script collect_training_data.py and script started to work
import pygame pygame.display.set_mode((100, 100))
yes i have made the wiring between arduino and rc controller. as per the program 6 7 10 11 pin of arduino i have shouldered to the remote control. and no the recieve led on arduino does not flash when i press arrow keys
Have you connected also GND? Minus on remote to GND on Arduino
yeah i have connected the ground. the rx led doesnt glow when i press the arrow button on keyboard
when i run the rc_control_test.py and press arrow buttons the cursor moves anywhere. it doesnt get locked in pycharm. how to solve that
Hi, ultrasonic_client.py throws error to computer where rc_driver.py runs:
Connection closed on thread 2
Exception happened during processing of request from ('192.168.0.100', 60976) Traceback (most recent call last): File "/usr/lib/python2.7/SocketServer.py", line 290, in _handle_request_noblock self.process_request(request, client_address) File "/usr/lib/python2.7/SocketServer.py", line 318, in process_request self.finish_request(request, client_address) File "/usr/lib/python2.7/SocketServer.py", line 331, in finish_request self.RequestHandlerClass(request, client_address, self) File "/usr/lib/python2.7/SocketServer.py", line 652, in init self.handle() File "rc_driver.py", line 138, in handle sensor_data = round(float(self.data), 1)
ValueError: could not convert string to float:
Right Right Right
Your data may not be what you expect -- it seems you're expecting, but not getting, floats some where. A simple solution to figuring out where this occurs would be to add a try/except or Isdigit() to a for-loop: This way you can debug. self.request.recv(1024) is not returning strings that can be converted to Floats. Please echo out the data in self.request.recv(1024)
On Thu, Jun 16, 2016 at 10:59 PM, MihaHoo [email protected] wrote:
Hi, ultrasonic_client.py throws error to computer where rc_driver.py runs: Connection closed on thread 2
Exception happened during processing of request from ('192.168.0.100', 60976) Traceback (most recent call last): File "/usr/lib/python2.7/SocketServer.py", line 290, in
_handle_request_noblock self.process_request(request, client_address) File "/usr/lib/python2.7/SocketServer.py", line 318, in process_request self.finish_request(request, client_address) File "/usr/lib/python2.7/SocketServer.py", line 331, in finish_request self.RequestHandlerClass(request, client_address, self) File "/usr/lib/python2.7/SocketServer.py", line 652, in init self.handle() File "rc_driver.py", line 138, in handle sensor_data = round(float(self.data), 1) ValueError: could not convert string to float:
Right Right Right
— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub https://github.com/hamuchiwa/AutoRCCar/issues/2#issuecomment-226687109, or mute the thread https://github.com/notifications/unsubscribe/AJLO94fybe2smTMcu89YSzhZfw6Mg76aks5qMjfagaJpZM4Hkx_c .
Green dreams sleep roughly.
Competence exceeded. Not very familiar w/ python. ultrasonic_client.py is awful. First of all, i need to run it w/ python3 to bypass this:
SyntaxError: Non-ASCII character '\xe2' in file ultrasonic_client.py.orig on line 4, but no encoding declared; see http://python.org/dev/peps/pep-0263/ for details
And lot of these "IndentationError: unindent does not match any outer indentation level" and "IndentationError: unexpected indent" which are fixed manually.
This also fixed: SyntaxError: Missing parentheses in call to 'print' by modifying line print "Distance : %.1f cm" % distance to print("Distance : %.1f cm") % distance
Quite much modified script looks like this:
from socket import *
import time
import RPi.GPIO as GPIO
# referring to the pins by GPIO numbers
GPIO.setmode(GPIO.BCM)
# define pi GPIO
GPIO_TRIGGER = 23
GPIO_ECHO = 24
GPIO.setup(GPIO_TRIGGER,GPIO.OUT)
GPIO.setup(GPIO_ECHO,GPIO.IN)
GPIO.setwarnings(False)
# create a socket and bind socket to the host
client_socket = socket(AF_INET, SOCK_STREAM)
client_socket.connect(('192.168.0.101', 8002))
def measure():
"""
measure distance
"""
GPIO.output(GPIO_TRIGGER, True)
time.sleep(0.00001)
GPIO.output(GPIO_TRIGGER, False)
start = time.time()
while GPIO.input(GPIO_ECHO)==0:
start = time.time()
while GPIO.input(GPIO_ECHO)==1:
stop = time.time()
elapsed = stop-start
distance = (elapsed * 34300)/2
print ("Distance:",distance,"cm")
#return distance
#quit()
# referring to the pins by GPIO numbers
#GPIO.setmode(GPIO.BCM)
#
## define pi GPIO
#GPIO_TRIGGER = 23
#GPIO_ECHO = 24
# output pin: Trigger
GPIO.setup(GPIO_TRIGGER,GPIO.OUT)
# input pin: Echo
GPIO.setup(GPIO_ECHO,GPIO.IN)
# initialize trigger pin to low
GPIO.output(GPIO_TRIGGER, False)
try:
while True:
distance = measure()
#print("Distance : %.1f cm") % distance
# send data to the host every 0.5 sec
client_socket.send(str(distance))
time.sleep(0.5)
finally:
client_socket.close()
GPIO.cleanup()
And gives error:
Distance: 106.38035535812378 cm Traceback (most recent call last): File "ultrasonic_client.py", line 59, inclient_socket.send(str(distance)) TypeError: 'str' does not support the buffer interface
On computer (rc_control.py) same error as mentioned previously:
Forward
Forward
Forward
Connection closed on thread 2
----------------------------------------
Exception happened during processing of request from ('192.168.0.100', 34758)
Traceback (most recent call last):
File "/usr/lib/python2.7/SocketServer.py", line 290, in _handle_request_noblock
self.process_request(request, client_address)
File "/usr/lib/python2.7/SocketServer.py", line 318, in process_request
self.finish_request(request, client_address)
File "/usr/lib/python2.7/SocketServer.py", line 331, in finish_request
self.RequestHandlerClass(request, client_address, self)
File "/usr/lib/python2.7/SocketServer.py", line 652, in __init__
self.handle()
File "rc_driver.py", line 138, in handle
sensor_data = round(float(self.data), 1)
ValueError: could not convert string to float:
----------------------------------------
Forward
Forward
Forward
Forward
Forward
Issues:;
- Loop on ultrasonic_client.py is broken
- How to do this "add a try/except or Isdigit() to a for-loop"
TypeError happens most likely because script is executed with python3 instead of python2. It is quite hard to understand how ultra-script works for others..
Modified script acts now: pi@rc:~/git/AutoRCCar/raspberryPi $ python ultratest.py
ultratest.py:11: RuntimeWarning: This channel is already in use, continuing anyway. Use GPIO.setwarnings(False) to disable warnings. GPIO.setup(GPIO_TRIGGER,GPIO.OUT) 177.980709076pi@rc:~/git/AutoRCCar/raspberryPi $
And on computer (rc_control.py):
Right
Right
Right
Connection closed on thread 2
----------------------------------------
Exception happened during processing of request from ('192.168.0.100', 35084)
Traceback (most recent call last):
File "/usr/lib/python2.7/SocketServer.py", line 290, in _handle_request_noblock
self.process_request(request, client_address)
File "/usr/lib/python2.7/SocketServer.py", line 318, in process_request
self.finish_request(request, client_address)
File "/usr/lib/python2.7/SocketServer.py", line 331, in finish_request
self.RequestHandlerClass(request, client_address, self)
File "/usr/lib/python2.7/SocketServer.py", line 652, in __init__
self.handle()
File "rc_driver.py", line 138, in handle
sensor_data = round(float(self.data), 1)
ValueError: could not convert string to float:
----------------------------------------
Connection closed on thread 2
----------------------------------------
`Right
Right
Right
Connection closed on thread 2
----------------------------------------
Exception happened during processing of request from ('192.168.0.100', 35084)
Traceback (most recent call last):
File "/usr/lib/python2.7/SocketServer.py", line 290, in _handle_request_noblock
self.process_request(request, client_address)
File "/usr/lib/python2.7/SocketServer.py", line 318, in process_request
self.finish_request(request, client_address)
File "/usr/lib/python2.7/SocketServer.py", line 331, in finish_request
self.RequestHandlerClass(request, client_address, self)
File "/usr/lib/python2.7/SocketServer.py", line 652, in __init__
self.handle()
File "rc_driver.py", line 138, in handle
sensor_data = round(float(self.data), 1)
ValueError: could not convert string to float:
----------------------------------------
Connection closed on thread 2
---------------------------------------
My modified script:
from socket import *
import time
import RPi.GPIO as GPIO
# referring to the pins by GPIO numbers
GPIO.setmode(GPIO.BCM)
# define pi GPIO
GPIO_TRIGGER = 23
GPIO_ECHO = 24
GPIO.setup(GPIO_TRIGGER,GPIO.OUT)
GPIO.setup(GPIO_ECHO,GPIO.IN)
GPIO.setwarnings(False)
# create a socket and bind socket to the host
client_socket = socket(AF_INET, SOCK_STREAM)
client_socket.connect(('192.168.0.101', 8002))
def measure():
"""
measure distance
"""
GPIO.output(GPIO_TRIGGER, True)
time.sleep(0.00001)
GPIO.output(GPIO_TRIGGER, False)
start = time.time()
while GPIO.input(GPIO_ECHO)==0:
start = time.time()
while GPIO.input(GPIO_ECHO)==1:
stop = time.time()
elapsed = stop-start
distance = (elapsed * 34300)/2
#print ("Distance:",distance,"cm")
print (distance)
#return distance
quit()
# referring to the pins by GPIO numbers
#GPIO.setmode(GPIO.BCM)
#
## define pi GPIO
#GPIO_TRIGGER = 23
#GPIO_ECHO = 24
# output pin: Trigger
GPIO.setup(GPIO_TRIGGER,GPIO.OUT)
# input pin: Echo
GPIO.setup(GPIO_ECHO,GPIO.IN)
# initialize trigger pin to low
GPIO.output(GPIO_TRIGGER, False)
try:
while True:
distance = measure()
#print("Distance : %.1f cm") % distance
# send data to the host every 0.5 sec
client_socket.send(str(distance))
time.sleep(0.5)
finally:
client_socket.close()
GPIO.cleanup()
I'm stuck with this, help would be nice to get. Thank you
MiHaHoo: Try to do what rickbeacham suggested, print it out and check the type. Make sure you are sending the number as a string, receiving as string and then convert it to float.