Current Priority List for NXJ

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

Moderators: roger, 99jonathan, imaqine

I2C and Bluetooth

Postby esmetaman » Mon Nov 12, 2007 9:38 pm

I agree with mdsmitty. In new release, I2C should write and it is neccesary to improve BT communications.
Juan Antonio Breña Moral
http://www.juanantonio.info/lejos-ebook/
http://www.roboticaenlaescuela.es
User avatar
esmetaman
Advanced Member
 
Posts: 201
Joined: Wed Sep 13, 2006 12:16 am
Location: Madrid, Spain

Postby PatrickLismore » Mon Feb 11, 2008 7:59 am

what about allowing you to pass over more than 15 parameters to class constructors currrently only 15 are supported.

makes working with 3 light sensors possible,

also allowing communication between NXT Brick and PC via bluetooth as well executing a program on the NXT brick at the same time.

currently it seems that you can run one or the other, PC based or NXT based programs not together.
User avatar
PatrickLismore
Active User
 
Posts: 81
Joined: Tue Oct 16, 2007 7:28 pm
Location: Prague

Postby lawrie » Tue Feb 12, 2008 1:25 pm

Why do you need so many parameters on a constructor?

There are likely to be better designs that reduce the number of parameters, such as using arrays, defining classes that combine some of the parameters, using set methods after constructing the objects, etc. More than 15 parameters on any constructor or method call is going to be hard to understand.

I do not understand your other point. You can write programs that execute locally, and simultaneously talk to the PC, other NXTs and other devices via Bluetooth. What difficulty are you hitting?

If you want to execute LCP commands while a program is running, you can use the LCPBTResponder like the MonitorTest sample does, but it is usually best to define your own commands and send them over Bluetooth Java streams.
lawrie
leJOS Team Member
 
Posts: 677
Joined: Mon Feb 05, 2007 1:27 pm

Postby PatrickLismore » Wed Feb 13, 2008 5:21 am

hi lawrie,

the reason for the paramters is based on the design,

im using JCSP robot edition . stripped down version of JCSP.

my design consists of a set processes such as ActiveLightSensor process, control process, filter process, ActiveMotor process. If your not aware these processes interact with other processes via channels.

So basicly i instansiate three ActiveLightSensor Processes , three filters one for each LightSensor which are to feed into the control process. In the flow of the program once you hit start it says "black color" this is where i calibrate the value for black. i then next do white and once the calibration is done you hit the button again to go.


its due to the channels,

I need a channel to cofigure the ALS process and the filter processes as well as setting the levels,

heres an example

Code: Select all


import lejos.nxt.Motor;

import org.jcsp.nxt.io.ActiveButtons;
import org.jcsp.nxt.io.ActiveLightSensor;
import org.jcsp.nxt.io.ActiveMotor;
import org.jcsp.nxt.lang.Alternative;
import org.jcsp.nxt.lang.AltingChannelInputInt;
import org.jcsp.nxt.lang.CSProcess;
import org.jcsp.nxt.lang.ChannelInputInt;
import org.jcsp.nxt.lang.ChannelOutputInt;
import org.jcsp.nxt.lang.Guard;
import org.jcsp.nxt.lang.One2OneChannel;
import org.jcsp.nxt.lang.One2OneChannelInt;
import org.jcsp.nxt.lang.One2OneChannelIntImpl;
import org.jcsp.nxt.lang.Parallel;

/**
 * @author NewIrelandComputing
 *
 */
public class logic implements CSProcess {


