NXT Environment Setup( icommand + eclipse + processing)

Download Report

Transcript NXT Environment Setup( icommand + eclipse + processing)

(Icommand & Processing)

NXT

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

Create a new project.

FILE –> NEW PROJECT and select “Java Project”

Create a new project.

Enter your project name (for example, “TestProcessing”) and select “finish”

Import the Processing libraries.

FILE –> IMPORT –> GENERAL –> FILE SYSTEM Click Next.

Import the Processing libraries.

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.”

Import the Processing libraries.

BUILD PATH –> ADD TO BUILD PATH The “core.jar” file should now appear with a jar icon.

Create a class and write your code.

FILE –> NEW –> CLASS

Create a class and write your code.

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 –> RUN AS –> JAVA APPLET

JAVA APPLET

마우스가 클릭된 시작점과 끝점의 좌표를 이용한 line drawing

JAVA APPLICATION

RUN –> RUN AS –> JAVA APPLICATION FullScreen.

  Download http://sourceforge.net/projects/nxtcommand/

Import the Icommand jar file

icommand 는 bluecove 는 bluecove 를 이용해서 NXT Java API bluecove.jar

로 지원되는 와 icommand.jar

bluetooth library.

에 표준 명령을 전달하기 위한 API 를 제공 .

 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=00165300d860 nxtcomm.type=bluecove nxtcomm=COM5

 ◦ Icommand C:\icommand-0.6\docs\api\index.html

 압축 풀어놓은 경로의 docs 폴더  ◦ Processing http://www.processing.org/reference/index_ext.ht

ml   http://folog.egloos.com/1296765 http://www.mostpixelsever.com/tutorial/ecli pse/

 ◦ ◦ ◦ ◦ 키보드 4, 8, 6, 2 버튼을 누르는 동안 이게 해보자 .

4 번 키 8 번 키 6 번 키 2 번 키 – – – – 왼쪽으로 회전 앞으로 전진 오른쪽으로 회전 뒤로 후진 nxt 가 움직   Processing – Icommand – 키보드 값 제어 모터 제어

 processing – reference  ◦ Input -> Keyboard -> keyPressed Draw() 안과 밖의 차이점   안 : 계속 반복하면서 키보드의 눌림을 확인한다 .

밖 : 계속 누르고 있어도 반복되지 않기 때문에 한번만 누른 것으로 된다 .