Upload
roxanne-barker
View
225
Download
3
Embed Size (px)
DESCRIPTION
serial profile 지원하는 usb Bluetooth Dongle 필요 NXT 끼리의 연결 ◦ 동시에 3 개의 다른 NXT 와 연결 가능 ◦ 1 개와의 통신만 가능 ◦ 파일 전송 가능 Bluetooth 연동되는 다른 기기와도 연결 가능 ◦ 핸드폰 ◦ 조이스틱
Citation preview
(Icommand & Processing)
The NXT is the brain of a MINDSTORMS® robot. It's an intelligent, computer-controlled LEGO® brick that lets a MINDSTORMS robot come alive and
perform different operation.
serial profile 지원하는 usb Bluetooth Dongle 필요
NXT 끼리의 연결◦ 동시에 3 개의 다른 NXT 와 연결 가능◦ 1 개와의 통신만 가능◦ 파일 전송 가능
Bluetooth 연동되는 다른 기기와도 연결 가능◦ 핸드폰◦ 조이스틱
NXT Bluetooth Dongle
Icommand & processind
Download and install Eclipse◦ http://www.eclipse.org/downloads/
Download and install Processing◦ http://www.processing.org/download/index.html
FILE –> NEW PROJECT and select “Java Project”
Enter your project name (for example, “TestProcessing”) and select “finish”
FILE –> IMPORT –> GENERAL –> FILE SYSTEMClick Next.
Click browse and find the “lib” directory inside the Processing application folder.“C:\processing – 0135\lib” Select the file “core.jar” inside the lib folder.
Click “finish.”
BUILD PATH –> ADD TO BUILD PATHThe “core.jar” file should now appear with a jar icon.
FILE –> NEW –> CLASS
Enter in a class name “MyProcessingSketch” and click finish.
After selecting finish, you’ll see the following code :
Import the core Processing library :◦ “import processing.core.*;”
PApplet is the parent Processing class that allows us to have access to all the Processing goodies.
Write setup() and draw()◦ and specify “public” for these Processing
functions.
RUN –> RUN AS –> JAVA APPLET
마우스가 클릭된 시작점과 끝점의 좌표를 이용한 line drawing
RUN –> RUN AS –> JAVA APPLICATIONFullScreen.
Download http://sourceforge.net/projects/nxtcommand/
bluecove.jar 와 icommand.jarbluecove 는 Java API 로 지원되는 bluetooth library.
icommand 는 bluecove 를 이용해서 NXT 에 표준 명령을 전달하기 위한 API 를 제공 .
Bluetooth Bluetooth Communication
◦ RXTX : a native lib providing serial and parallel communication for the
Java Development http://www.rxtx.org/
◦ BlueZ : Official Linux Bluetooth protocol stack http://www.bluez.org/download/
◦ Bluecove a Java library for Bluetooth (JSR-82 implementation) that currently
interfaces with the Mac OS X, WIDCOMM, BlueSoleil and Microsoft Bluetooth stack
http://www.bluecove.org/
◦ ETC http://www.ecst.csuchico.edu/~juliano/Research/Blog/nxt.html
import icommand.nxt.Motor;import icommand.nxt.comm.NXTCommand;public class TestNXT { public static void main(String[] args) { NXTCommand.open(); // 블루투스 연결 초기화 Motor.B.setSpeed(100); // 속도 //Motor.B.forward();
Motor.B.rotate(360); // 한바퀴 Motor.B.stop(); // 정지
NXTCommand.close(); // 연결을 끊음 }}
실행하기 전에 properties 파일로 NXT 와의 연결 정보를 주어야 한다 .◦ C:\Document and Settings\icommand.properties
각자의 윈도우 사용 계정 파일을 만들던가 아님 , 파일 없이 수행하면 에러가 나면서
자동으로 파일이 생성된다 .
nxt.btaddress=00165300d860nxtcomm.type=bluecovenxtcomm=COM5
Icommand◦ C:\icommand-0.6\docs\api\index.html
압축 풀어놓은 경로의 docs 폴더
Processing◦ http://www.processing.org/reference/
index_ext.html
http://folog.egloos.com/1296765 http://www.mostpixelsever.com/tutorial/
eclipse/
키보드 4, 8, 6, 2 버튼을 누르는 동안 nxt 가 움직이게 해보자 .◦ 4 번 키 – 왼쪽으로 회전◦ 8 번 키 – 앞으로 전진◦ 6 번 키 – 오른쪽으로 회전◦ 2 번 키 – 뒤로 후진
Processing – 키보드 값 제어 Icommand – 모터 제어
processing – reference
Input -> Keyboard -> keyPressed◦ Draw() 안과 밖의 차이점
안 : 계속 반복하면서 키보드의 눌림을 확인한다 . 밖 : 계속 누르고 있어도 반복되지 않기 때문에 한번만
누른것으로 된다 .