introducing lego 1 mindstorms ev3 介绍 lego mindstorms ev3

9
1 介绍 LEGO Mindstorms EV3 你是不是已经拥有了图 1-1 中这样的盒子? 1-1 LEGO Mindstorms EV3 套装,编号 31313 如果刚才那个问题的答案是“是的”,那么你已经准备好使用本书了。市面上有多种版本 LEGO Mindstorms 套装,但是我们使用的是编号为 31313 LEGO Mindstorms EV3 套装。 本章简单地概述了套装内的设备及其作用。 1.1 了解 EV3 套装:从你打开包装的那一刻开始 EV3 套装包含了各种部件。你可能已经在其他 LEGO 套装里见过其中的一部分部件,但 是即使有一些和之前版本的 LEGO Mindstorms 类似,也有一些是你绝对没有见过的。在使用 新的套装以前,了解它们是什么非常重要。核心部件包括:

Upload: others

Post on 12-Dec-2021

33 views

Category:

Documents


0 download

TRANSCRIPT

Page 1: Introducing LEGO 1 MINDSTORMS EV3 介绍 LEGO Mindstorms EV3

第 1 章

介绍 LEGO Mindstorms EV3

你是不是已经拥有了图 1-1 中这样的盒子?

1

c01.indd 11:51:53:AM 07/22/2014 Page 1

Did you get a box that looks like the one shown in Figure 1-1?

Figure 1-1: The LEGO MINDSTORMS EV3 set, item number 31313

C H A P T E R

1

Introducing LEGO MINDSTORMS EV3

图 1-1 LEGO Mindstorms EV3 套装,编号 31313

如果刚才那个问题的答案是“是的”,那么你已经准备好使用本书了。市面上有多种版本

的 LEGO Mindstorms 套装,但是我们使用的是编号为 31313 的 LEGO Mindstorms EV3 套装。

本章简单地概述了套装内的设备及其作用。

1.1 了解 EV3 套装:从你打开包装的那一刻开始

EV3 套装包含了各种部件。你可能已经在其他 LEGO 套装里见过其中的一部分部件,但

是即使有一些和之前版本的 LEGO Mindstorms 类似,也有一些是你绝对没有见过的。在使用

新的套装以前,了解它们是什么非常重要。核心部件包括:

Page 2: Introducing LEGO 1 MINDSTORMS EV3 介绍 LEGO Mindstorms EV3

2 探索 LEGO Mindstorms EV3:机器人搭建与编程实用工具及技术

❏ 与 EV3 套装一起使用的电子部件

❏ EV3 软件

❏ 科技 搭建零件一

❏ 搭建指南

❏ 试验板

通过了解各个部件,你将更高效地设计新机器人。让我们从更多细节来了解这些部件。

1.1.1 EV3 电子部件

定义机器人的最重要的特征之一就是它可以处理命令并产生动作。EV3 套装中的电子部

件使你可以搭建机器人,它们能够处理你所写的程序并做出由那些命令所定义的动作。

1. EV3 程序块

图 1-2 所示的 EV3 程序块就像机器人的大脑。

如同我们的大脑告诉我们的身体要做什么一样,

EV3 程序块命令机器人如何行动。我们的大脑和

EV3 程序块的区别在于大脑有自己的行为,而 EV3程序块只能理解你所写的程序。注意,你将需要六

节 AA 1.5V 电池(五号电池)驱动 EV3 程序块。

2. 电机

你将给图 1-3 中的 EV3 电机编程,让你的机器

人移动起来。我们说 EV3 程序块是机器人的大脑,

电机就如同机器人的肌肉。就像我们的肌肉能够完成我们身体的所有动作,电机也将带动机

器人的所有动作,比如行驶、行走、升降、旋转等。

Chapter 1 ■ Introducing LEGO MINDSTORMS EV3 3

c01.indd 11:51:53:AM 07/22/2014 Page 3

muscles. As our muscles generate all of our body movements, the motors will power all the actions of your robot such as driving, walking, lifting, spinning, and so on.

Figure 1-2: The EV3 brick

Figure 1-3: The EV3 Motors: The large motors and the medium motor

As you can see in Figure 1-3, the large and medium motors have quite dif-ferent appearances. The large motor is bigger than the medium motor, and the body size represents the strength of the motor. Also, the two motors move in different directions: The large motor’s movement is parallel with the body of the motor whereas the medium motor’s movement is perpendicular with the body of the motor, which allows you to effectively design a robot that can achieve your goal.

图 1-3 EV3 电机:大型电机和中型电机

 此类零件为科技零件,就像 LEGO 的科技套装。—译者注

