一、項目名稱:汽車駕駛評分器
作者:aramy
二、項目概述:
公司有公用的維護車,每個員工開車習(xí)慣都不同,但是行車安全最重要。制作了“汽車駕駛評分器”這個項目,用來監(jiān)督記錄每次行車狀態(tài)數(shù)據(jù)。出現(xiàn)危險駕駛行為進行扣分。
項目硬件使用CoreS3。是一個M5Stack 推出的基于樂鑫 ESP32-S3 開發(fā)的 Core 系列第三代主機 CoreS3,集成了多個傳感器,其中包括這次項目使用到的加速度傳感器、SD卡和2.0寸的觸摸屏。另外添加了一個GROVE - GPS (AIR530)模塊,使用GPS+北斗來進行定位。
1、主要框架:系統(tǒng)主要分為3個部分。
第一部分,收集傳感器信息。GPS+北斗定位信息和加速度傳感器信息。
GPS+北斗定位信息,用來獲得當(dāng)前車輛的詳細(xì)位置和速度。有想過將交通地圖集成到系統(tǒng)中去,但是能力有限,沒能實現(xiàn)。定位信息結(jié)合交通地圖就能獲得不同道路的限速信息,從而實現(xiàn)對不同道路的限速評分管理,但是這個功能暫時沒有能夠?qū)崿F(xiàn)。所以對速度的評分,僅僅實現(xiàn)了最高速的扣分(當(dāng)時速超過120公里/小時則扣分)。加速度傳感器用來收集車輛加減速和轉(zhuǎn)彎時的加速度信息。設(shè)定了閾值,當(dāng)車輛加速度超過1倍重力加速度時,意味著產(chǎn)生了急加速、急減速的情況,就給與扣分。
第二部分為駕駛信息記錄部分。CoreS3能力有限,所以將行車時傳感器獲取到的數(shù)據(jù),以文件的方式保留下來。對行車數(shù)據(jù)進行收集,為以后做出駕駛行為評估模型搭建數(shù)據(jù)基礎(chǔ)。記錄文件采取每分鐘寫入一個單獨文件,保障文件不會因斷電丟失。
第三部分為UI部分。最為車載系統(tǒng),盡可能做到不干擾駕駛員的注意力。所以界面使用儀表盤方式顯示了 車速和當(dāng)前評分。經(jīng)緯度、加速度等信息輔助顯示,顏色使用較為暗淡的方式,盡量做到不干擾駕駛員的注意力。
UI界面使用了LVGL,使用了Guider工具進行UI繪制,代碼使用Arduino的C來編寫,編程工具使用的是Vscode+platformio。
2、打分。
系統(tǒng)默認(rèn)駕駛員的駕駛行為為滿分(10分)??鄯钟腥N情況。i:超速行為,當(dāng)車速超過120公里/小時開始扣分,每秒扣1分。ii:當(dāng)加速度連續(xù)2次(2秒)檢測到超過1倍重力加速度,則扣1分。iii:當(dāng)加速度超過1.5倍重力加速度,則扣1分。
// 評分標(biāo)準(zhǔn) 如果連續(xù)兩次加速度超過1 或者單次加速度超過1.5 則扣一分,速度超過120KM/小時 扣1分
static int score = 10;
static float oldacc = 0; // 上次的加速度
int judgeScore(LvglQueue lvglmsg)
{
float acc = lvglmsg.acc; // 本次加速度
if (oldacc > 1 && acc > 1)
{
score--;
}
if (acc > 1.5)
score--;
if (lvglmsg.speed > 120)
score--;
oldacc = acc;
return score;
}
復(fù)制代碼
21:56:00 :135600 ,latitude:2303.157471 ,longitude:11346.219727 ,speed:32.430000 ,acc_x:-0.067269 ,acc_y:0.942306 ,acc_z:-0.289605 ,gyro_x:2.837960 ,gyro_y:0.201862 ,gyro_z:0.255032 ,judge:10
21:56:01 :135601 ,latitude:2303.162109 ,longitude:11346.228516 ,speed:33.110001 ,acc_x:-0.044075 ,acc_y:0.968673 ,acc_z:-0.357965 ,gyro_x:-1.739677 ,gyro_y:0.323933 ,gyro_z:0.193996 ,judge:10
21:56:01 :135601 ,latitude:2303.162109 ,longitude:11346.228516 ,speed:33.110001 ,acc_x:-0.026497 ,acc_y:0.916916 ,acc_z:-0.331353 ,gyro_x:-5.706962 ,gyro_y:0.018757 ,gyro_z:-0.477390 ,judge:10
21:56:03 :135603 ,latitude:2303.171387 ,longitude:11346.246094 ,speed:32.830002 ,acc_x:-0.012581 ,acc_y:0.983566 ,acc_z:-0.275445 ,gyro_x:0.640694 ,gyro_y:-1.079876 ,gyro_z:-1.087742 ,judge:10
21:56:04 :135604 ,latitude:2303.175781 ,longitude:11346.254883 ,speed:31.780001 ,acc_x:0.005974 ,acc_y:0.970871 ,acc_z:-0.253228 ,gyro_x:1.128975 ,gyro_y:-0.408489 ,gyro_z:1.292629 ,judge:10
21:56:05 :135605 ,latitude:2303.180176 ,longitude:11346.262695 ,speed:31.000000 ,acc_x:-0.062142 ,acc_y:0.975753 ,acc_z:-0.346246 ,gyro_x:1.495186 ,gyro_y:-1.262981 ,gyro_z:0.804348 ,judge:10
21:56:06 :135606 ,latitude:2303.184082 ,longitude:11346.270508 ,speed:30.230000 ,acc_x:-0.063362 ,acc_y:0.989181 ,acc_z:-0.277154 ,gyro_x:3.692452 ,gyro_y:0.323933 ,gyro_z:-0.111179 ,judge:10
21:56:06 :135606 ,latitude:2303.184082 ,longitude:11346.270508 ,speed:30.230000 ,acc_x:-0.013069 ,acc_y:0.970871 ,acc_z:-0.305719 ,gyro_x:1.190010 ,gyro_y:0.018757 ,gyro_z:0.316067 ,judge:10
21:56:08 :135608 ,latitude:2303.191895 ,longitude:11346.286133 ,speed:28.850000 ,acc_x:-0.078499 ,acc_y:0.971115 ,acc_z:-0.280084 ,gyro_x:0.701729 ,gyro_y:1.117390 ,gyro_z:1.292629 ,judge:10
21:56:09 :135609 ,latitude:2303.195557 ,longitude:11346.293945 ,speed:28.230000 ,acc_x:0.001335 ,acc_y:1.002365 ,acc_z:-0.263971 ,gyro_x:1.800362 ,gyro_y:0.018757 ,gyro_z:-4.322605 ,judge:10
21:56:09 :135609 ,latitude:2303.195557 ,longitude:11346.293945 ,speed:28.230000 ,acc_x:-0.039437 ,acc_y:0.975509 ,acc_z:-0.315240 ,gyro_x:-1.251396 ,gyro_y:2.399128 ,gyro_z:-0.172215 ,judge:10
21:56:11 :135611 ,latitude:2303.202881 ,longitude:11346.308594 ,speed:26.059999 ,acc_x:-0.098763 ,acc_y:1.006759 ,acc_z:-0.239557 ,gyro_x:2.715889 ,gyro_y:2.338093 ,gyro_z:1.353664 ,judge:10
21:56:12 :135612 ,latitude:2303.206543 ,longitude:11346.314453 ,speed:24.230000 ,acc_x:-0.039193 ,acc_y:1.008224 ,acc_z:-0.315973 ,gyro_x:3.509346 ,gyro_y:2.154987 ,gyro_z:-2.552586 ,judge:10
21:56:13 :135613 ,latitude:2303.209961 ,longitude:11346.320312 ,speed:21.879999 ,acc_x:-0.020638 ,acc_y:0.885421 ,acc_z:-0.327936 ,gyro_x:-3.387626 ,gyro_y:1.605671 ,gyro_z:3.428860 ,judge:10
21:56:13 :135613 ,latitude:2303.209961 ,longitude:11346.320312 ,speed:21.879999 ,acc_x:-0.022103 ,acc_y:0.993820 ,acc_z:-0.273004 ,gyro_x:1.251046 ,gyro_y:0.568073 ,gyro_z:-1.270847 ,judge:10
21:56:15 :135615 ,latitude:2303.216797 ,longitude:11346.331055 ,speed:19.889999 ,acc_x:-0.026497 ,acc_y:0.940597 ,acc_z:-0.340875 ,gyro_x:2.105538 ,gyro_y:-0.469524 ,gyro_z:-0.538426 ,judge:10
21:56:16 :135616 ,latitude:2303.220215 ,longitude:11346.335938 ,speed:19.600000 ,acc_x:-0.053109 ,acc_y:0.885666 ,acc_z:-0.317926 ,gyro_x:4.241768 ,gyro_y:-1.507122 ,gyro_z:-0.965672 ,judge:10
21:56:17 :135617 ,latitude:2303.223877 ,longitude:11346.339844 ,speed:20.500000 ,acc_x:-0.025765 ,acc_y:0.900558 ,acc_z:-0.334283 ,gyro_x:-0.030693 ,gyro_y:1.361530 ,gyro_z:0.682278 ,judge:10
21:56:17 :135617 ,latitude:2303.223877 ,longitude:11346.339844 ,speed:20.500000 ,acc_x:-0.050667 ,acc_y:0.939132 ,acc_z:-0.320367 ,gyro_x:2.654854 ,gyro_y:1.971882 ,gyro_z:0.071926 ,judge:10
21:56:19 :135619 ,latitude:2303.231201 ,longitude:11346.349609 ,speed:20.520000 ,acc_x:-0.071907 ,acc_y:1.071457 ,acc_z:-0.265924 ,gyro_x:4.424874 ,gyro_y:2.399128 ,gyro_z:-3.468113 ,judge:10
21:56:20 :135620 ,latitude:2303.234863 ,longitude:1134635392.000000 ,speed:20.200001 ,acc_x:-0.046273 ,acc_y:0.937179 ,acc_z:-0.272516 ,gyro_x:-3.692802 ,gyro_y:3.009480 ,gyro_z:2.696438 ,judge:10
21:56:21 :135621 ,latitude:2303.238525 ,longitude:11346.358398 ,speed:19.370001 ,acc_x:0.015739 ,acc_y:0.956955 ,acc_z:-0.295465 ,gyro_x:2.166573 ,gyro_y:-1.018841 ,gyro_z:-6.580906 ,judge:10
21:56:23 :135623 ,latitude:2303.245850 ,longitude:11346.367188 ,speed:18.020000 ,acc_x:-0.020150 ,acc_y:0.856125 ,acc_z:-0.025201 ,gyro_x:-12.359795 ,gyro_y:-0.042278 ,gyro_z:-0.355320 ,judge:10
21:56:24 :135624 ,latitude:2303.249268 ,longitude:11346.371094 ,speed:17.219999 ,acc_x:-0.098519 ,acc_y:0.955734 ,acc_z:-0.188043 ,gyro_x:-3.570732 ,gyro_y:0.812214 ,gyro_z:0.438137 ,judge:10
21:56:24 :135624 ,latitude:2303.249268 ,longitude:11346.371094 ,speed:17.219999 ,acc_x:-0.014046 ,acc_y:0.978683 ,acc_z:-0.375299 ,gyro_x:0.213448 ,gyro_y:0.934284 ,gyro_z:0.926418 ,judge:10
21:56:26 :135626 ,latitude:2303.255615 ,longitude:11346.377930 ,speed:15.250000 ,acc_x:-0.093636 ,acc_y:0.840255 ,acc_z:-0.394098 ,gyro_x:-2.655204 ,gyro_y:2.216022 ,gyro_z:1.719875 ,judge:10
21:56:26 :135626 ,latitude:2303.255615 ,longitude:11346.377930 ,speed:15.250000 ,acc_x:-0.045052 ,acc_y:0.934494 ,acc_z:-0.312066 ,gyro_x:0.823799 ,gyro_y:0.629108 ,gyro_z:1.109524 ,judge:10
21:56:28 :135628 ,latitude:2303.262207 ,longitude:11346.384766 ,speed:16.420000 ,acc_x:-0.011360 ,acc_y:0.967209 ,acc_z:-0.322076 ,gyro_x:-3.204521 ,gyro_y:1.300495 ,gyro_z:1.780910 ,judge:10
21:56:28 :135628 ,latitude:2303.262207 ,longitude:11346.384766 ,speed:16.420000 ,acc_x:-0.071907 ,acc_y:0.873947 ,acc_z:-0.384332 ,gyro_x:1.678292 ,gyro_y:1.117390 ,gyro_z:0.743313 ,judge:10
21:56:30 :135630 ,latitude:2303.268555 ,longitude:11346.391602 ,speed:16.020000 ,acc_x:-0.021859 ,acc_y:0.944015 ,acc_z:-0.362359 ,gyro_x:1.800362 ,gyro_y:0.995319 ,gyro_z:1.475735 ,judge:10
21:56:30 :135630 ,latitude:2303.268555 ,longitude:11346.391602 ,speed:16.020000 ,acc_x:-0.040413 ,acc_y:0.927414 ,acc_z:-0.408502 ,gyro_x:-0.580009 ,gyro_y:0.262897 ,gyro_z:0.377102 ,judge:10
復(fù)制代碼
三、作品實物圖
四、演示視頻
https://www.bilibili.com/video/BV13Q4y1w7Tc/
五、項目文檔
鏈接:https://pan.baidu.com/s/1-1XPUpYTo4-4l2V1egzBjA
提取碼:wsg6