This is my first post and i'm still new in lejos and NXT.
I use the 0.9.0 release version of lejos and so far it works fine. I love to be able to use OOP on a NXT!
But now i'm facing a problem:
My robot project includes several Motors, some are directly connected to NXT, others throw a multiplexer(mindsensors).
I need a solution to detect two physical/hard-limits (positiveLimit and negativeLimit for each motor), get the center(middle) position and store the values.
I'm looking forward to use ONE implementation for both motor types: NXTRegulated and MMXRegulatedMotor.
I've tried to use the RegulatedMotor interface and came up with this solution:
- Code: Select all
public class MotorAdjustor {
private RegulatedMotor _motor;
private boolean _isAdjusted;
private int _positiveLimit;
private int _negativeLimit;
private int _middle;
public MotorAdjustor(RegulatedMotor motor)
{
_motor = motor;
}
public void Adjust(int positiveLimitMaxSpeedDivider, int negativeLimitMaxSpeedDivider) throws Exception
{
_motor.resetTachoCount();
_motor.setSpeed((int)_motor.getMaxSpeed()/positiveLimitMaxSpeedDivider);
_motor.rotate(360,false);
Thread.sleep(150);
_positiveLimit = _motor.getLimitAngle();
Thread.sleep(1000);
_motor.setSpeed((int)_motor.getMaxSpeed()/negativeLimitMaxSpeedDivider);
Thread.sleep(150);
_motor.rotate(-360,false);
Thread.sleep(150);
_negativeLimit = _motor.getLimitAngle();
_middle = (_negativeLimit + _positiveLimit) / 2;
_motor.rotateTo(_middle);
LCD.drawString("p:" + _positiveLimit, 0, 3);
LCD.drawString("n:" + _negativeLimit, 0, 4);
LCD.drawString("m:" + _middle, 0, 5);
_motor.flt();
Thread.sleep(10000);
}
public boolean isAdjustd()
{
return _isAdjusted;
}
public int getPositiveLimit()
{
return _positiveLimit;
}
public int getMiddle()
{
return _middle;
}
public int getNegativeLimit()
{
return _negativeLimit;
}
}
It works in general but one of the motors are heavier to move and stops before reaching the limit.
I tried different speed and acceleration settings but always get simular results.
Questions:
Is it possible at all to change the sensivity of the Motors with RegulatedMotor class?
If not, which implementation can i use to complete the task?
Is the sensivity of motors influenced by speed or accelaration at all?
Have someone do simular stuff with lejos or have sources with further information on this?
As you can see, i'm a little stuck with this and looking forward to get some advises.
best regards,
cracky^^