Chapter 1 ■ Introducing LEGO MINDSTORMS EV3 3

c01.indd 11:51:53:AM 07/22/2014 Page 3

muscles. As our muscles generate all of our body movements, the motors will power all the actions of your robot such as driving, walking, lifting, spinning, and so on.

Figure 1-2: The EV3 brick

Figure 1-3: The EV3 Motors: The large motors and the medium motor

As you can see in Figure 1-3, the large and medium motors have quite dif-ferent appearances. The large motor is bigger than the medium motor, and the body size represents the strength of the motor. Also, the two motors move in different directions: The large motor’s movement is parallel with the body of the motor whereas the medium motor’s movement is perpendicular with the body of the motor, which allows you to effectively design a robot that can achieve your goal.

图 1-2 EV3 程序块

Page 3: Introducing LEGO 1 MINDSTORMS EV3 介绍 LEGO Mindstorms EV3

第 1 章 介绍 LEGO Mindstorms EV3 3

就像你在图 1-3 中看到的,大型和中型电机有着截然不同的外观。大型电机比中型电机

更大,它们的大小也展现了电机的力量。另外,两种电机转动的方向不同:大型电机的转动

方向平行于其机身,而中型电机的转动方向垂直于其机身。这令你可以很有效地设计能够达

到你目标的机器人。

3. 传感器

EV3 套装包含一个触动传感器、一个颜色传感器和一个红外传感器(见图 1-4)。当你搭

建本书中的项目时,你将学习如何使用这些传感器让你的机器人与外界交互。换句话说,你

的机器人将可以根据来自其环境的输入信息决定它的动作。举个例子,比如你有一个车型机

器人,那么它可以利用红外传感器探测它与前方物体的距离。基于来自传感器的数据,当机

器人越来越靠近该物体时,会发出越来越大的声音。

4 Exploring LEGO MINDSTORMS EV3

c01.indd 11:51:53:AM 07/22/2014 Page 4

Sensors

Within the EV3 set, you will fi nd a touch sensor, a color sensor, and an infrared sensor (see Figure 1-4). As you build the projects from this book, you will learn to use these sensors to make your robots interactive. In other words, your robot will be able to decide its action based on the inputs from its surroundings. For example, let’s say you have a vehicle type robot. With an infrared sensor, it can detect how far an object is in front of it. Based on the data from the sensor, the robot can play a louder sound when it gets closer to the object.

Figure 1-4: The EV3 sensors

Remote Infrared Beacon

The remote infrared beacon, or the IR beacon, is one of the cool new features of EV3 (see Figure 1-5). You can use it as a remote control for your robot, and you can program various commands for each button or combinations of buttons. In addition, you can set your robot to detect where the IR beacon is. Note that you should not use this device with the infrared sensor.

Figure 1-5: The remote infrared beacon

图 1-4 EV3 传感器

4. 远程红外信标

远程红外(IR)信标,是 EV3 很酷的新特性之一(见图 1-5)。你可以把它作为你的机器

人的遥控器,也可以为每一个按键或多个按键的组合编写不同的程序命令。另外,你可以设

置让机器人探测远程红外信标的位置。注意,你不应将这个设备和红外传感器一起使用。

4 Exploring LEGO MINDSTORMS EV3

c01.indd 11:51:53:AM 07/22/2014 Page 4

Sensors

Within the EV3 set, you will fi nd a touch sensor, a color sensor, and an infrared sensor (see Figure 1-4). As you build the projects from this book, you will learn to use these sensors to make your robots interactive. In other words, your robot will be able to decide its action based on the inputs from its surroundings. For example, let’s say you have a vehicle type robot. With an infrared sensor, it can detect how far an object is in front of it. Based on the data from the sensor, the robot can play a louder sound when it gets closer to the object.

Figure 1-4: The EV3 sensors

Remote Infrared Beacon

The remote infrared beacon, or the IR beacon, is one of the cool new features of EV3 (see Figure 1-5). You can use it as a remote control for your robot, and you can program various commands for each button or combinations of buttons. In addition, you can set your robot to detect where the IR beacon is. Note that you should not use this device with the infrared sensor.

Figure 1-5: The remote infrared beacon图 1-5 远程红外信标

5. 数据线

这个套装包含两种类型的数据线(见图 1-6):常规数据线和一条 USB 2.0 数据线。常规

Page 4: Introducing LEGO 1 MINDSTORMS EV3 介绍 LEGO Mindstorms EV3

4 探索 LEGO Mindstorms EV3:机器人搭建与编程实用工具及技术

数据线用来将电机和传感器插入 EV3 程序块中,USB 数据线用来将程序从计算机中下载到

