NXT Navigation via Arrow Keys

This is where you talk about the NXJ software itself, installation issues, and programming talk.

Moderators: 99jonathan, roger, imaqine

NXT Navigation via Arrow Keys

Postby nxtnewbie » Sat Apr 14, 2012 7:42 pm

Hello there!
I am new to lejos (and Java) and very excited of the options it provides so far!
Can someone help me build a Navigation Program for the NXT?
The project I want to accomplish is to connect the laptop with the NXT via Bluetooth and navigate the robot using the arrow keys of the keyboard.
And I want this Bluetooth connection until a button (q for example) is pressed from the keyboard.
Thanks in advance for your assistance.
nxtnewbie
New User
 
Posts: 11
Joined: Sat Apr 14, 2012 7:31 pm

Re: NXT Navigation via Arrow Keys

Postby roger » Sun Apr 15, 2012 3:00 am

Hi nxtnewbie,
A pretty ambitious project.
To learn how to communicate between the NXT and the PC, see the tutorial on communications.
For examples of a navigating robot controlled by a PC, see
http://lejos.svn.sourceforge.net/viewvc ... navigator/
and for the PC side, see:
http://lejos.svn.sourceforge.net/viewvc ... oncontrol/

Good luck,
Roger
roger
Moderator
 
Posts: 363
Joined: Fri Jun 01, 2007 4:31 am
Location: Berkeley, CA

Re: NXT Navigation via Arrow Keys

Postby nxtnewbie » Wed May 02, 2012 7:47 pm

Thank you Roger for the instant reply,

I read the links you sent me and I have achieved the Bluetooth Connection, as it is in the samples (to send an integer from the PC and print its negative on NXT's screen). Unfortunately, I haven't yet achieved the remote control despite all my efforts.
For the remote control part I have found this: http://lejos.sourceforge.net/p_technologies/nxt/nxj/api/lejos/devices/KeyEvent.html.
Could you please tell me if this is useful and give me an example of how to use the commands? (For example, when you press the up arrow key we want the robot to go straight)

Thank you!
nxtnewbie
New User
 
Posts: 11
Joined: Sat Apr 14, 2012 7:31 pm

Re: NXT Navigation via Arrow Keys

Postby roger » Tue May 08, 2012 8:48 pm

As I understand it, you want to use the arrow keys on your laptop, so you need a key listener in standard Java, not Lejos. The java tutorial on how to write a key listener might be useful.
Good luck
roger
Moderator
 
Posts: 363
Joined: Fri Jun 01, 2007 4:31 am
Location: Berkeley, CA

Re: NXT Navigation via Arrow Keys

Postby kirkpthompson » Wed May 09, 2012 1:50 pm

Hi.

Assuming you are going to create a Java Swing-based GUI client to communicate with your robot, a key binding makes sense for your arrow keys:
http://docs.oracle.com/javase/tutorial/uiswing/misc/keybinding.html.

Best,
-K
Leg Godt!
User avatar
kirkpthompson
leJOS Team Member
 
Posts: 304
Joined: Wed Dec 05, 2007 1:27 am
Location: New Mexico, USA


Return to NXJ Software

Who is online

Users browsing this forum: Yahoo [Bot] and 4 guests

more stuff