0.9.0 NXTLineLeader problems

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

Moderators: 99jonathan, roger, imaqine

0.9.0 NXTLineLeader problems

Postby Walt White » Mon Jun 06, 2011 1:36 am

In a previous thread I reported that the NXTLineLeader class didn't seem able to accurately set some of the PID constant values correctly. That was before the release of 0.9.0 and Andy responded suggesting that the version that would be included in 0.9.0 would be basically the same and he suggested that
looking at the code I don't really see anything wrong with it and would suspect that the odd values being returned are down to the sensor. You could test this by trying the same thing from NXC (or RobotC if you have it).


I don't have any other NXT languages available, but I did try using the LineLeader class submitted by ChrisB01 in this thread.

The results show that the ChrisB01 class can in fact accurately set the PID constants on the sensor and the release 0.9.0 class still has problems. Specifically, the release 0.9.0 class commands to set the KI Divisor and KD Divisor do not change those values from the default settings and the command to set the KP Divisor sets it to whatever value you have supplied as the KI Divisor.

The code for testing the Release 0.9.0 class:
Code: Select all
import lejos.nxt.*;
import lejos.nxt.addon.NXTLineLeader;

public class Rel090 {
   
   /** Uses the new NXTLineLeader class included with Release 0.9.0
    */
   
   static NXTLineLeader liner = new NXTLineLeader(SensorPort.S4);
   
    /** Default settings for the sensor are:
    * SetPoint=45, Kp=25, KpDiv=32, Ki=0, KiDiv=32, Kd=10, KdDiv=32.  **/
   
   public static void main(String[] args) throws InterruptedException {
      Rel090 display = new Rel090();
   }
   
   public Rel090()  {
      while (Button.ENTER.isPressed())  {  }
        liner.wakeUp();
       
      LCD.drawString("Release 0.9.0", 0, 0);
      LCD.drawString("Default values: ", 0, 1);
      LCD.drawString("SetPoint=" + liner.getSetPoint(), 0, 2);
      LCD.drawString("Kp=" + liner.getKP() + " " + "KpDiv=" + liner.getKPDivisor(), 0, 3);
      LCD.drawString("Ki=" + liner.getKI() + " " + "KiDiv=" + liner.getKIDivisor(), 0, 4);
      LCD.drawString("Kd=" + liner.getKD() + " " + "KdDiv=" + liner.getKDDivisor(), 0, 5);
      LCD.drawString("Press orange btn", 0, 6);
      Button.ENTER.waitForPressAndRelease();
      LCD.clear();
      
       int SetPoint = 12;
        int KP = 13, KPDivisor = 14;
        int KI = 15, KIDivisor = 16;
        int KD = 17, KDDivisor = 18;
        liner.setSetPoint(SetPoint);
      liner.setKP(KP);
      liner.setKD(KD);
      liner.setKI(KI);
      liner.setKPDivisor(KPDivisor);
      liner.setKPDivisor(KDDivisor);
      liner.setKPDivisor(KIDivisor);

      LCD.drawString("Release 0.9.0", 0, 0);
      LCD.drawString("My init values: ", 0, 1);
      LCD.drawString("SetPoint=" + liner.getSetPoint(), 0, 2);
      LCD.drawString("Kp=" + liner.getKP() + " " + "KpDiv=" + liner.getKPDivisor(), 0, 3);
      LCD.drawString("Ki=" + liner.getKI() + " " + "KiDiv=" + liner.getKIDivisor(), 0, 4);
      LCD.drawString("Kd=" + liner.getKD() + " " + "KdDiv=" + liner.getKDDivisor(), 0, 5);
      LCD.drawString("Press orange btn", 0, 6);
      Button.ENTER.waitForPressAndRelease();
   }
}



The code for testing the ChrisB01 class:
Code: Select all
import lejos.nxt.*;

public class ChrisB01 {
   
   /** Uses the LineLeader class written by ChrisB01.  That class is stored in the
    * same Eclipse folder as this program.
    */
   
   static LineLeader liner = new LineLeader(SensorPort.S4);
   
   /** Default settings for the sensor are:
   * SetPoint=45, Kp=25, KpDiv=32, Ki=0, KiDiv=32, Kd=10, KdDiv=32.  **/

   public static void main(String[] args) throws InterruptedException {
      ChrisB01 display = new ChrisB01();
   }
   