   int id1 = 1;
   int id2 = 2;
   int id3 = 3;
   private ChannelOutputInt buttonPress = new One2OneChannelIntImpl();
   private Object lightLeft;
   private Object lightCenter;
   private Object lightRight;
   private Object lightLevelLeft;
   private Object lightLevelCenter;
   private Object lightLevelRight;
   private AltingChannelInputInt filterOutputWhiteLeft;
   private AltingChannelInputInt filterOutputWhiteCenter;
   private AltingChannelInputInt filterOutputWhiteRight;
   private AltingChannelInputInt filterOutputBlackLeft;
   private AltingChannelInputInt filterOutputBlackCenter;
   private AltingChannelInputInt filterOutputBlackRight;
   private ChannelOutputInt lightConfigLeft;
   private ChannelOutputInt lightConfigCenter;
   private ChannelOutputInt lightConfigRight;
   private ChannelOutputInt filterConfigLeft;
   private ChannelOutputInt filterConfigCenter;
   private ChannelOutputInt filterConfigRight;
   private Parallel par = new Parallel();
   private Motor m1 = Motor.A;
   private Motor m2 = Motor.B;
   private ChannelOutputInt motorSpeed;
   private ChannelOutputInt buttonPressRtn;
   
   
   public logic(ChannelInputInt levelLeft,
         ChannelInputInt levelCenter,
         ChannelInputInt levelRight,
         AltingChannelInputInt filterOutWhiteLeft,
         AltingChannelInputInt filterOutWhiteCenter,
         AltingChannelInputInt filterOutWhiteRight,
         AltingChannelInputInt filterOutBlackLeft,
         AltingChannelInputInt filterOutBlackCenter,
         AltingChannelInputInt filterOutBlackRight,
         ChannelOutputInt configLeft,
         ChannelOutputInt configCenter,
         ChannelOutputInt configRight,
         ChannelOutputInt filterConfigLeft,
         ChannelOutputInt filterConfigCenter,
         ChannelOutputInt filterConfigRight){

      ActiveButtons press = new ActiveButtons(buttonPress.in());
      par.addProcess(press);
      
      this.buttonPressRtn = buttonPress;
      this.lightLevelLeft = lightLeft;
      this.lightLevelCenter = lightCenter;
      this.lightLevelRight = lightRight;
      
      this.filterOutputWhiteLeft = filterOutWhiteLeft;
      this.filterOutputWhiteCenter = filterOutWhiteCenter;
      this.filterOutputWhiteRight = filterOutWhiteRight;
      
      this.filterOutputBlackLeft = filterOutBlackLeft;
      this.filterOutputBlackCenter = filterOutBlackCenter;
      this.filterOutputBlackRight = filterOutBlackRight;
      
      this.lightConfigLeft = configLeft;
      this.lightConfigCenter = configCenter;
      this.lightConfigRight = configRight;
      
      this.filterConfigLeft = filterConfigLeft;
      this.filterConfigCenter = filterConfigCenter;
      this.filterConfigRight = filterConfigRight;
      
      
      this.id1 = 1;
      this.id2 = 2;
      this.id3 = 3;
      
      par.addProcess(new ActiveMotor( m1, motorSpeed.in()));
      par.addProcess(new ActiveMotor( m2, motorSpeed.in()));
      this.motorSpeed = motorSpeed.out();
      
      
   }

