I have problem with regulation of the motor when I control EV3 with Bluetooth. Here is the code:
RemoteEV3 ev3 = new RemoteEV3("10.0.1.1");
ev3.setDefault();
RMIRegulatedMotor leftMotor = ev3.createRegulatedMotor("A", 'L');
RMIRegulatedMotor rightMotor = ev3.createRegulatedMotor("B", 'L');
EV3ColorSensor color_sensor = new EV3ColorSensor(SensorPort.S2);
int color_id = color_sensor.getColorID();
while(color_id!=7){
leftMotor.setSpeed(300);
rightMotor.setSpeed(300);
leftMotor.setAcceleration(1000);
rightMotor.setAcceleration(1000);
leftMotor.backward();
rightMotor.backward();
Delay.msDelay(500);
leftMotor.stop(true);
rightMotor.stop(true);
color_id = color_sensor.getColorID();
}
System.out.println("Establishing connection. Please wait ...");
if(leftMotor!=null) leftMotor.close();
if(rightMotor!=null) rightMotor.close();
if(color_sensor!=null) color_sensor.close();
The problem is that the EV3's motor not continuously moving. It is stop a bit and then continue moving, it is kinda lagging or problems with regulation of RMIRegulatedMotor. However, if I change from RMIRegulatedMotor to RegulatedMotor and compile it directly with the brick not Bluetoothm, there is no problem at all.
stop
out of thewhile
loop, then the motors would keep running until the colour id was 7.