Repository navigation
Conversation
JakubVanek
left a comment
There was a problem hiding this comment.
Hi,
I can not see the diff for BaseRegulatedMotor - the whole file shows as deleted and recreated. This could be due to different line endings. However this makes the review quite hard to make, so I cannot yet approve (and it breaks git history/blame).
Jakub
|
You are right, I will upload again the change, meanwhile, I will refactor the example. |
|
I have fixed the diff, refactored the code and changed the version to However I think I found an issue with this polarity approach. Will calling package example;
import ev3dev.actuators.lego.motors.EV3LargeRegulatedMotor;
import lejos.hardware.port.MotorPort;
import lejos.robotics.RegulatedMotor;
import lejos.utility.Delay;
import lombok.extern.slf4j.Slf4j;
@Slf4j
class FwdBwdRotateTest {
public static void main(String[] args) {
LOGGER.info("Initializing motor class");
RegulatedMotor motor = new EV3LargeRegulatedMotor(MotorPort.A);
LOGGER.info("Set motor speed");
motor.setSpeed(360);
LOGGER.info("Move motor forward for 1 second");
motor.forward();
Delay.msDelay(1000);
LOGGER.info("Stop the motor and wait 0,5 seconds");
motor.stop();
Delay.msDelay(500);
LOGGER.info("Calling rotate(360) - should move forward, i.e. in the same direction as the last move");
motor.rotate(360, false);
LOGGER.info("Move motor backward for 1 second");
motor.backward();
Delay.msDelay(1000);
LOGGER.info("Stop the motor and wait 0,5 seconds");
motor.stop();
Delay.msDelay(500);
LOGGER.info("Calling rotate(360) - should move forward, i.e. in the oppposite direction to the last move");
motor.rotate(360, false);
}
}Behaviour that I would expect on leJOS:
Behaviour that I suspect would happen on ev3dev-lang-java:
I think this will happen because kernel will take the motor as |
|
I have also found this:
|
JakubVanek
left a comment
There was a problem hiding this comment.
It is necessary to check if the current solution works when combining forward() with rotate().
|
package example;
import ev3dev.actuators.lego.motors.EV3LargeRegulatedMotor;
import lejos.hardware.port.MotorPort;
import lejos.robotics.RegulatedMotor;
import lejos.utility.Delay;
import lombok.extern.slf4j.Slf4j;
@Slf4j
class FwdBwdRotateToTest {
public static void main(String[] args) {
LOGGER.info("Initializing motor class");
RegulatedMotor motor = new EV3LargeRegulatedMotor(MotorPort.A);
LOGGER.info("Set motor speed");
motor.setSpeed(360);
LOGGER.info("Move motor forward for 1 second");
motor.forward();
Delay.msDelay(1000);
LOGGER.info("Stop the motor and wait 0,5 seconds");
motor.stop();
Delay.msDelay(500);
LOGGER.info("Calling rotateTo(360)");
motor.rotateTo(360, false);
LOGGER.info("Move motor backward for 0,1 second");
motor.backward();
Delay.msDelay(100);
LOGGER.info("Stop the motor and wait 0,5 seconds");
motor.stop();
Delay.msDelay(500);
LOGGER.info("Calling rotateTo(360) - motor should move forward a little bit");
motor.rotateTo(360, false);
}
}Behaviour that I would expect on leJOS:
|
|
Good analysis Jakub, I will test with the examples today |
|
Test 1 (FwdBwdRotateTest) failed. Motor has rotated in the B direction, so usage of |
|
Test 2 (FwdBwdRotateToTest) failed. Motor has moved in the B direction, so it probably aimed at Updated source code: package example;
import ev3dev.actuators.lego.motors.EV3LargeRegulatedMotor;
import lejos.hardware.port.MotorPort;
import lejos.robotics.RegulatedMotor;
import lejos.utility.Delay;
import lombok.extern.slf4j.Slf4j;
@Slf4j
class FwdBwdRotateToTest {
public static void main(String[] args) {
LOGGER.info("Initializing motor class");
RegulatedMotor motor = new EV3LargeRegulatedMotor(MotorPort.A);
LOGGER.info("Set motor speed");
motor.hold();
motor.setSpeed(360);
LOGGER.info("Move motor forward for 1 second");
motor.forward();
Delay.msDelay(1000);
motor.stop();
Delay.msDelay(500);
LOGGER.info("Calling rotateTo(360)");
motor.rotateTo(360, false);
Delay.msDelay(500);
motor.stop();
Delay.msDelay(500);
LOGGER.info("Move motor backward for 0,5 second");
motor.backward();
Delay.msDelay(500);
motor.stop();
Delay.msDelay(500);
LOGGER.info("Calling rotateTo(360) - motor should move forward a little bit");
motor.rotateTo(360, false);
Delay.msDelay(500);
motor.stop();
}
} |
|
Alternative solution: #689 |

Fixed and tested on an EV3 Brick with a motor.
The solution is fine for me.