Java 与乐高机器人.pdf
《Java 与乐高机器人.pdf》由会员分享,可在线阅读,更多相关《Java 与乐高机器人.pdf(46页珍藏版)》请在三一文库上搜索。
1、Java and LEGO Robots 齐琨(Kun Qi) GC Senior Sales Consultant Copyright 2013, Oracle and/or its affiliates. All rights reserved. 2 拥有一个机器人是每个孩子的梦想拥有一个机器人是每个孩子的梦想 Copyright 2013, Oracle and/or its affiliates. All rights reserved. 3 梦想可以成真梦想可以成真 Copyright 2013, Oracle and/or its affiliates. All rights r
2、eserved. 4 Program Agenda LEGO(乐高) NXT leJOS Java控制NXT机器人 演示 Copyright 2013, Oracle and/or its affiliates. All rights reserved. 5 Lego NXT是什么?是什么? 硬件 ARM7(32位) AT91SAM7S256(48Mhz) 256K的闪存,64K的内存 蓝牙、USB2.0 4个输入、3个输出 64*100像素单色LCD 编程 NXT-G/LeJOS/NXC/RobotC/ 可编程组合机器人玩具 Copyright 2013, Oracle and/or its
3、 affiliates. All rights reserved. 6 LEGO设计工具设计工具 LEGO Digital Designer Copyright 2013, Oracle and/or its affiliates. All rights reserved. 7 LEGO编程语言编程语言 NXT-G Copyright 2013, Oracle and/or its affiliates. All rights reserved. 8 To fill a shape with an image. 1.Use existing picture box, DO NOT delete
4、 and create new picture box. 2.Right click on the shape. 3.At the bottom of the submenu select Format Shape 4.Select Fill at the top of the Format Shape dialog box. 5.Select Picture or Texture fill from the options. 6.And select File under the Insert from option. 7.Navigate to the file you want to u
5、se and select Insert 8.On the Format tab, in the Size group, click on Crop to Fill in the Crop tool and drag the image bounding box to the desired size 9.DELETE THIS INSTRUCTION NOTE WHEN NOT IN USE Copyright 2013, Oracle and/or its affiliates. All rights reserved. 9 是一个微型的Java VM,替代LEGO操作系统 最早来源于Ti
6、nyVM项目,一个基于Java的用于Lego Mindstorm RCX固件 2000年移到到leJOS项目 使用C和ARM的汇编指令编写 一次只能运行一个Java程序 leJOS包括两个项目 leJOS NXJ leJOS RCX leJOS: 运行在运行在LEGO上的上的Java 操作系统操作系统 http:/ Copyright 2013, Oracle and/or its affiliates. All rights reserved. 10 leJOS NXJ JavaVM的NXT固件,替换原有NXT的LEGO固件 Java 类库,classes.jar 实现NXJ API 提供替
7、代的Java Runtime (java.*) 工具 链接工具,链接java类和classes.jar为二进制文件格式,上传至NXT运行 PC工具,烧录固件到NXT中,上传程序,调试工具等功能 PC API,开发与NXJ通讯的程序,在蓝牙和USB连接上使用Java Stream,或使用LCP(LEGO通讯协议) LEGO NXT的Java环境 Copyright 2013, Oracle and/or its affiliates. All rights reserved. 11 为什么要用为什么要用leJOS? 使用行业标准的Java语言 支持面向对象编程 开源项目,有很多贡献者 使用专业的
8、IDE,Eclipse/Netbean 跨平台支持,Windows/Linux/Mac 比NXT-G更快(主要指开发效率) 全面支持蓝牙、USB、 I C和RS485协议 提供精确的马达控制 支持Java 7语言特性 Copyright 2013, Oracle and/or its affiliates. All rights reserved. 12 为什么要用为什么要用leJOS? 支持高级导航设备 支持蒙特卡罗定位 支持卡尔曼滤波 提供行为类来支持复杂机器人行为 支持大量第三方传感器 支持通过蓝牙或USB的远程事件记录 支持PC远程控制和跟踪NXJ程序 提供了浮点运算等数学运算函数 C
9、opyright 2013, Oracle and/or its affiliates. All rights reserved. 13 为什么要用为什么要用leJOS? 支持java.io访问flash文件系统 支持多线程 支持监听和事件 支持gc安全内存管理 支持8位WAV文件播放 提供了大量的样例 支持NXT到NXT的通讯 支持GPS设备 Copyright 2013, Oracle and/or its affiliates. All rights reserved. 14 准备准备leJOS环境环境 To fill a shape with an image. 1.Use exist
10、ing picture box, DO NOT delete and create new picture box. 2.Right click on the shape. 3.At the bottom of the submenu select Format Shape 4.Select Fill at the top of the Format Shape dialog box. 5.Select Picture or Texture fill from the options. 6.And select File under the Insert from option. 7.Navi
11、gate to the file you want to use and select Insert 8.On the Format tab, in the Size group, click on Crop to Fill in the Crop tool and drag the image bounding box to the desired size 9.DELETE THIS INSTRUCTION NOTE WHEN NOT IN USE Copyright 2013, Oracle and/or its affiliates. All rights reserved. 15 环
12、境准备环境准备Windows JDK 5/6/7 要使用32bit的 http:/ USB驱动 最新的Fantom Driver 1.1.3 http:/ Win7专业版+(或setup.ini-AllowWindowsStarter=1) 蓝牙模块(可选) 蓝牙设备及驱动 获取介质 Copyright 2013, Oracle and/or its affiliates. All rights reserved. 16 leJOS NXJ软件 0.9.1 beta版 http:/ leJOS_NXJ_0.9.1beta-3_win32_setup.exe (21.9 MB) IDE Ecli
13、pse/Netbean 必须使用32bit Copyright 2013, Oracle and/or its affiliates. All rights reserved. 17 安装安装leJOS 安装步骤 Copyright 2013, Oracle and/or its affiliates. All rights reserved. 18 建立建立NXT的的Java运行环境运行环境 NXT刷固件,将NXJ固件使用leJOS的Flash工具写入到NXT中 如果刷机失败,可以从LEGO官网中找到固件刷回,NXT不会变砖 环境变量 NXJ_HOME LEJOS_NXT_JAVA_HOME
14、 PATH=%NXJ%bin;%PATH% 写入leJOS到LEGO NXT Copyright 2013, Oracle and/or its affiliates. All rights reserved. 19 选择选择IDE,连接你的,连接你的NXT 安装新软件 lejos - http:/ 以Eclipse为例 Copyright 2013, Oracle and/or its affiliates. All rights reserved. 20 第一个程序第一个程序 与新建类的方式相同 屏幕输出的两种方式 LCD类 System.out.println Hello,World C
15、opyright 2013, Oracle and/or its affiliates. All rights reserved. 21 编译和上传程序编译和上传程序 运行-LeJOS NXT Program 插件完成Link、上传和运行的工作 Eclipse方式 Copyright 2013, Oracle and/or its affiliates. All rights reserved. 22 编译和上传程序编译和上传程序 nxjc.bat,使用javac编译源码,生成class文件 nxjc HelloWorld.java nxjlink.bat,生成LE格式的nxj文件 nxjli
16、nk o HelloWorld.nxj HelloWorld nxjupload.bat,上传nxj文件到NXT,执行程序 (r参数) nxjupload r HelloWorld.nxj nxj.bat,集成link和上传功能 nxj r o HelloWorld.nxj HelloWorld 手工方式 Copyright 2013, Oracle and/or its affiliates. All rights reserved. 23 按键按键 名称名称 说明说明 回车/开机 菜单选择 左 右 退出/关机 当位于顶层菜单时, 关机 leJOS的按键的按键 Copyright 2013,
17、 Oracle and/or its affiliates. All rights reserved. 24 leJOS的菜单的菜单 Copyright 2013, Oracle and/or its affiliates. All rights reserved. 25 控制轮式小车控制轮式小车 To fill a shape with an image. 1.Use existing picture box, DO NOT delete and create new picture box. 2.Right click on the shape. 3.At the bottom of th
18、e submenu select Format Shape 4.Select Fill at the top of the Format Shape dialog box. 5.Select Picture or Texture fill from the options. 6.And select File under the Insert from option. 7.Navigate to the file you want to use and select Insert 8.On the Format tab, in the Size group, click on Crop to
19、Fill in the Crop tool and drag the image bounding box to the desired size 9.DELETE THIS INSTRUCTION NOTE WHEN NOT IN USE Copyright 2013, Oracle and/or its affiliates. All rights reserved. 26 控制伺服电机控制伺服电机 Motor类是对NXT 马达的抽象 马达需要连接A/D 端口 A端口 B端口 C端口 Motor类 类类 方法方法 说明说明 Motor.A forward() 向前转动 backward()
20、 向后转动 stop() 快速停止 getTachoCount() 返回马达角度 setSpeed(int speed) 设置每秒的角度值 rorate(int angle) 旋转angle角度 rorateTo(int angle) 旋转到angle角度 rorate(int angle,boolean immediateReturn) 如果是true,则方法立 即返回 rorateTo(int angle,boolean immediateReturn) 如果是true,则方法立 即返回 Copyright 2013, Oracle and/or its affiliates. All r
- 配套讲稿:
如PPT文件的首页显示word图标,表示该PPT已包含配套word讲稿。双击word图标可打开word文档。
- 特殊限制:
部分文档作品中含有的国旗、国徽等图片,仅作为作品整体效果示例展示,禁止商用。设计者仅对作品中独创性部分享有著作权。
- 关 键 词:
- Java 与乐高机器人 机器人
链接地址:https://www.31doc.com/p-3330481.html