Overview项目概述
A six-legged (hexapod) walking robot controlled in C++ on a DE10-Nano (Intel Cyclone V SoC). The FPGA generates 18 servo PWM signals plus an ultrasonic ranging circuit, while an object-oriented control stack walks the robot with a tripod gait — and, in the capstone lab, reads a memory-mapped sonar to avoid obstacles autonomously.一个用 C++ 在 DE10-Nano(Intel Cyclone V SoC)上控制的六足步行机器人。FPGA 生成 18 路舵机 PWM 信号以及一个超声波测距电路,面向对象的控制栈以三足步态驱动机器人行走——并在结课实验中读取内存映射的声呐数据,实现自主避障。
The Robot这台机器人
The Terasic spider is a six-legged (hexapod) walking robot. Each of its six legs — right and left front, middle, and back — has three servo-driven joints (hip, knee, and ankle), for 18 servos in total. It runs on a DE10-Nano board built around an Intel Cyclone V SoC, which fuses an ARM processor running embedded Linux with FPGA fabric on a single chip.Terasic 蜘蛛是一台六足步行机器人。它的六条腿——左右各有前、中、后——每条腿都有三个由舵机驱动的关节(髋、膝、踝),共计 18 个舵机。它运行在一块基于 Intel Cyclone V SoC 的 DE10-Nano 开发板上,该芯片在单一芯片内融合了运行嵌入式 Linux 的 ARM 处理器与 FPGA 逻辑。
Hardware & FPGA硬件与 FPGA
The FPGA handles real-time signal generation while Linux runs the high-level control:FPGA 负责实时信号生成,Linux 负责高层控制:
- The FPGA fabric hosts 18 PWM generators — one per servo — so every joint angle is produced in hardware.FPGA 逻辑中实现了 18 个 PWM 发生器——每个舵机一个——因此每个关节角度都由硬件生成。
- Peripherals are memory-mapped, so C++ running under Linux on the ARM core commands the servos by writing to register addresses.外设采用内存映射,因此运行在 ARM 核 Linux 上的 C++ 只需向寄存器地址写入即可控制舵机。
- The design is compiled in Intel Quartus / Platform Designer; the bitstream is converted to a raw binary (.rbf) and loaded from the microSD card so the FPGA self-configures at boot.设计在 Intel Quartus / Platform Designer 中编译;比特流被转换为原始二进制文件(.rbf)并从 microSD 卡加载,使 FPGA 在上电时自动配置。
- For the capstone I added an ultrasonic sonar ranging circuit (a Quartus schematic) that times the trigger/echo pulse and outputs distance in centimetres, exposed to software as a 32-bit memory-mapped PIO at address 0x180.在结课实验中,我加入了一个超声波测距电路(Quartus 原理图),它对触发/回波脉冲计时并输出以厘米为单位的距离,并作为一个 32 位内存映射 PIO(地址 0x180)提供给软件。
Software Architecture (C++ OOP)软件架构(C++ 面向对象)
The control stack is layered and object-oriented:控制栈分层且面向对象:
- A Spider class coordinates six SpiderLeg objects, each owning three Motor objects (hip, knee, ankle).一个 Spider 类协调六个 SpiderLeg 对象,每个 SpiderLeg 各拥有三个 Motor 对象(髋、膝、踝)。
- An MMap / RegisterMap layer hides the raw memory-mapped FPGA registers behind clean methods.MMap / RegisterMap 层把底层的内存映射 FPGA 寄存器封装在简洁的方法之后。
- High-level motions — Init, Standup, MoveForward, MoveBackward, LeftTurn, RightTurn, and a MoveSquare closed path — are built on an alternating tripod gait (legs RF-LM-RB move together, then LF-RM-LB).高层动作——Init、Standup、MoveForward、MoveBackward、LeftTurn、RightTurn 以及走方形路径的 MoveSquare——都建立在交替三足步态之上(RF-LM-RB 三条腿一起动,然后是 LF-RM-LB)。
Lab 9 — Adding Obstacle Avoidance (the hard one)实验 9 — 加入避障(最难的一关)
Earlier labs walked the robot open-loop, with no sensing. Lab 9 closes the loop with the sonar:之前的实验都让机器人在开环下行走,没有任何感知。实验 9 用声呐闭合了控制回路:
- Opened a second /dev/mem mapping to the sonar PIO and wrote ReadRange(), which returns the forward distance in centimetres.打开第二个指向声呐 PIO 的 /dev/mem 映射,并编写了 ReadRange(),它返回前方距离(厘米)。
- Built three control modes: (1) a manual menu with live distance telemetry; (2) a "command-interception" mode that refuses any forward step when an obstacle is within 20 cm; and (3) a fully autonomous cruise mode that continuously scans and — on detecting an obstacle under 20 cm — stops, backs up, turns, and resumes.实现了三种控制模式:(1) 带实时距离遥测的手动菜单;(2) 当障碍物进入 20 cm 以内即拒绝任何前进指令的“指令拦截”模式;(3) 持续扫描的全自主巡航模式——一旦检测到 20 cm 以内的障碍物,便停车、后退、转向,然后继续前进。
- The result turns an open-loop walker into a sensor-driven robot that reacts to its environment in real time.其结果是把一个开环步行器变成了能实时对环境做出反应的传感驱动机器人。
What this project shows这个项目体现了什么
- Hardware/software co-design across the FPGA–CPU boundary on a Cyclone V SoC.在 Cyclone V SoC 上跨越 FPGA–CPU 边界的软硬件协同设计。
- Memory-mapped I/O and direct hardware access from Linux (/dev/mem, mmap).从 Linux 进行内存映射 I/O 与直接硬件访问(/dev/mem、mmap)。
- Real-time sensor polling and closed-loop control.实时传感器轮询与闭环控制。
- Embedded, object-oriented C++ and the full FPGA toolchain (Quartus, Platform Designer, .sof → .rbf).嵌入式面向对象 C++ 以及完整的 FPGA 工具链(Quartus、Platform Designer、.sof → .rbf)。