Skip to content

Commit 24c6411

Browse files
authored
Merge pull request #1 from itheima1/master
update
2 parents 3f23eb4 + c09a11b commit 24c6411

File tree

89 files changed

+18406
-0
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

89 files changed

+18406
-0
lines changed

README.md

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1 +1,35 @@
11
# 黑马无人小车
2+
3+
## 控制概述
4+
5+
链接:https://pan.baidu.com/s/1kMnXZxpTx9mRfPxv4du62Q 提取码:czxy
6+
7+
## 坐标系变换
8+
9+
链接:https://pan.baidu.com/s/1KCho6WGNhHTUwhCPjbpXXg 提取码:czxy
10+
11+
## Numpy&Matplotlib
12+
13+
链接:https://pan.baidu.com/s/1CjONSUECSHgMplu8qvUkYg 提取码:czxy
14+
15+
## ORB_SLAM2
16+
17+
### 课堂源码
18+
19+
ORB-SLAM2(官方修订版):https://gitee.com/tangyang/ORB_SLAM2
20+
21+
Astra相机ROS驱动(官方修订版):https://gitee.com/tangyang/ros_astra_camera
22+
23+
点云文件转OctoMap(ROS版):https://gitee.com/tangyang/pointcloud_publisher
24+
25+
点云和OctoMap生成器(ROS版):https://gitee.com/tangyang/pointcloud_mapping
26+
27+
16bit-8bit图片转换(ROS版):https://gitee.com/tangyang/image_transformer
28+
29+
### 相关资料
30+
31+
链接:https://pan.baidu.com/s/188tvRHuorwjqkTIsDXUBDQ 提取码:45jk
32+
33+
## 相机标定&内外参
34+
35+
链接:https://pan.baidu.com/s/16Y50ax14MpFgpSgWZzuu6Q 提取码:czxy

ai/day06_auto_drive/.ipynb_checkpoints/01_自动驾驶-checkpoint.ipynb

