乐高MINDSTORMS头脑风暴EV3机器人核心套装

搭建无人驾驶汽车

设计一辆可以实现用户驾驶指令的自动驾驶汽车

120+分钟
中级
9-12 年级
roaming-vehicles-gps

课程计划

课前准备
- 通读教师教学材料。
- 可根据教学需要使用 EV3 Lab 软件或编程 App 应用程序中的入门教学材料来设计课程。这将有助于学生熟悉乐高®教育 MINDSTORMS® 头脑风暴 EV3 机器人套装。

参与(30 分钟)
- 结合下文“发起一次讨论”部分的提示,组织学生围绕本项目展开讨论。
- 解释项目。
- 将整个班级按两人一组方式进行分组。
- 为学生预留头脑风暴的时间。

探究(30 分钟)
- 让学生创建多个原型。
- 鼓励学生探索搭建和编程。
- 让每组学生搭建并测试两种方案。

解释(60 分钟)
- 要求学生测试自己的方案,并选出最优的一个。
- 确保学生能够创建自己的测试表。
- 为每个团队留些时间来完成项目,并收集他们的工作记录材料。

拓展(60 分钟)
- 给学生一些时间,让他们完成自己的最终报告。
- 组织一次分享会,让每个团队展示他们的成果。

评估
- 为每位学生的课堂表现提供反馈。
- 可借助所提供的评价量表来简化此环节。

发起一次讨论

如今,汽车中装配了多种导航系统。其中一些系统已经取代了驾驶员,将乘客安全送往目的地。在确定 A 点和 B 点之间的最佳路线之前,自动驾驶汽车必须能够根据用户的输入执行一系列运动。

roaming-vehicles-gps

引入头脑风暴环节。
要求学生思考下列问题:

  • 什么是自动驾驶汽车,它们是如何工作的?
  • 自动驾驶汽车如何确定方向?
  • 为了让汽车沿着一系列城市街道(东、西、南、北坐标格网上)行驶,它需要做什么动作?

给学生留出回答问题的时间:

鼓励学生记录最初想法,并且解释第一原型选用此方案的原因。要求学生描述:如何在整个项目进行过程中评估自己的想法。通过这种方式,他们在审核和修改过程中将会拥有评估自身方案的具体信息,并可籍此来决定方案是否有效。

伪代码是一种很好的工具,可以帮助学生在开始编程之前组织自己的思维。

搭建要诀

从搭建车辆开始。学生可以使用任何建议的乐高®教育 MINDSTORMS® 头脑风暴 EV3 机器人驱动模块模型,或者设计自己的模型。确保可以直接触碰 EV3 程序块顶部的按钮。在这项活动中,这些按钮将被用于控制方向。

ev3-robot-driving-base

编程要诀

向学生解释:他们将对机器人进行编程,使其根据一组记录的指令进行移动,这些指令通过 EV3 程序块上的按钮输入。 请使用下列参数:

  • 按压“上按钮”,机器人向前移动 30 厘米
  • 按压“下按钮”,机器人向后移动 30 厘米
  • 按压“左按钮”,机器人向左转 90 度
  • 按压“右按钮”,机器人向右转 90 度

记录一个动作,使机器人进行移动

coding-08-01

程序说明
1.启动此程序。
2.创建一个名为 “Drive” 的变量模块。
3.等待程序块按钮被按压。
4.播放声音 “Click 2”。
5.在变量 “Drive” 中记录被按压按钮的数值。
6.等待 2 秒。
7.播放声音 “G02”。
8.读取存储在变量 “Drive” 中的数字,并将值发送至 Switch 语句。
9.数字 Switch 语句:

a.如果 Drive = 0(默认情况),则不执行任何操作。
b.如果 Drive = 1,将机器人左转弯。
c.如果 Drive = 3,将机器人右转弯。
d.如果 Drive = 4,将机器人的轮子前进 2 圈。
e.如果 Drive = 5,将机器人的轮子后退 2 圈。

10.播放声音 “Game Over 2”。

记录多个动作,使机器人进行移动

“数组运算模块”可用于存储一系列数据,通常被描述为由具有“一行多列”结构的表格。

coding-08-02

方案说明

1.启动此程序。
2.创建一个名为 “Drive” 的变量模块。 选择 “WriteNumeric Array” 选项。
3.创建循环。 示例程序被设置为运行 5 次。
4.等待程序块按钮被按压。
5.播放声音 “Click”。
6.读取变量模块 “Drive”。 选择 “Read Numeric Array” 选项。
7.使用“数组运算模块”。 选择 “Write at Index - Numeric”。

a.连接至变量模块 “Drive”。
b.将循环索引从循环的前部连接至“数组运算模块”的索引位置。
c.将“等待 EV3 按钮模块”连接至“数组运算模块”的值位置。