EV3 程序块中。

Chapter 1 ■ Introducing LEGO MINDSTORMS EV3 5

c01.indd 11:51:53:AM 07/22/2014 Page 5

Cables

This set contains two types of cables (see Figure 1-6): connector cables and a USB 2.0 cable. Connector cables are for plugging the motors and sensors into the EV3 brick. The USB cable is used to download a program to the EV3 brick from your computer.

Figure 1-6: The connector cables and the USB 2.0 cable

EV3 Software

To give your EV3 robot instructions, you must use the EV3 software specifi cally designed for this set. If you are looking in the box for an installation disc, you will be looking for a while. LEGO offers its free EV3 software only as a down-load from www.LEGO.com/mindstorms. From the main page, click the Downloads link to display the page shown in Figure 1-7. Then click the Download button.

Don’t worry if you don’t have the EV3 software available when you want to test out your robot. There is an app that comes with the brick that allows you to program your robot. The program that you can create with this app will be simpler than with the EV3 software, but it is still very useful! You will see where

25cm 数据线

35cm 数据线

50cm 数据线

2.0 USB数据线

图 1-6 数据线和 USB 2.0 数据线

1.1.2 EV3 软件

为了获得 EV3 机器人的操作指南,你必须使用特别为这个套装设计的 EV3 软件。如果

你想要在包装里寻找安装光盘,那恐怕你要找一会儿了。LEGO 提供仅可以在 http://www.lego.com/mindstorms 下载的免费 EV3 软件。在这个主页上单击下载链接,会显示图 1-7 中的

页面,之后单击下载按钮。

如果你在需要测试机器人的时候没有 EV3 软件也不用担心,程序块上面的应用程序让你

可以直接给机器人编程。使用这个应用程序创建的程序会比使用 EV3 软件创建的程序简单一

些,但依然很实用!通过阅读 2.2 节,你将会知道怎样在程序块中找到这个应用程序。

我该下载哪个版本?

EV3 软件同时兼容 PC 和 Mac。如果你使用 Windows 操作系统,需要下载以下版本

之一:Windows XP(32 位);Vista(32/64 位),入门版除外;Windows 7(32/64 位);以

及 Windows 8 桌面版本,入门版除外。如果你使用 Mac 操作系统,需要下载以下版本之

一:Mac OS X 10.6、10.7 或 10.8(仅支持 Intel)。

Page 5: Introducing LEGO 1 MINDSTORMS EV3 介绍 LEGO Mindstorms EV3

第 1 章 介绍 LEGO Mindstorms EV3 56 Exploring LEGO MINDSTORMS EV3

c01.indd 11:51:53:AM 07/22/2014 Page 6

you can fi nd this app on the brick when we go over the EV3 brick interface in “Building the Auto-Driver: A Starter Vehicle.”

Figure 1-7: Downloading the EV3 software

单击

单击

图 1-7 下载 EV3 软件

下载页包括选择操作系统(Mac OS X 和 Win32)及语言选项。如果你下载的是 PC 版本

的安装文件,你将看到一个后缀为 .exe 的文件;Mac 版本的则是后缀为 .dmg 的文件。在文

件下载至计算机之后,你只需要双击文件并按照界面上弹出的指示来安装软件即可。

1.1.3 搭建部件

除电子部件外,套装内还包含了搭建机器人所需的各种零件。在投入到机器人的搭建之

前,让我们概览一下部分经常用到的主要搭建零件,并了解它们的重要特征。

Page 6: Introducing LEGO 1 MINDSTORMS EV3 介绍 LEGO Mindstorms EV3

6 探索 LEGO Mindstorms EV3:机器人搭建与编程实用工具及技术

1. 科技梁

在搭建 EV3 机器人的过程中,你将会用到科技梁 ( 见图 1-8)。官方的名字非常拗口,所

以从现在开始我们用“梁”来指代这些零件。搭建复杂的可移动机器人时这些零件是至关重

要的,而仅使用常规的 LEGO 零件是不可能完成的。

Chapter 1 ■ Introducing LEGO MINDSTORMS EV3 7

c01.indd 11:51:53:AM 07/22/2014 Page 7

WHICH VERSION DO I DOWNLOAD?

The EV3 software is compatible with both PC and Mac. If you use a Windows operating system, it should be one of the following versions: Windows XP (32-bit); Vista (32-/64-bit), excluding Starter Edition; Windows 7 (32-/64-bit); and Windows 8 desktop mode, excluding Starter Edition. If you use a Mac operation system, it should be one of the following versions: Mac OS X 10.6, 10.7, or 10.8 (Intel only).

