Class LCP - direct command/ system command

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

Moderators: roger, 99jonathan, imaqine

Class LCP - direct command/ system command

Postby gbh » Wed Nov 16, 2011 1:17 pm

Greetings.

I'm currently looking for the code to control NXT brick without uploading and run .nxt file in the NXT brick.
Upon research, I found Mindroid application which using the LCP class constants with Direct command and System command via bluetooth connection is able to do so.
Here is the class link : http://lejos.sourceforge.net/nxt/nxj/ap ... m/LCP.html
But, it only able to control the nxt motor ports and is much more different compared with the Class Pilot.

May I know which constant field in the LCP class is able to control sensor ports and get sensor readings?

Thanks.
goh
gbh
New User
 
Posts: 7
Joined: Wed Jan 19, 2011 7:38 am
Location: Malaysia

Re: Class LCP - direct command/ system command

Postby gloomyandy » Wed Nov 16, 2011 5:02 pm

What do you want to run your program on? If it is a Mac/Linux/Windows PC then you have a pretty complete set of classes available using the leJOS PC API:
http://lejos.sourceforge.net/nxt/pc/api/index.html
The tutorials have more details on using the API:
http://lejos.sourceforge.net/nxt/nxj/tutorial/index.htm

If you are trying to run your program on Android then I'm sorry I can't help, perhaps others can...

Andy
User avatar
gloomyandy
leJOS Team Member
 
Posts: 3003
Joined: Fri Sep 28, 2007 2:06 pm
Location: UK

Re: Class LCP - direct command/ system command

Postby gbh » Thu Nov 17, 2011 2:21 am

Thanks for the reply.

hmm... yes, the program is running on Android.
goh
gbh
New User
 
Posts: 7
Joined: Wed Jan 19, 2011 7:38 am
Location: Malaysia

Re: Class LCP - direct command/ system command

Postby Shawn » Thu Nov 17, 2011 10:25 pm

Hi,

The android stuff is only in svn.

There shouldn't be too much difference between standard leJOS and android here (other than android can't do the robotic package).

The TachoCount example shows how to use motors:

Code: Select all
public class TachoCount {
   
   public static void main(String [] args) throws Exception {
      NXTConnector conn = new NXTConnector();
      conn.addLogListener(new NXTCommLogListener() {
         public void logEvent(String message) {
            System.out.println(message);            
         }

         public void logEvent(Throwable throwable) {
            System.err.println(throwable.getMessage());         
         }         
      });
      conn.setDebug(true);
      if (!conn.connectTo("btspp://NXT", NXTComm.LCP)) {
         System.err.println("Failed to connect");
         System.exit(1);
      }
      NXTCommand.getSingleton().setNXTComm(conn.getNXTComm());
      
      System.out.println("Tachometer A: " + Motor.A.getTachoCount());
      System.out.println("Tachometer C: " + Motor.C.getTachoCount());
      Motor.A.rotate(5000);
      Motor.C.rotate(-5000);
      Thread.sleep(10000);
      Sound.playTone(1000, 1000);
      System.out.println("Tachometer A: " + Motor.A.getTachoCount());
      System.out.println("Tachometer C: " + Motor.C.getTachoCount());
      conn.close();
   }   
}


I'm not so sure about sensors via LCP but the PC examples has:

Code: Select all
   /**
 * This is a test of remote reading of sensors from the PC
 * using the iCommand equivalent classes in pccomm.jar
 *
 * @author Lawrie Griffiths
 *
 */
public class SensorTest {
   public static void main(String[] args) {
      LightSensor light = new LightSensor(SensorPort.S1);
      SoundSensor sound = new SoundSensor(SensorPort.S2);
      TouchSensor touch = new TouchSensor(SensorPort.S3);
      UltrasonicSensor sonic = new UltrasonicSensor(SensorPort.S4);
      
      while(sound.readValue() < 90) {      
         System.out.println("light = " + light.readValue());
         System.out.println("sound = " + sound.readValue());
         System.out.println("touch = " + touch.isPressed());
         System.out.println("distance = " + sonic.getDistance());
         try {
            Thread.sleep(1000);
         } catch (InterruptedException ie) {}
      }
   }
}


Give it a try and if that doesn't work, perhaps see the link below. Anyway, as I said using LCP should be the same for Android so any posts you see related to that should apply.

see http://lejos.sourceforge.net/p_technologies/nxt/nxj/api/lejos/nxt/remote/RemoteNXT.html

Shawn
User avatar
Shawn
Advanced Member
 
Posts: 723
Joined: Wed Sep 12, 2007 4:59 am
Location: Tokyo

Re: Class LCP - direct command/ system command

Postby CrazyRobotMan » Fri Aug 24, 2012 4:31 am

A great tutorial for the Lego LCP is here:

http://www.robotappstore.com/Knowledge- ... ms/92.html

If you also go to the store section, and then under the navigation tab, there is a free app you can download called NXT navigation that runs over bluetooth on the android. (http://www.robotappstore.com/Apps/NXT-E ... B6F082439E)

I'm not terribly familiar with the differences in the android OS, but as long as you are sending the correct LPC commands you should be fine.
CrazyRobotMan
New User
 
Posts: 1
Joined: Fri Aug 24, 2012 4:19 am


Return to NXJ Software

Who is online

Users browsing this forum: No registered users and 2 guests

more stuff