8.将“数组运算模块”的输出写入变量模块 “Drive”。
9.等待 2 秒。
10.播放声音 “Go”。
11.创建第二个循环。示例程序被设置为运行 5 次,与第一个循环的次数相同。
12.读取变量模块 “Drive”。 选择 “Read Numeric Array” 选项。
13.使用“数组运算模块”。选择 “Read at Index - Numeric” 选项。
14.数字 Switch 语句:

a.如果 Drive = 0(默认情况),则不执行任何操作。
b.如果 Drive = 1,将机器人左转弯。
c.如果 Drive = 3,将机器人右转弯。
d.如果 Drive = 4,将机器人的轮子前进 2 圈。
e.如果 Drive = 5,将机器人的轮子后退 2 圈。

15.播放声音 “Game Over 2”。

下载示例程序 32 KB,需要用到 EV3 Lab 软件

选项标签 “1” 和 “2”

EV3 MicroPython 程序方案

记录一个动作,使机器人进行移动

#!/usr/bin/env pybricks-micropython

from pybricks import ev3brick as brick
from pybricks.ev3devices import Motor
from pybricks.parameters import Port, Stop, Button, SoundFile
from pybricks.tools import wait
from pybricks.robotics import DriveBase

# The Left, Right, Up, and Down Buttons are used to command the robot.
COMMAND_BUTTONS = (Button.LEFT, Button.RIGHT, Button.UP, Button.DOWN)

# Configure 2 motors with default settings on Ports B and C.  These
# will be the left and right motors of the Driving Base.
left_motor = Motor(Port.B)
right_motor = Motor(Port.C)

# The wheel diameter of the Robot Educator Driving Base is 56 mm.
wheel_diameter = 56

# The axle track is the distance between the centers of each of the
# wheels.  This is 118 mm for the Robot Educator Driving Base.
axle_track = 118

# The Driving Base is comprised of 2 motors.  There is a wheel on each
# motor.  The wheel diameter and axle track values are used to make the
# motors move at the correct speed when you give a drive command.
robot = DriveBase(left_motor, right_motor, wheel_diameter, axle_track)

# Wait until one of the command buttons is pressed.
while not any(b in brick.buttons() for b in COMMAND_BUTTONS):
    wait(10)

# Store the pressed button as the drive command.
drive_command = brick.buttons()[0]
brick.sound.file(SoundFile.CLICK)

# Wait 2 seconds and then play a sound to indicate that the robot is
# about to drive.
wait(2000)
brick.sound.file(SoundFile.GO)
wait(1000)

# Now drive the robot using the drive command.  Depending on which
# button was pressed, drive in a different way.

# The robot turns 90 degrees to the left.
if drive_command == Button.LEFT:
    robot.drive_time(100, -90, 1000) 

# The robot turns 90 degrees to the right.
elif drive_command == Button.RIGHT:
    robot.drive_time(100, 90, 1000)

# The robot drives straight forward 30 cm.
elif drive_command == Button.UP:
    robot.drive_time(100, 0, 3000) 
    
# The robot drives straight backward 30 cm.
elif drive_command == Button.DOWN:
    robot.drive_time(-100, 0, 3000)

# Play a sound to indicate that it is finished.
brick.sound.file(SoundFile.GAME_OVER)
wait(2000)

记录多个动作,使机器人进行移动

#!/usr/bin/env pybricks-micropython

from pybricks import ev3brick as brick
from pybricks.ev3devices import Motor
from pybricks.parameters import Port, Stop, Button, SoundFile
from pybricks.tools import wait
from pybricks.robotics import DriveBase

# The Left, Right, Up, and Down Buttons are used to command the robot.
COMMAND_BUTTONS = (Button.LEFT, Button.RIGHT, Button.UP, Button.DOWN)

# Configure 2 motors with default settings on Ports B and C.  These
# will be the left and right motors of the Driving Base.
left_motor = Motor(Port.B)
right_motor = Motor(Port.C)

# The wheel diameter of the Robot Educator Driving Base is 56 mm.
wheel_diameter = 56

# The axle track is the distance between the centers of each of the
# wheels.  This is 118 mm for the Robot Educator Driving Base.
axle_track = 118

# The Driving Base is comprised of 2 motors.  There is a wheel on each
# motor.  The wheel diameter and axle track values are used to make the
# motors move at the correct speed when you give a drive command.
robot = DriveBase(left_motor, right_motor, wheel_diameter, axle_track)

# Pressing a button stores the command in a list.  The list is empty to
# start.  It will grow as commands are added to it.
drive_command_list = []