The download page contains options for choosing the operating system (Mac OS X and Win32) and language. If you download the installation fi le for PC, you will see a fi le with a .exe extension; for Mac, it will be a .dmg fi le. After the fi le downloads to your computer, just double-click the fi le icon and follow the instructions that pop up on your screen.

TECHNIC Building Parts

Other than the electronic parts, the box contains various parts for building robots. Before jumping into building robots, let’s overview some of the main building parts that you will use often and their important features.

Studless TECHNIC Beams

When building EV3 robots, you will use studless TECHNIC beams (see Figure 1-8). The offi cial name is quite a mouthful, so from here on out we will just refer to the part as a beam. These parts are crucial for building complex, moving robots that would not be possible using standard LEGO bricks.

Figure 1-8: Various studless TECHNIC beams图 1-8 各种科技梁

2. 连接销

套装内包含许多小小的零件,其中大部分看起来就像图 1-9 中所示的这些连接销。请注

意,它们也被称为连接栓。

8 Exploring LEGO MINDSTORMS EV3

c01.indd 11:51:53:AM 07/22/2014 Page 8

Connector Pegs

The set contains many small parts, but the majority of the pieces look like the connector pegs shown in Figure 1-9. Note that they are also called connecter pins.

Figure 1-9: Different types of connector pegs

These components are called connector pegs because they allow multiple parts to snap together. Connector pegs come in different sizes with different features, but one of the important things that you need to know is how to distinguish the following: The connector peg and the connector peg with “friction.” If you look at the regular connector peg, its surface is smooth or “frictionless” (see Figure 1-10), whereas the connector peg with friction has little bumps on the surface.

Figure 1-10: Connector peg with friction versus a frictionless connector peg

If you put a connector peg on a beam, you will notice that the beam can be turned easily. However, if instead you use a connector peg with friction, it will be more diffi cult to turn the beam because the little bumps on the peg create more resistance.

图 1-9 不同类型的连接销

这些零件之所以被称为连接销是因为它们令多个部分组合在一起。连接销有不同的尺寸

和功能,但最重要的是你需要知道如何分辨连接销和带“摩擦”的连接销。如果你观察一个

常规的连接销,它的表面是光滑的或“无摩擦力”的(见图 1-10),而带摩擦连接销的表面会

有一些小突起。

如果你把一个连接销安在梁上,你会发现梁可以很轻松地转动。但是如果你换用带摩擦

的连接销,转动梁的过程会变得较为困难,因为销上面的突起会带来更多阻力。

Page 7: Introducing LEGO 1 MINDSTORMS EV3 介绍 LEGO Mindstorms EV3

第 1 章 介绍 LEGO Mindstorms EV3 7

8 Exploring LEGO MINDSTORMS EV3

c01.indd 11:51:53:AM 07/22/2014 Page 8

Connector Pegs

The set contains many small parts, but the majority of the pieces look like the connector pegs shown in Figure 1-9. Note that they are also called connecter pins.

Figure 1-9: Different types of connector pegs

These components are called connector pegs because they allow multiple parts to snap together. Connector pegs come in different sizes with different features, but one of the important things that you need to know is how to distinguish the following: The connector peg and the connector peg with “friction.” If you look at the regular connector peg, its surface is smooth or “frictionless” (see Figure 1-10), whereas the connector peg with friction has little bumps on the surface.

Figure 1-10: Connector peg with friction versus a frictionless connector peg

If you put a connector peg on a beam, you will notice that the beam can be turned easily. However, if instead you use a connector peg with friction, it will be more diffi cult to turn the beam because the little bumps on the peg create more resistance.

突起突起

带摩擦的 连接销

连接销

图 1-10 带摩擦的连接销对比无摩擦的连接销

3. 机械零件

当你设计机器人的动作时,机械零件可以令结构更有效(见图 1-11)。这些零件提供(但

不限于)带来机械优势,比如切换齿轮传动的方向、搭建传动系统、改变齿轮运动的速度等。

Chapter 1 ■ Introducing LEGO MINDSTORMS EV3 9

c01.indd 11:51:53:AM 07/22/2014 Page 9

Mechanical Pieces

When you design your robot’s movements, the mechanical pieces allow for a more effi cient construction (see Figure 1-11). These pieces provide, but are not limited to, mechanical advantages such as switching the direction of gear move-ment, building a drive train, changing the speed of gear movements, and so on.

Figure 1-11: The EV3 mechanical pieces: spur gears, double bevel gears, worm gear, cam, and so on

MAKING AN EV3 ORGANIZER