   public void run() {
      
      par.run();
      int rotate = 0;
      int noRotate = -2;
      int altIndex = -1;
      buttonPressRtn.read(); // configure black level
      //Display.print("B");
      //Display.print(id);
      lightConfigLeft.write(ActiveLightSensor.LEVEL);
      lightConfigCenter.write(ActiveLightSensor.LEVEL);
      lightConfigRight.write(ActiveLightSensor.LEVEL);
      //Display.print("C");
      //Display.print(id);
      int lowleft = ((ChannelInputInt) lightLevelLeft).read();
      int lowcenter = ((ChannelInputInt) lightLevelCenter).read();
      int lowright = ((ChannelInputInt) lightLevelRight).read();
      //Display.print("L");
      //Display.print(low);
      buttonPress.read(); // configure white level
      //Display.print("W");
      //Display.print(id);
      lightConfigLeft.write(ActiveLightSensor.LEVEL);
      lightConfigCenter.write(ActiveLightSensor.LEVEL);
      lightConfigRight.write(ActiveLightSensor.LEVEL);
      
      //Display.print("C");
      //Display.print(id);
      int highLeft = ((ChannelInputInt) lightLevelLeft).read();
      int highCenter = ((ChannelInputInt) lightLevelCenter).read();
      int highRight = ((ChannelInputInt) lightLevelRight).read();
      
      //Display.print("H");
      //Display.print(high);
      int midLeft = lowleft + ((highLeft - lowleft)/2);
      int midCenter = lowcenter + ((highCenter - lowcenter)/2);
      int midRight = lowright + ((highRight - lowright)/2);
      //Display.print("M");
      //Display.print(mid);
      filterConfigLeft.write( midLeft ); // write mid point value to the filter
      filterConfigCenter.write( midCenter ); // write mid point value to the filter
      filterConfigRight.write( midRight ); // write mid point value to the filter
      
      //Display.print("F");
      //Display.print(id);
      lightConfigLeft.write(ActiveLightSensor.ACTIVATE);
      lightConfigCenter.write(ActiveLightSensor.ACTIVATE);
      lightConfigRight.write(ActiveLightSensor.ACTIVATE);
      
      //Display.print("A");
      Alternative a = new Alternative( new Guard[] { filterOutputWhiteLeft,  filterOutputWhiteCenter, filterOutputWhiteRight, filterOutputBlackLeft, filterOutputBlackCenter, filterOutputBlackRight, (Guard) buttonPress } );
            
      
      while (true) {
         //rotate = buttonPress.read(); // read speed of wheel rotation
         //Display.println( rotate );
         buttonPress.read(); // the go signal
         boolean going = true;
         while (going) {
            
            altIndex = a.fairSelect();
            
            
            if (altIndex == 0) {
               
               filterOutputWhiteLeft.read();
               
               if(altIndex == 2){
                  
                  filterOutputWhiteRight.read();
                  
                  
                  if(altIndex == 4){
                     
                     filterOutputBlackCenter.read();
                     m1.forward();
                     m2.forward();
                     
                  }
                  
                  
               }else if ( altIndex == 5){
                  
                  filterOutputBlackRight.read();
                  
                  if(altIndex == 1){
                     
                     filterOutputWhiteCenter.read();
                     
                     m1.forward();
                     m2.backward();
                     
                  }else if(altIndex == 4){
                     
                     filterOutputBlackCenter.read();
                     m1.forward();
                     m2.backward();
                     
                  }
                  
                  
               }
            }
               //=========
               
               if (altIndex == 2) {
                  
                  filterOutputWhiteRight.read();
                  
                  if(altIndex == 0){
                     
                     filterOutputWhiteLeft.read();
                     
                     
                     if(altIndex == 4){
                        
                        filterOutputBlackCenter.read();
                        m1.forward();
                        m2.forward();
                        
                     }
                     
                     
                  }else if ( altIndex == 3){
                     
                     filterOutputBlackLeft.read();
                     
                     if(altIndex == 1){
                        
                        filterOutputWhiteCenter.read();
                        
                        m2.forward();
                        m1.backward();
                        
                     }else if(altIndex == 4){
                        
                        filterOutputBlackCenter.read();
                        m2.forward();
                        m1.backward();
                        
                     }
                     
                     
                  }
               }
               //==========
                  
                  if (altIndex == 4) {
                     
                     filterOutputBlackCenter.read();
                     
                     if(altIndex == 2){
                        
                        filterOutputWhiteRight.read();
                        
                        
                        if(altIndex == 0){
                           
                           filterOutputWhiteLeft.read();
                           m1.forward();
                           m2.forward();
                           
                        }
                        
                        
                     }else if ( altIndex == 5){
                        
                        filterOutputBlackRight.read();
                        
                        if(altIndex == 0){
                           
                           filterOutputWhiteLeft.read();
                           
                           m1.forward();
                           m2.backward();
                           
                        }else if(altIndex == 3){
                           
                           filterOutputBlackLeft.read();
                           m1.forward();
                           
                           
                        }
                        
                        
                     }
                  }
                  
            if (altIndex == 6) {
               buttonPress.read(); // the stop signal
               going = false;
            }
         }
      }
   }


 


Think of the design looking like

three active light sensor process feeding black or white through channels into three BinaryFilter processes which will then feed integers(for go or stop) in to one control process. the control process has the logic to look at the data coming in and make the robot folow the line. The control process then ouputs data to two Active motor processes. But with the restriction on parameters I cant make use of the 3rd light sensor. Only two. Im sure if i just wrote a normal looking program i could use it but the projects about learning concurrent/parallel programming. Designing this way im learning about making self contained processes that can easily be reused. Having a system of processes interacting with each other via channels all in sync.

Im studing parallelism and seeing if theirs any performence in building software that has several processes running conncurrently versus the traditional OO design. Laying the ground work for future design and development of parallel systems and software that runs on dual cores and multi core systems.

As far im aware the only other people working with parallelism/concurrency on the NXT are myself at my university and university of kent. We are using JCSP and University of Kent are using OCCAM PI.

So far one and two sensors work but cant do three, then when i go to attempt to add the bluetooth process it increases the parameters which then fails because their is a limit in lejos.

I hope this was clear for you to understand.

I recently was told about the LCPBTResponder in another post and im currently working with it.
User avatar
PatrickLismore
Active User
 
Posts: 81
Joined: Tue Oct 16, 2007 7:28 pm
Location: Prague

Postby lawrie » Sat Feb 16, 2008 10:39 pm

OK, I understand.

I have had a quick look at the linker and I cannot see any reason why the current values of MAX_PARAMETERS_WORDS of 16, cannot be changed to anything up to 255, as the number of parameters is held in a byte. I may well have missed something. I will see if we can increase the limit for the next release.
lawrie
leJOS Team Member
 
Posts: 677
Joined: Mon Feb 05, 2007 1:27 pm

ICommand style conection over usb

Postby ChrisB01 » Sat May 24, 2008 10:13 am

I think it would be useful if you could implement a icommand type of interface over USB. This would make it easier to control the nxt from your computer without having to use Bluetooth.
ChrisB01
Advanced Member
 
Posts: 189
Joined: Sat Mar 15, 2008 12:19 pm
Location: UK

Priority list updated?

Postby christhompson » Sun Jul 06, 2008 5:21 am

Hi there,

I am just curious whether the priority list is still up to date--it looks like it hasn't been edited in a year or so...

Thanks,

C
christhompson
Novice
 
Posts: 32
Joined: Tue May 06, 2008 5:44 am

Postby enzomango » Mon Jan 05, 2009 4:40 pm

Giving the user control over the NXT volume (incl. the button clicks) was a great improvement, but Java Exceptions are still audible (and loud!) even if the NXT sound is set to "mute". I'd like the option to mute exceptions.
enzomango
Novice
 
Posts: 30
Joined: Tue Feb 26, 2008 5:20 pm

Postby gloomyandy » Mon Jan 05, 2009 5:48 pm

Hi,
If you add the -g option to the linker then the debug code will be included with your program, this will intercept any uncaught exceptions. This means that the tone played will use the volume setting. You will also get a mini stack trace, and if you are using RConsole you can redirect the output to your PC (by directing the System.err stream to RConsole)....

The reason the volume control does not work for the default exception handler is that this is implemented in the firmware, while the volume control code is in the Java code. The development team spent a long time discussing the best place to implement volume (and other settings), and we decided that this was the best overall compromise (between memory usage/complexity and convenience, access by user programs etc.).....

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

Speech Recognition

Postby bashiz » Fri Jan 23, 2009 1:16 pm

Hi,

Did you consider having the java speech recognition engine migrated into leJOS ?

mainly

javax.speech.*
javax.speech.recognition.*

This will be extremely useful.

Thanks.
bashiz
New User
 
Posts: 1
Joined: Fri Jan 23, 2009 1:12 pm

Postby lawrie » Sat Jan 24, 2009 9:05 pm

javax.speech is an API. It needs an implementation, and most of the implementations rely on commercial products such as IBM's Via Voice. Do you know of an open source implementation.

I did an example for the RCX using IBM's ViaVoice - see http://lejos.sourceforge.net/tutorial/speech/index.html. This is probably out of date.

Brian's book, Maximum Lego NXT: Building Robots with
Java Brains, has an example using the open source Sphinx package, but that does not seem to use javax.speech.

There isn't really any need for support in leJOS as the speech recognition is done on the PC. All it then needs is a way of executing commands on the NXT, and you can do that withy iCommand or lejos.pc.comm.
lawrie
leJOS Team Member
 
Posts: 677
Joined: Mon Feb 05, 2007 1:27 pm

Postby lejosfan » Sun Feb 15, 2009 6:28 pm

Hello guys.

Again, thank you so much for the fantastic work you guys do. I just would like to pick up on a comment made by another poster:

I'm really desperate for a lejos nxt emulator. It would be really helpful to test out code without the bother of putting on the lejos firmware and then reloading the normal one. I'm on the highschool lego league team but there is only one nxt between us and the junior high team...


A simulation environment, even a crude one, that is kept up to date and runs and compile in Windows would be a fabulous feature.

Here's the reason why: Lejos is not only fun, but also extremely handy as an educational tool. I have a sense that it is being used by many universities' Computer Science courses and highschools, as the quote above suggests.

A simulator doesn't need to be sophisticated at first. It can be as simple as having the ability to display strings on the PC's console screen. This would allow developers out there to start picking up from there and incrementally start contributing code to the community.

Great job guys.
LejosFan.
lejosfan
New User
 
Posts: 19
Joined: Sat Jan 24, 2009 6:45 pm

Postby meister_steve » Wed Apr 22, 2009 3:52 pm

Hi there,

it would be nice to have a signum function added to the Math library in the next release.
It's only some lines of code:

Code: Select all
   /**
    * Signum function. Only the sign of the argument is returned.
    */
   public static int sgn(int a) {
      if (a < 0)
         return -1;
      else
         return 1;
   }

   /**
    * Signum function. Only the sign of the argument is returned.
    */
   public static double sgn(double a) {
      if (a < 0)
         return -1.0;
      else
         return 1.0;
   }



If you wish I can also check it in.

Thanks
Steffen
meister_steve
Novice
 
Posts: 27
Joined: Sun Sep 28, 2008 4:24 pm
Location: Germany

Postby gloomyandy » Wed Apr 22, 2009 4:04 pm

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

Postby pegu » Tue May 26, 2009 1:02 am

I'd like to see the firmware be compatible with NXT-G-made programs.
pegu
Novice
 
Posts: 42
Joined: Tue May 26, 2009 1:00 am

PreviousNext

Return to NXJ Software

Who is online

Users browsing this forum: No registered users and 3 guests

more stuff