# This loop records the commands in the list.  It repeats until 5
# buttons have been pressed.  This is done by repeating the loop while
# the list contains less than 5 commands. 
while len(drive_command_list) < 5:
    # Wait until one of the command buttons is pressed.
    while not any(b in brick.buttons() for b in COMMAND_BUTTONS):
        wait(10)
    
    # Add the pressed button to the command list.
    drive_command_list.append(brick.buttons()[0])
    brick.sound.file(SoundFile.CLICK)

    # To avoid registering the same command again, wait until the Brick
    # Button is released before continuing.
    while any(brick.buttons()):
        wait(10)

# Wait 2 seconds and then play a sound to indicate that the robot is
# about to drive.
wait(2000)
brick.sound.file(SoundFile.GO)
wait(1000)

# Now drive the robot using the list of stored commands.  This is done
# by going over each command in the list in a loop.
for drive_command in drive_command_list:
    # The robot turns 90 degrees to the left.
    if drive_command == Button.LEFT:
        robot.drive_time(100, -90, 1000) 

    # The robot turns 90 degrees to the right.
    elif drive_command == Button.RIGHT:
        robot.drive_time(100, 90, 1000)

    # The robot drives straight forward 30 cm.
    elif drive_command == Button.UP:
        robot.drive_time(100, 0, 3000) 
        
    # The robot drives straight backward 30 cm.
    elif drive_command == Button.DOWN:
        robot.drive_time(-100, 0, 3000)

# Play a sound to indicate that it is finished.
brick.sound.file(SoundFile.GAME_OVER)
wait(2000)

拓展

语言艺术拓展

选项 1
探索基于文本的编程方式:

  • 让学生探索基于文本的编程方式,以便他们比较不同的编程语言。

选项 2
在本节课中,学生创建了一辆根据数组中的指令运行的无人驾驶汽车。如果未来的无人驾驶汽车能够覆盖人类驾驶员的指令,该怎么办?
为了引入语言艺术能力培养环节,让学生:

  • 写一篇支持以下论点的议论文:无人驾驶汽车不应不顾乘客的意见而自主控制速度
  • 收集支持该论点的具体证据,并列举可能令乘客处于不利地位的情景实例
  • 确保提出反驳论点:由无人驾驶汽车自动控制车速可能是提高驾驶员或交通安全的有效策略

数学拓展

在本节课中,学生为无人驾驶汽车创建了一个逐向 (turn-by-turn) 指令序列。借助传感器和机器学习,无人驾驶汽车可以遵循指令,并根据新状况修改这些指令的执行。
为了提高数学技能,并探索机器学习在无人驾驶汽车中的应用,请为学生设定一定转弯数所需的“预算”。然后要求他们:

  • 创建一个网格来代表城市街道(例如,5 条东西走向的街道和 5 条南北走向的街道)
  • 选择起点和目的地 · 请记住,转弯最少的路径为最佳路径,分析起点和目的地之间的三个交点
  • 确定车辆从随机方向以“低于预算”的方式到达目的地的概率

评估环节

教师观察清单
可根据教学需要设定等级,例如:
1.部分完成
2.全部完成
3.超额完成

请使用下列成功完成任务的标准来评估学生的进度:

  • 学生能够识别问题的关键要素。
  • 学生能够自主开发出可行且富有创意的方案。
  • 学生能够清楚地交流他们的想法。

自我评估
当学生收集到所需的性能数据后,给他们一些时间反思自己的方案。通过提出如下问题来帮助他们:

  • 你们的方案是否符合“设计任务”的标准?
  • 你们的机器人运动的能够更精准些吗?
  • 其他人解决这个问题时采用了哪些方法?

要求学生进行头脑风暴,并记录两种能够改进他们方案的方法。

同伴反馈
推动学生进行同伴审核,由每个小组负责评价自己及其他小组的项目。此审核过程能够培养学生提供建设性反馈的能力,提升他们的分析能力和使用客观数据支持论点的能力。

职业连接

喜欢这节课的学生可能会对以下相关行业产生兴趣:

  • 商业与金融(创业学)
  • 制造与工程(工程预科)

教师支持

学生将会:
运用设计流程解决实际问题

www.moe.gov.cn/srcsite/A26/s8001/201801/t20180115_324647.html
高中信息技术课程标准

开源硬件项目设计模块

6.3 基于事物特征的分析,设计基于开源硬件的作品开发方案,描述作品各组成部分及其功能作用,明确各组成部分之间的调用关系。
6.4 根据设计方案,选择恰当的开源硬件,搜索相关的使用说明资料,审查与优化作品设计方案。
6.5 了解作品制作过程中各种设备与组件的安全使用规则和方法,根据设计方案,利用开源硬件、相关组件与材料,完成作品制作。
6.6 根据设计方案,利用开源硬件的设计工具或编程语言,实现作品的各种功能模块。
6.7 根据设计方案,测试、运行作品的数据采集、运算处理、数据输出、调控执行等各项功能,优化设计方案。

学生材料

学生学习单

下载以查看和分享学生学习单