   public ChrisB01() {
      while (Button.ENTER.isPressed())  {  }
      liner.setSleep('P');  // wake it up; turn it on.
      LCD.drawString("ChrisB01 class", 0, 0);
      LCD.drawString("Default values: ", 0, 1);
      LCD.drawString("SetPoint=" + liner.getSetPoint(), 0, 2);
      LCD.drawString("Kp=" + liner.getKp() + " " + "KpDiv=" + liner.getKpDivisor(), 0, 3);
      LCD.drawString("Ki=" + liner.getKi() + " " + "KiDiv=" + liner.getKiDivisor(), 0, 4);
      LCD.drawString("Kd=" + liner.getKd() + " " + "KdDiv=" + liner.getKdDivisor(), 0, 5);
      LCD.drawString("Press orange btn", 0, 6);
      Button.ENTER.waitForPressAndRelease();

      int SetPoint = 12;
       int Kp = 13, KpDivisor = 14; 
       int Ki = 15, KiDivisor = 16; 
       int Kd = 17, KdDivisor = 18; 
      liner.setSetPoint(SetPoint);
      liner.setKp(Kp);
      liner.setKpDivisor(KpDivisor);
      liner.setKi(Ki);
      liner.setKiDivisor(KiDivisor);
      liner.setKd(Kd);
      liner.setKdDivisor(KdDivisor);
      LCD.drawString("ChrisB01 class", 0, 0);
      LCD.drawString("My init values: ", 0, 1);
      LCD.drawString("SetPoint=" + liner.getSetPoint(), 0, 2);
      LCD.drawString("Kp=" + liner.getKp() + " " + "KpDiv=" + liner.getKpDivisor(), 0, 3);
      LCD.drawString("Ki=" + liner.getKi() + " " + "KiDiv=" + liner.getKiDivisor(), 0, 4);
      LCD.drawString("Kd=" + liner.getKd() + " " + "KdDiv=" + liner.getKdDivisor(), 0, 5);
      LCD.drawString("Press orange btn", 0, 6);
      Button.ENTER.waitForPressAndRelease();
   }   
}      



Note that for an accurate comparison you should shut off the NXT between tests. Each test should accurately show the default values before proceeding. The fact that the NXT plays its startup music after running each program does not reflect a reset of the sensor which only happens when the NXT is powered off and then on.

In all previous threads Andy explained that none of the development team members had this particular sensor so could not really do a lot of testing or debugging. Hopefully someone who does have this sensor can see something I'm missing and help. Failing that, I guess I'm elected to thank Andy for all of his work on 0.9.0 and all the help he provides in this forum by sending him one :)

Walt
Walt White
Novice
 
Posts: 44
Joined: Sun Aug 06, 2006 11:57 pm
Location: California Central Valley

Re: 0.9.0 NXTLineLeader problems

Postby MattG » Sun Jul 17, 2011 12:27 pm

Hey Walt,
I just posted some new great work with the NXTLineLeader and Lejos 0.9.
Presenting NXTLineLeader with leJOS 0.9

I read this Thread of course.... and I found your mistake (it cost me some hours :evil:, I thought the class of leJOS 0.9 really doesnt work.... but I found your fault....).

Look at this part of your code in the class Rel090 exactly:

Code: Select all
      liner.setKP(KP);
      liner.setKD(KD);
      liner.setKI(KI);
      liner.setKPDivisor(KPDivisor);
      liner.setKPDivisor(KDDivisor);
      liner.setKPDivisor(KIDivisor);


Look at the last three lines.... you are using three times the same Divisor...
and thats why in ur class the KIDivisor and KDDivsor are always default :shock:

Maybe you should post this information in your older Thread :D

Cheers
Matt
MattG
New User
 
Posts: 4
Joined: Sun Jul 17, 2011 12:06 pm

Re: 0.9.0 NXTLineLeader problems

Postby Walt White » Tue Jul 19, 2011 12:31 am

Matt,

Many thanks for finding the problem. [Bangs head on desk.....duh]

I've been on vacation for a week and need to get caught up on some things, so hopefully by this weekend I can check out your work. Nice to see that someone else is using this sensor. It appeared to have so much potential......just need to keep from making stupid "cut & paste without thinking" errors.

Walt
Walt White
Novice
 
Posts: 44
Joined: Sun Aug 06, 2006 11:57 pm
Location: California Central Valley


Return to NXJ Software

Who is online

Users browsing this forum: No registered users and 0 guests

more stuff