Answers.Body: <p>Looking at your code, you're saying:</p>
  
  <ol>
  <li>Set the motors to a speed of 300, acceleration of 1000</li>
  <li>Run the motors backwards</li>
  <li>Pause execution of your program for 500ms</li>
  <li>Stop the motors </li>
  <li>If you're not seeing colour id 7, go to 1.</li>
  </ol>
  
  <p>Assuming that this was exactly the same code you had on the Brick, I'd guess the delays introduced by the communication will cause a stuttery motion that you might not notice when running it on the device.</p>
  
  <p>If you pulled the following lines out of your <code>while</code> loop things would probably be smoother:</p>
  
  <pre><code>leftMotor.stop(true);
  rightMotor.stop(true);
  </code></pre>
  
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2014-11-05T15:21:14.010Z
Answers.LastActivityDate: 2014-11-05T15:21:14.010Z
Answers.UserDisplayName: Zhaph - Ben Duguid
Body: <p>I have problem with regulation of the motor when I control EV3 with Bluetooth.
  Here is the code:</p>
  
  <pre><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();
  </code></pre>
  
  <p>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.</p>
  
Comments.ContentLicense: CC BY-SA 3.0
Comments.CreationDate: 2014-11-04T09:40:20.043Z
Comments.Text: Looking at your code, you're telling the motors to go at a speed of 300, then pause execution for 500ms, then you're telling the motors to stop, before continuing around again. Due to delays in communication you'll probably find that this will cause a stuttery motion that you might not notice when running it on the device.
Comments.UserDisplayName: Zhaph - Ben Duguid
Comments.ContentLicense: CC BY-SA 3.0
Comments.CreationDate: 2014-11-04T09:41:38.163Z
Comments.Text: Perhaps if you moved the calls to `stop` out of the `while` loop, then the motors would keep running until the colour id was 7.
Comments.UserDisplayName: Zhaph - Ben Duguid
Comments.ContentLicense: CC BY-SA 3.0
Comments.CreationDate: 2014-11-04T14:41:00.760Z
Comments.Text: I am so stupid with this function. Thank for your suggestion.
Comments.UserDisplayName: Phav Makara
Comments.ContentLicense: CC BY-SA 3.0
Comments.CreationDate: 2014-11-04T15:39:00.267Z
Comments.Text: Pair programming for the win - often it just needs another pair of eyes ;)
Comments.UserDisplayName: Zhaph - Ben Duguid
Tags: <ev3><programming><motor><remote-control><lejos>
Title: EV3 RMIregulatedMotor Regulation Problems
UserDisplayName: Phav Makara
ThreadText: # EV3 RMIregulatedMotor Regulation Problems
  
  (Asked by: username_0 on 2014-11-04)
  
  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.
  
  **Tags:** ev3, programming, motor, remote-control, lejos
  
  > **Comments:**
  > **username_1**: Looking at your code, you're telling the motors to go at a speed of 300, then pause execution for 500ms, then you're telling the motors to stop, before continuing around again. Due to delays in communication you'll probably find that this will cause a stuttery motion that you might not notice when running it on the device.  
  > **username_1**: Perhaps if you moved the calls to `stop` out of the `while` loop, then the motors would keep running until the colour id was 7.  
  > **username_0**: I am so stupid with this function. Thank for your suggestion.  
  > **username_1**: Pair programming for the win - often it just needs another pair of eyes ;)  
  
  ---
  
  ## 1 answers
  
  ### Answer by username_1 on 2014-11-05. Score: 1 | Accepted answer
  
  Looking at your code, you're saying:
  
  1. Set the motors to a speed of 300, acceleration of 1000
  2. Run the motors backwards
  3. Pause execution of your program for 500ms
  4. Stop the motors
  5. If you're not seeing colour id 7, go to 1.
  
  Assuming that this was exactly the same code you had on the Brick, I'd guess the delays introduced by the communication will cause a stuttery motion that you might not notice when running it on the device.
  
  If you pulled the following lines out of your `while` loop things would probably be smoother:
  
  ```
  leftMotor.stop(true);
  rightMotor.stop(true);
  
  ```
  
  
  ---
  
  