hamuchiwa / AutoRCCar

OpenCV Python Neural Network Autonomous RC Car
BSD 2-Clause "Simplified" License
3.34k stars 1.47k forks source link

Some question about the speed of car #5

Open r290085 opened 8 years ago

r290085 commented 8 years ago

請問作者 你有調整遙控車的速度嗎? 我目前在做training 可是車子速度太快 一直駛出白紙跑道 無法training完成 我想把車子速度調慢 有什麼方法嗎?

aha124226675 commented 7 years ago

但在您的介绍中,红绿灯正样本我看是彩色的耶。

另外请问作者的train/test split是采多少比例? 谢谢

hamuchiwa commented 7 years ago

@aha124226675 恩。。。上传的时候传了彩色的。。。我记得训练的时候先转成灰阶的,haar features是基于灰阶图像,最后生成的vec文件也是灰阶的 我大体看了一下opencv的文档,没看到明确说样本必须是灰阶,说不定直接读取彩色也可以,opencv在训练前先自动转成灰阶的

我是7:3分,如果你想更进一步的话,建议直接使用k-folds cross validation

aha124226675 commented 7 years ago

@hamuchiwa 了解!感谢作者。 1.敢问当初作者正样本大小都是一样的吗?我看教学中裁减大小似乎都不一。输出才统一为25*25吧, 2.另外想请问一下作者使用点亮的红灯&绿灯当样本有什么特别用意吗?

pkletsko commented 7 years ago

Hi @hamuchiwa and @aha124226675, I have a speed problem , and have no idea how to overcome it , I have translated that you are talking about implement (add car potentiometer) , Can you explain what should I do. Maybe some pictures and schema if you can. Thanks a lot.

hamuchiwa commented 7 years ago

@aha124226675 输出的时候会resize一下,我当时用的是一样的图片,我是觉得既然都要自己拍图片了就不如一开始就保持大小一致,你说呢 红绿灯当时真没多想,其实我连黄灯也拍了。你想的比我周到,说不定真的不需要考虑灯的因素

hamuchiwa commented 7 years ago

@pkletsko You can add a potentiometer in between the power and motor on your rc car, just like the way of adding a resistor.

pkletsko commented 7 years ago

@hamuchiwa I did a quick test and seems like it works , Have to put all parts of the car together , because now it barely looks like a car :)

pkletsko commented 7 years ago

I works not well with potentiometer B50K - this is the one I have so far. Can you check/recall which type of potentiometer do you use for the project? Thanks a lot.

hamuchiwa commented 7 years ago

@pkletsko Sorry, I don't have that anymore. My car had been disassembled a long time ago. 50K may be too large, a pot basically is a adjustable resistor, if you have resistors on your disposal, you could try out different combinations see which one works best.

pkletsko commented 7 years ago

@hamuchiwa got it , I also think that it is to large, so I ordered smaller , but have to wait for delivery. Did you create a new car project after that one ?

aha124226675 commented 7 years ago

作者您好: 这几天我尝试改了隐藏层的节点个数, 比较了 64 32 16 发现还是32个准确率较高。

另外我改变过跑道来实际测试我的model发现效果还不错,虽然在Test accuracy: 58.33% 很低,但是效果不错呢!以下为测试影片 另外想请问一下,能否计算出从图片传送到PC处理到发送指令给arduino之间的延迟大概是几秒呢?

hamuchiwa commented 7 years ago

@pkletsko Not really, I freed raspberry pi for some other stuff.

hamuchiwa commented 7 years ago

@aha124226675  真的很不错,效果很好。可以算一下server接到当前包和下一个包的时间间隔,累计100个值或者更多1000个值,最后求平均数,这样大概就是传送图片的时间。到arduino的延迟我估计会非常非常的小,你算算看看吧,说不定结果意料之外呢。

aha124226675 commented 7 years ago

恩,请问作者 能算出接受到图片后,到实际Arduino下指令前这段过程的时间吗? 转成灰阶跟numpy输入model到預測应该也占用不少时间吧。

hamuchiwa commented 7 years ago

@aha124226675 可以呀,用python里面的time.time()就行 ,设一个开始再设一个结束,最后算一下差。每秒大概传过来10至15张图片的样子,每张图片的处理时间应该不会太长。

kxrf97 commented 5 years ago

@hamuchiwa

(self-rccar) D:\rccar\computer>python model_training.py Loading training data... Image array shape: (85, 38400) Label array shape: (85, 4) Loading data duration: 0.08s Training ... Training duration: 35.47s Train accuracy: 98.31% Validation accuracy: 100.00% Model saved to: 'saved_model/nn_model.xml'

(self-rccar) D:\rccar\computer>

这是我训练直路的准确度, 这样对吗? 为什么我run 了 rc_driver.py + stream_client.py + ultrasonic_client.py 可是我的 ultrasonic sensor 接近到物体时他 停了 又forward leh..... 这是什么问题。。。 明明还有东西挡在前面

kxrf97 commented 5 years ago

2.0 Stop, obstacle in front Forward Forward Forward Forward Forward Forward Forward 1.4 Stop, obstacle in front Forward Forward Forward Forward Forward 2.0 Stop, obstacle in front Forward Forward Forward Forward 1.4 2.0 Stop, obstacle in front Forward

Exception happened during processing of request from ('192.168.1.17', 46446) Traceback (most recent call last): File "D:\Miniconda3\envs\self-rccar\lib\socketserver.py", line 316, in _handle_request_noblock self.process_request(request, client_address) File "D:\Miniconda3\envs\self-rccar\lib\socketserver.py", line 347, in process_request self.finish_request(request, client_address) File "D:\Miniconda3\envs\self-rccar\lib\socketserver.py", line 360, in finish_request self.RequestHandlerClass(request, client_address, self) File "D:\Miniconda3\envs\self-rccar\lib\socketserver.py", line 720, in init self.handle() File "rc_driver.py", line 24, in handle sensor_data = round(float(self.data), 1) ValueError: could not convert string to float: b'1.95448398592.5759935379'

hamuchiwa commented 5 years ago

@kxrf97 训练没什么问题。至于sensor,一个是测量本身就有误差,用在raspberry pi上误差更大,再一个可能是rc_driver.py里的SensorDataHandler多少写的有点儿问题,你先试试把client的发送频率增加一下看看,改一下ultrasonic_client.py第53行,时间间隔设置的短一点儿。

kxrf97 commented 5 years ago

@hamuchiwa 我训练有很高的准确率,可是我的车一上路就出线了。。。。。看了这个人的方法,同一个轨道训练了15次。。。待会会试下这个方法。。。有什么可以指点吗。你说用整张图片来做训练,可是在新的code我找不到哪里可以改我的array size 了。| stream_client 和 stream_client_fast 有什么分别。 image

kxrf97 commented 5 years ago

我只想要我的车可以在同一个轨道上行走就好了

hamuchiwa commented 5 years ago

@kxrf97 反正你用的是同一个轨道,全部数据都用来训练也可以。还有是不是车速太快的原因,毕竟图像传输有延时,车速降下来帮助会很大。 array size有三个地方要改一下,collect_training_data.py里面72行,收集整张图像;然后model_training.py第五行对应的input size改一下;最后跑的时候rc_driver.py第94行也改成整张图像大小。 那两个stream client是从picamera文档搬过来的,延时差别不大的话用stream_client.py就可以了。