# 驴车

**驴车**（Donkey Car）是一个开源、采用MIT许可证的DIY平台，用于搭建小型自动驾驶遥控车：一套运行在[树莓派](https://www.edgepedia.org/zh/raspberry-pi)上的Python软件栈读取前置摄像头画面，由人类驾驶员训练出的神经网络输出转向和油门指令。<sup>[1](https://qconsf.com/sf2017/system/files/presentation-slides/q-con_donkeycar_presentation.pdf)</sup> 最小硬件成本约250美元，组装耗时两小时，<sup>[2](https://arxiv.org/html/2008.00715v2)</sup> 其深度学习自动驾驶采用行为克隆——卷积神经网络通过模仿录制好的人类驾驶数据来学习开车。<sup>[3](https://docs.donkeycar.com/guide/train_autopilot/)</sup>

| 关键事实 | 详情 |
|---|---|
| 是什么 | 基于树莓派的开源（MIT）Python项目，使用Keras/TensorFlow和OpenCV，通过端到端神经网络让遥控车自动驾驶<sup>[1](https://qconsf.com/sf2017/system/files/presentation-slides/q-con_donkeycar_presentation.pdf)</sup> |
| 成本与组装时间 | 最小硬件约250美元，组装两小时<sup>[2](https://arxiv.org/html/2008.00715v2)</sup>；2023年一项教学研究将整车定价为约325美元<sup>[4](https://doi.org/10.3390/electronics12081874)</sup> |
| 自动驾驶方法 | 深度学习行为克隆：单个前置摄像头、一个CNN，以及人类驾驶时每秒记录20次的训练数据<sup>[3](https://docs.donkeycar.com/guide/train_autopilot/)</sup> |
| 数据集规模 | 大约跑20圈可收集1万至5万条记录<sup>[1](https://qconsf.com/sf2017/system/files/presentation-slides/q-con_donkeycar_presentation.pdf)</sup> |
| 双机分工 | 树莓派在车上以连续循环方式驱动车辆；训练在独立的GPU机器或云实例上运行<sup>[2](https://arxiv.org/html/2008.00715v2)</sup><sup> • </sup><sup>[5](https://aws.amazon.com/blogs/machine-learning/build-an-autonomous-vehicle-on-aws-and-race-it-at-the-reinvent-robocar-rally/)</sup> |
| 已知局限 | 深度学习自动驾驶依赖光照条件，在光照可控的室内赛道上效果最佳<sup>[3](https://docs.donkeycar.com/guide/train_autopilot/)</sup> |
| 当前状态 | 5.4.0版本新增树莓派Zero支持、GPS+IMU融合以及Keras 3；仓库约有3000颗星<sup>[6](https://github.com/autorope/donkeycar/releases)</sup> |

## 历史与社区

在2017年旧金山QCon大会上，创作者将其介绍为一辆约200美元的开源自动驾驶汽车，并展示了当时在近期DIY Robocar比赛中屡获佳绩的自动驾驶程序。<sup>[1](https://qconsf.com/sf2017/system/files/presentation-slides/q-con_donkeycar_presentation.pdf)</sup> 该项目登上《Make:》杂志后不久，据报道约有10辆驴车已组装完成并投入使用。<sup>[7](https://makezine.com/projects/build-autonomous-rc-car-raspberry-pi/)</sup>

DIY Robocars将自家车辆定位为小型低成本车辆，运行真正的自动驾驶软件——从PyTorch、[TensorFlow](https://www.edgepedia.org/zh/tensorflow)到OpenCV——以压低成本，并持续在[旧金山湾区](https://www.edgepedia.org/zh/san-francisco-bay-area)举办比赛和黑客日。<sup>[8](https://www.diyrobocars.com/)</sup> 代码仓库autorope/donkeycar用Python编写，约有3000颗星。<sup>[6](https://github.com/autorope/donkeycar/releases)</sup>

## 硬件

标准组装从一款受支持的遥控车底盘开始。文档中的零件清单将Magnet Car定价为92美元，Desert Monster、Short Course Truck和Blaze为电气上完全相同的替代款，但需要打印或购买转接件。<sup>[9](https://docs.donkeycar.com/guide/build_hardware/)</sup> 这些车使用有刷电机，文档称这使训练更容易、能较好地应对粗糙路面，并降低成本。<sup>[9](https://docs.donkeycar.com/guide/build_hardware/)</sup>

想跳过组装环节的搭建者可以选择Waveshare Piracer Pro，这是一款预组装方案，附带树莓派4。<sup>[9](https://docs.donkeycar.com/guide/build_hardware/)</sup> 文档警告不要用更便宜的零件替代：文档已经找出了能正常工作的最便宜选项，而更低价的替代品可能根本无法工作。<sup>[9](https://docs.donkeycar.com/guide/build_hardware/)</sup>

谨慎替换是可行的。一项同行评审的教学研究在驴车4.2.1软件上搭建了两个变体，使用树莓派4 B核心、直流齿轮箱电机和[L298N](https://www.edgepedia.org/zh/l298n)电机控制器，发现车辆的转向由电机和转向机构控制效果更好。<sup>[4](https://doi.org/10.3390/electronics12081874)</sup> “学会驾驶”（L2D）研究基准使用HSP 94186有刷遥控车，并加装[Intel RealSense T265](https://www.edgepedia.org/zh/intel-realsense-t265)追踪摄像头。<sup>[2](https://arxiv.org/html/2008.00715v2)</sup>

## 软件架构

donkeycar Python包以连续循环方式运行车辆。在L2D研究车上，车载树莓派4上的这个循环采集摄像头观测、运行策略网络并施加得到的控制指令。<sup>[2](https://arxiv.org/html/2008.00715v2)</sup> AWS的参考搭建遵循同样的分工：由于树莓派算力有限，训练在基于AWS Deep Learning AMI构建、以Docker容器部署的GPU版EC2实例上运行。<sup>[5](https://aws.amazon.com/blogs/machine-learning/build-an-autonomous-vehicle-on-aws-and-race-it-at-the-reinvent-robocar-rally/)</sup> 在项目最早的架构中，车辆将数据发送到托管服务器再接收回来，完整往返延迟约十分之一秒。<sup>[7](https://makezine.com/projects/build-autonomous-rc-car-raspberry-pi/)</sup>

基于Unity的模拟器让搭建者无需实体车即可训练和测试驾驶程序；由于模拟器使用Unity引擎，必须安装在x86主机PC上，而不能装在树莓派上。<sup>[10](https://custom-build-robots.com/wp-content/uploads/2021/01/20210627-Donkey-Car-E-Book-v-0-1-0-en-Ingmar-Stapel.pdf)</sup>

## 训练与自动驾驶

**行为克隆。** 深度学习自动驾驶使用单个前置摄像头和一个通过模仿训练的卷积神经网络：人类手动驾车在赛道上行驶时，驴车每秒记录20次数据，每条记录包含一张摄像头图像、一个油门值和一个转向值。<sup>[3](https://docs.donkeycar.com/guide/train_autopilot/)</sup> 创作者在QCon上的建议是跑赛道约20次，收集1万到5万条记录。<sup>[1](https://qconsf.com/sf2017/system/files/presentation-slides/q-con_donkeycar_presentation.pdf)</sup> 《Make:》的工作流程规模更小：约10分钟驾驶，超过1000张训练图像和转向角。<sup>[7](https://makezine.com/projects/build-autonomous-rc-car-raspberry-pi/)</sup>

在L2D基准的分类模型中，五个卷积层之后接两个全连接层；油门和转向值被离散化，网络在人工采集的人类驾驶数据集上以分类交叉熵损失训练。<sup>[2](https://arxiv.org/html/2008.00715v2)</sup>

**失效模式。** 自动驾驶依赖摄像头图像的光照条件。它在光照和房间细节可控的室内赛道上表现良好，但在光照多变的户外更难奏效。<sup>[3](https://docs.donkeycar.com/guide/train_autopilot/)</sup> 在塔林两条户外赛道——科普利公园的环形路径和马亚卡公园的矩形路径——进行的实地实验表明，图像裁剪的效果好坏参半：马亚卡模型在几个弯道有所改善，但整体退化。<sup>[11](https://medium.com/@donkeycar/self-driving-donkey-car-training-7b94580eb3e2)</sup>

## 竞速与活动

驴车在DIY Robocars活动中比赛，计算任务分为车载树莓派实时处理和云端或离线训练。<sup>[8](https://www.diyrobocars.com/)</sup> 早期车辆在有标线的赛道上过弯最高速度约为每小时4至6英里。<sup>[7](https://makezine.com/projects/build-autonomous-rc-car-raspberry-pi/)</sup> AWS为其re:Invent Robocar Rally搭建了基于驴车的自动驾驶车，使用遥控车、树莓派、Pi Cam和Adafruit舵机HAT，总成本不到250美元。<sup>[5](https://aws.amazon.com/blogs/machine-learning/build-an-autonomous-vehicle-on-aws-and-race-it-at-the-reinvent-robocar-rally/)</sup>

## 与JetRacer和DeepRacer的比较

驴车是通用平台，支持多种单板计算机和遥控车；而NVIDIA的JetRacer是围绕Jetson Nano构建的专用项目；JetRacer使用PyTorch和Jupyter Notebook，而驴车主要使用TensorFlow和命令行Python程序。<sup>[12](https://dmccreary.medium.com/donkeycar-vs-jetracer-a74c4d853d2a)</sup> 与AWS DeepRacer相比，成本差距更大：DeepRacer和DeepRacer Evo分别定价399美元和598美元，而驴车约325美元；DeepRacer每两小时云端训练收费3.50美元，另加存储租赁费。<sup>[4](https://doi.org/10.3390/electronics12081874)</sup> 使用模型用直流电机的更小型驴车兼容车适合教室使用，只需一块12×12英尺的赛道。<sup>[12](https://dmccreary.medium.com/donkeycar-vs-jetracer-a74c4d853d2a)</sup>

## 近期发展

项目在5.x发布系列中保持活跃维护。5.4.0版本新增了对树莓派Zero的妥善支持、一个GPS加IMU融合部件，并迁移至Python 3.12/3.13，使用uv和Keras 3，采用.keras模型格式。<sup>[6](https://github.com/autorope/donkeycar/releases)</sup>

## 搭建者的收获

该平台已被用作结构化教学工具。一个教学系统建立在驴车4.2.1之上。<sup>[4](https://doi.org/10.3390/electronics12081874)</sup> 在一个本科生AI项目中，录制了4小时驾驶数据；经过清洗和整理，保留了约20分钟的完整跑圈、18000帧，其中约2500帧用于训练最终的CNN导航模型，约2500帧用于验证——这具体说明了录制驾驶数据在数据清洗后能保留多少。<sup>[13](https://www.atu.edu/research/facultyresearchgrants/17-18/Zeng-FinalReport-SelfDrivingRCCar.pdf)</sup>

## References

1. [Donkey Car presentation slides, QCon San Francisco 2017](https://qconsf.com/sf2017/system/files/presentation-slides/q-con_donkeycar_presentation.pdf)
2. [Learning to Drive (L2D) as a Low-Cost Benchmark for Real-World Reinforcement Learning, arXiv](https://arxiv.org/html/2008.00715v2)
3. [Create an autopilot. Donkey Car documentation](https://docs.donkeycar.com/guide/train_autopilot/)
4. [The Development of an Autonomous Vehicle Training and Verification System for the Purpose of Teaching Experiments, Electronics (MDPI), 2023](https://doi.org/10.3390/electronics12081874)
5. [Build an Autonomous Vehicle on AWS and Race It at the re:Invent Robocar Rally, AWS Machine Learning Blog](https://aws.amazon.com/blogs/machine-learning/build-an-autonomous-vehicle-on-aws-and-race-it-at-the-reinvent-robocar-rally/)
6. [Releases, autorope/donkeycar, GitHub](https://github.com/autorope/donkeycar/releases)
7. [Build an Autonomous R/C Car with Raspberry Pi, Make:](https://makezine.com/projects/build-autonomous-rc-car-raspberry-pi/)
8. [DIY Robocars](https://www.diyrobocars.com/)
9. [Build a car. Donkey Car documentation](https://docs.donkeycar.com/guide/build_hardware/)
10. [Donkey Car E-Book (Ingmar Stapel, 2021)](https://custom-build-robots.com/wp-content/uploads/2021/01/20210627-Donkey-Car-E-Book-v-0-1-0-en-Ingmar-Stapel.pdf)
11. [Self-driving Donkey Car Training, Donkey Car project Medium](https://medium.com/@donkeycar/self-driving-donkey-car-training-7b94580eb3e2)
12. [DonkeyCar vs. JetRacer, Medium](https://dmccreary.medium.com/donkeycar-vs-jetracer-a74c4d853d2a)
13. [Self-driving RC Car: Development of an Intro AI Project for Undergraduate Students, ATU faculty research report](https://www.atu.edu/research/facultyresearchgrants/17-18/Zeng-FinalReport-SelfDrivingRCCar.pdf)

---
*Initially written Oct 15, 2026*

Topic: 技术与人造世界 › 工程与制造 › 机器人技术与自动化 › Robot components and hardware

Copyright 2026 Edgepedia

License: Edgepedia Community License 1.0, https://www.edgepedia.org/edgepedia/license

Source: https://www.edgepedia.org/zh/donkey-car

English original: https://www.edgepedia.org/donkey-car