The EV3 set comes with many diff erent pieces. Based on my experience, I prefer to have all the parts organized separately as I design a robot. I can thus see what parts I have left at a glance and not lose my thought process by spending time searching for a piece. You can probably use plastic cups or small containers, but I highly recommend that you take as your EV3 organizer an organizer that is normally used for spare parts (see Figure 1-12). This way, you can keep parts organized by size or type and store everything all together. You can fi nd these organizers at any well-stocked hardware store or on the Internet.

Continues

图 1-11 EV3 机械零件:正齿轮、双锥齿轮、蜗轮、凸轮等

做一个 EV3 分类收纳盒

EV3 套装包含许多不同的零件。根据我的经验,我喜欢在设计机器人的时候把所有

零件分门别类地摆放。正因如此,我可以看一眼就马上知道还剩下哪些零件,就不会因

为找零件花费时间而中断我的思维过程了。你可以用一些塑料杯子或小容器,但我强烈

建议你采用一个通常用来存放多余零件的收纳盒作为 EV3 分类收纳盒 ( 见图 1-12)。这

样,你可以按照零件的大小或种类有条理地整理,并把所有东西收纳在一起。你可以在

任何备货充足的五金店或互联网上购买到分类收纳盒。

Page 8: Introducing LEGO 1 MINDSTORMS EV3 介绍 LEGO Mindstorms EV3

8 探索 LEGO Mindstorms EV3:机器人搭建与编程实用工具及技术10 Exploring LEGO MINDSTORMS EV3

c01.indd 11:51:53:AM 07/22/2014 Page 10

图 1-12 收纳你的 EV3 套装

1.1.4 搭建指南和试验板

除零件以外,EV3 的盒子里还包括一本搭建机器人的指南手册,以及如何使用 EV3 程序

块的简单说明(见图 1-13)。为了解释手册中的基础说明,本书提供了 EV3 程序块的深入介

绍。在包装的第一层,你会发现一张试验板(见图 1-13)。你将会使用这张板子测试本书中

的机器人。

10 Exploring LEGO MINDSTORMS EV3

c01.indd 11:51:53:AM 07/22/2014 Page 10

搭建指南手册

试验板

图 1-13 搭建指南手册和试验板

Page 9: Introducing LEGO 1 MINDSTORMS EV3 介绍 LEGO Mindstorms EV3

第 1 章 介绍 LEGO Mindstorms EV3 9

1.2 比较 EV3 和 NXT

NXT 是 LEGO Mindstorms 系列的早期版本。如果你使用 NXT 还拥有 EV3,你也许想

知道若将这两个套装比较会如何。总的来说,EV3 的性能优于 NXT 的性能。程序块的能力

方面,从数据处理、所含传感器的准确性以及电子部件的改良设计这几个方面来讲,EV3 都

是更好的机器人套装。NXT 和 EV3 的电机是互相兼容的,无论在哪一个套装里都可以很好

地工作。然而,EV3 的传感器与 NXT 是不兼容的,而 EV3 可以使用 NXT 套装中的传感器。

仅需要注意,EV3 使用 NXT 的光电传感器会相当不稳定。EV3 的免费软件是供 Mindstorms使用的非常强大的控制软件,NXT 同样也可以使用(见图 1-14)。

Chapter 1 ■ Introducing LEGO MINDSTORMS EV3 11

c01.indd 11:51:53:AM 07/22/2014 Page 11

Comparing EV3 and NXT

NXT is the previous version of the LEGO MINDSTORMS set. If you use an NXT and also have an EV3, you may wonder how these two versions are comparable. In general, the EV3 equipment performs better than the NXT equipment. In terms of the brick’s ability to process data, the accuracy of the included sensors, and the improved design of the electronic parts, EV3 makes for a better robot. NXT and EV3 motors are cross-compatible and work fi ne for either set. EV3 sensors, however, are not compatible with NXT, although EV3 can use sensors from the NXT set. Just note that using the NXT light sensor with EV3 can be quite unstable. EV3’s free software is very powerful control software available for MINDSTORMS and will work with NXT (see Figure 1-14).

Figure 1-14: Compatibility chart for EV3 and NXT elements

Summary

In this chapter, you learned about the following:

■ The electronic components of EV3

■ The EV3 software download and installation process

■ Characteristics of the principal building parts

■ Compatibility between NXT and EV3 components

EV3 NXT

电机

传感器

软件

图 1-14 EV3 和 NXT 组件的兼容性表格

小结

本章中,你学到了如下内容:

❏ EV3 的电子部件

❏ EV3 软件的下载及安装过程

❏ 主要搭建零件的特性

❏ NXT 和 EV3 组件的兼容性