Bug:NXTRegulatedMotor/DifferentialPilot

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

Moderators: roger, 99jonathan, imaqine

Bug:NXTRegulatedMotor/DifferentialPilot

Postby PallottiSoccerPLayer » Sat Feb 09, 2013 8:36 pm

Hi,

programming our soccer-robot we found an annoying problem. It has not been mentioned here before, I think:

NXTRegulatedMotor.class will accelerate the motors if they are blocked. But afterwards, they won't slow down again.
As this class is used by the DifferentialPilot, there occurs the same problem.

If you aren't careful, some programs will cause the robot to spin around very fast once he encountered an obstacle.
A simple example:
Code: Select all
import lejos.nxt.Button;
import lejos.nxt.Motor;
import lejos.robotics.navigation.DifferentialPilot;

public class Pilottest {
   
   public static void main(String[] args) {
       DifferentialPilot dp = new DifferentialPilot (8.35, 9.52, Motor.B, Motor.C, false);     
      
      dp.setRotateSpeed(50);
      
      while (!Button.ESCAPE.isDown())
         dp.rotateLeft();
   }
}


The code has to be modified like this to provide a constant low speed, even if the robot is stopped for a moment by an obstacle:
Code: Select all
import lejos.nxt.Button;
import lejos.nxt.Motor;
import lejos.robotics.navigation.DifferentialPilot;

public class Pilottest {
   
   public static void main(String[] args) {
       DifferentialPilot dp = new DifferentialPilot (8.35, 9.52, Motor.B, Motor.C, false);     
      
      while (!Button.ESCAPE.isDown()){
         dp.setRotateSpeed(50);
         dp.rotateLeft();
      }
         
   }
}


In this example the program applies (?? sry, I don't know the right English word) the speed in every turn. Therefore the robot slows down to the prescribed speed of "50", even if the NXTRegulatedMotors boost the speed a moment before because of an obstacle. And so the robot won't spin around in an abnormal high speed to overpower an obstacle that has already vanished.

In the end we fixed it by changing our code as shown in example 2. But we were thinking whether it wouldn't make sense to change the source code in a way, which will cause the NXTRegulatedMotors to turn the power down as soon as they are moving again. Maybe you have to rewrite parts of the Move.class to change this behavior, but we didn't investigate that far.
At least the problem should be mentioned in the API-documentation, shouldn't it?

It would be nice, if someone adopts our suggestion and fixes this problem.

Greetings from Rheinbach
PallottiSoccerPLayer
New User
 
Posts: 5
Joined: Sat Feb 09, 2013 6:21 pm

Re: Bug:NXTRegulatedMotor/DifferentialPilot

Postby gloomyandy » Sat Feb 09, 2013 9:22 pm

Hi,
it is not a good idea to repeatedly call methods like rotateLeft etc. Every time you make that call it will reset various parameters (like acceleration), and restart the motor move. There is no need to keep on calling rotateLeft, once you have called it the robot will continue to rotate until you stop it. I'm not sure if this is causing the problems you are seeing, but it will not be helping. If changing this does not help please post back giving details of how to reproduce the problem you are seeing...

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

Re: Bug:NXTRegulatedMotor/DifferentialPilot

Postby PallottiSoccerPLayer » Sun Feb 10, 2013 12:44 pm

Thanks for your quick answer.

Example 1 of the upper post shows how to reproduce the problem. I reduced the program to a necessary minimum. Be assured, that in our original program it is almost unavoidable to keep calling rotateLeft (there are of course larger loops and more conditions/distinction of cases).
Besides, (to be honest) we don't program as in example 2. We wrote an own pilot.class by using MotorPort.class to avoid the problem successfully.

At the moment, I'm not able to test the robot. But I think the following program should also reproduce the problem:
Code: Select all
import lejos.nxt.Button;
import lejos.nxt.Motor;
import lejos.robotics.navigation.DifferentialPilot;
import lejos.util.Delay;

    public class Pilottest {
       
       public static void main(String[] args) {
           DifferentialPilot dp = new DifferentialPilot (8.35, 9.52, Motor.B, Motor.C, false);     
         
          dp.setRotateSpeed(50);
          dp.rotateLeft();
          Delay.msDelay(10000);
          }
     }

-> I expect the robot to accelerate, once he faced an obstacle (due to the properties of NXTRegulatedMotor.class). I would be surprised if the robot decelerates after the obstacle vanished. In our previous testing (with other programs and repeatedly calling of rotateLeft) the robot did not slow down again...

But as you supposed,we’re going to test this on Wednesday. I'm curious, whether the problem can be avoided by reducing the callings of rotateLeft.

Andi :)
PallottiSoccerPLayer
New User
 
Posts: 5
Joined: Sat Feb 09, 2013 6:21 pm

Re: Bug:NXTRegulatedMotor/DifferentialPilot

Postby PallottiSoccerPLayer » Sun Feb 17, 2013 7:40 pm

Apperently I can not reproduce the error. With none of my examples :? Very strange matter. Next time I'm going to test it with my current soccer programm and the DifferentialPilot instead of my self-written pilot. Perhaps it is because of something else (sensors?), and the code needs to be more complicated...
PallottiSoccerPLayer
New User
 
Posts: 5
Joined: Sat Feb 09, 2013 6:21 pm


Return to NXJ Software

Who is online

Users browsing this forum: Google [Bot] and 5 guests

more stuff