Lines changed: 764 additions & 0 deletions
Large diffs are not rendered by default.
Lines changed: 185 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,185 @@
1+
{
2+
"cells": [
3+
{
4+
"cell_type": "code",
5+
"execution_count": null,
6+
"metadata": {},
7+
"outputs": [],
8+
"source": [
9+
"#安装python开发web程序的依赖\n",
10+
"!conda install flask"
11+
]
12+
},
13+
{
14+
"cell_type": "code",
15+
"execution_count": null,
16+
"metadata": {},
17+
"outputs": [],
18+
"source": [
19+
"from flask import Flask\n",
20+
"# 创建一个网页\n",
21+
"app = Flask(__name__)\n",
22+
"\n",
23+
"@app.route(\"/aaaa\")\n",
24+
"def gaga():\n",
25+
" return '<h1>静夜思</h1> <h2 style=\"color:blue\" >床前明月光</h2> <h2>疑是地上霜</h2>'\n",
26+
"\n",
27+
"@app.route(\"/bbbb\")\n",
28+
"def haha():\n",
29+
" return \"haha\"\n",
30+
"\n",
31+
"if __name__ == '__main__':\n",
32+
" app.run(port=80)"
33+
]
34+
},
35+
{
36+
"cell_type": "markdown",
37+
"metadata": {},
38+
"source": [
39+
"## websoket "
40+
]
41+
},
42+
{
43+
"cell_type": "code",
44+
"execution_count": null,
45+
"metadata": {},
46+
"outputs": [],
47+
"source": [
48+
"## socketio eventlet socket通讯需要的依赖\n",
49+
"## conda install -c conda-forge python-socketio\n",
50+
"## conda install -c conda-forge eventlet"
51+
]
52+
},
53+
{
54+
"cell_type": "code",
55+
"execution_count": null,
56+
"metadata": {},
57+
"outputs": [],
58+
"source": [
59+
"import eventlet\n",
60+
"import socketio\n",
61+
"from flask import Flask\n",
62+
"\n",
63+
"sio = socketio.Server() ## 创建socketio的服务器\n",
64+
"app = Flask(__name__)\n",
65+
"\n",
66+
"@sio.on('connect')\n",
67+
"def connect(sid,env):\n",
68+
" print(\"websocket链接建立了\")\n",
69+
" sio.emit(\"steer\",data={\n",
70+
" 'steering_angle':'0',\n",
71+
" 'throttle':'1'\n",
72+
" })\n",
73+
"\n",
74+
"if __name__=='__main__':\n",
75+
" # 把web服务器和socketio绑定在一起。\n",
76+
" app = socketio.Middleware(sio,app)\n",
77+
" ## 监听socket的事件了\n",
78+
" eventlet.wsgi.server(eventlet.listen(('',4567)),app)\n"
79+
]
80+
},
81+
{
82+
"cell_type": "code",
83+
"execution_count": null,
84+
"metadata": {},
85+
"outputs": [],
86+
"source": [
87+
"## 包装方法\n",
88+
"## 图片预处理的逻辑,接受参数图片的路径\n",
89+
"def img_preprocess(src_image):\n",
90+
" \n",
91+
" img = src_image[60:135,:,:]\n",
92+
" img = cv2.GaussianBlur(img,(3,3),1)\n",
93+
" img = cv2.resize(img,(200,66))\n",
94+
" img = cv2.cvtColor(img,cv2.COLOR_RGB2YUV)\n",
95+
" return img\n",
96+
"\n",
97+
"import tensorflow as tf\n",
98+
"save_model = tf.keras.models.load_model('hahaha.h5')\n",
99+
"## 从模拟器汽车的摄像头里面读到数据, 基于图像输入,使用cnn训练好的模型,预测方向盘的角度。\n",
100+
"\n",
101+
"import eventlet\n",
102+
"import socketio\n",
103+
"from flask import Flask\n",
104+
"from io import BytesIO\n",
105+
"from PIL import Image\n",
106+
"import cv2\n",
107+
"import base64\n",
108+
"import numpy as np\n",
109+
"\n",
110+
"sio = socketio.Server() ## 创建socketio的服务器\n",
111+
"app = Flask(__name__)\n",
112+
"\n",
113+
"speed_limit = 8\n",
114+
"\n",
115+
"@sio.on('connect')\n",
116+
"def connect(sid,env):\n",
117+
" print(\"websocket链接建立了\")\n",
118+
"# sio.emit(\"steer\",data={\n",
119+
"# 'steering_angle':'0',\n",
120+
"# 'throttle':'0.0'\n",
121+
"# })\n",
122+
"\n",
123+
"\n",
124+
"def send_control(angle,throttle):\n",
125+
" sio.emit(\"steer\",data={\n",
126+
" 'steering_angle':angle.__str__(),\n",
127+
" 'throttle':throttle.__str__()\n",
128+
" })\n",
129+
"\n",
130+
" \n",
131+
"@sio.on('telemetry')\n",
132+
"def telemetry(sid,data):\n",
133+
" image = Image.open(BytesIO(base64.b64decode(data['image'])))\n",
134+
" image = np.asarray(image)\n",
135+
" cv2.imshow(\"info\",image)\n",
136+
" cv2.waitKey(10)\n",
137+
" \n",
138+
" #预测\n",
139+
" image = img_preprocess(image)\n",
140+
" image = image / 255.0\n",
141+
" angel = save_model.predict(image.reshape(1,66,200,3))[0][0]\n",
142+
" \n",
143+
" ##当前的车速\n",
144+
" speed = float(data['speed'])\n",
145+
" throttle = 1.0 - speed / speed_limit\n",
146+
" \n",
147+
" send_control(angel,throttle)\n",
148+
" \n",
149+
"if __name__=='__main__':\n",
150+
" # 把web服务器和socketio绑定在一起。\n",
151+
" app = socketio.Middleware(sio,app)\n",
152+
" ## 监听socket的事件了\n",
153+
" eventlet.wsgi.server(eventlet.listen(('',4567)),app)\n"
154+
]
155+
},
156+
{
157+
"cell_type": "code",
158+
"execution_count": null,
159+
"metadata": {},
160+
"outputs": [],
161+
"source": []
162+
}
163+
],
164+
"metadata": {
165+
"kernelspec": {
166+
"display_name": "Python 3",
167+
"language": "python",
168+
"name": "python3"
169+
},
170+
"language_info": {
171+
"codemirror_mode": {
172+
"name": "ipython",
173+
"version": 3
174+
},
175+
"file_extension": ".py",
176+
"mimetype": "text/x-python",
177+
"name": "python",
178+
"nbconvert_exporter": "python",
179+
"pygments_lexer": "ipython3",
180+
"version": "3.7.4"
181+
}
182+
},
183+
"nbformat": 4,
184+
"nbformat_minor": 4
185+
}

0 commit comments

Comments
 (0)