Answers.Body: <p>Control loops. The builtin RotateMotor commands are very imprecise. Have a look at this file for a nice library that makes skid steer vehicles turn very precisely:</p>
  
  <p><a href="https://www.dropbox.com/s/o31qaxx0glx4m3x/Instacode.h?dl=0" rel="nofollow">https://www.dropbox.com/s/o31qaxx0glx4m3x/Instacode.h?dl=0</a></p>
  
  <p>You'll need to adjust the constants at the top of the file.</p>
  
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2015-03-29T13:32:12.687Z
Answers.LastActivityDate: 2015-03-29T13:32:12.687Z
Answers.UserDisplayName: Thaddeus Hughes
Answers.Body: <p>This depends on the exact configuration of your robot, including but not limited to the distance between the wheels (if it's a differential drive robot), the diameters of the wheels, the gearing (if any is used) between the motors and the wheels.</p>
  
  <p>A simple solution would be to experiment with various parameters and making corrections based on the direction and magnitude of the observed error. For example, if you send an order of <code>RotateMotor(100)</code> and see that your robot turns about 30°, you would try again with <code>RotateMotor(300)</code>.</p>
  
  <p>Another possible solution is to write a program that displays the values read from the motors' encoders, perform the required maneuvers by pushing the robot by hand, and noting the displayed values. In theory, those values would be the ideal parameters.</p>
  
  <p>Of course, the most sound and correct solution is to whip out your geometry skills and calculate the exact angle the motors need to turn, but this approach tends to fail when reality does not behave perfectly (as in skidding, measurement errors, friction, etc.)</p>
  
  <p>All in all, I'd recommend picking a starting value, trying it on your robot, observing the results, making adjustments based on the observations and starting over the loop.</p>
  
  <p>For reference (if you hadn't already found it): <a href="http://bricxcc.sourceforge.net/nbc/nxcdoc/nxcapi/group___output_module_functions_gab638baa46cfa84602c8517d9ed9b36ae.html" rel="nofollow">NXC RotateMotor command</a></p>
  
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2015-02-04T10:51:23.480Z
Answers.LastActivityDate: 2015-02-04T10:51:23.480Z
Answers.UserDisplayName: zovits
Body: <p>How can I program, with NXC, a Lego NXT to turn a specific angle? </p>
  
  <p>I've tried using <code>wait()</code> but the problem isn't solved.</p>
  
  <p>Can I use <code>RotateMotor()</code>? What parameters should I use? For example if I want it to move in a square, what kind of parameters.</p>
  
Tags: <nxt><nxc>
Title: How to turn the NXT at an angle with NXC
UserDisplayName: FDuarte
ThreadText: # How to turn the NXT at an angle with NXC
  
  (Asked by: username_0 on 2015-02-03)
  
  How can I program, with NXC, a Lego NXT to turn a specific angle?
  
  I've tried using `wait()` but the problem isn't solved.
  
  Can I use `RotateMotor()`? What parameters should I use? For example if I want it to move in a square, what kind of parameters.
  
  **Tags:** nxt, nxc
  
  
  ---
  
  ## 2 answers
  
  ### Answer by username_1 on 2015-03-29. Score: 1
  
  Control loops. The builtin RotateMotor commands are very imprecise. Have a look at this file for a nice library that makes skid steer vehicles turn very precisely:
  
  <https://www.dropbox.com/s/o31qaxx0glx4m3x/Instacode.h?dl=0>
  
  You'll need to adjust the constants at the top of the file.
  
  
  ---
  
  ### Answer by username_2 on 2015-02-04. Score: 1
  
  This depends on the exact configuration of your robot, including but not limited to the distance between the wheels (if it's a differential drive robot), the diameters of the wheels, the gearing (if any is used) between the motors and the wheels.
  
  A simple solution would be to experiment with various parameters and making corrections based on the direction and magnitude of the observed error. For example, if you send an order of `RotateMotor(100)` and see that your robot turns about 30°, you would try again with `RotateMotor(300)`.
  
  Another possible solution is to write a program that displays the values read from the motors' encoders, perform the required maneuvers by pushing the robot by hand, and noting the displayed values. In theory, those values would be the ideal parameters.
  
  Of course, the most sound and correct solution is to whip out your geometry skills and calculate the exact angle the motors need to turn, but this approach tends to fail when reality does not behave perfectly (as in skidding, measurement errors, friction, etc.)
  
  All in all, I'd recommend picking a starting value, trying it on your robot, observing the results, making adjustments based on the observations and starting over the loop.
  
  For reference (if you hadn't already found it): [NXC RotateMotor command](http://bricxcc.sourceforge.net/nbc/nxcdoc/nxcapi/group___output_module_functions_gab638baa46cfa84602c8517d9ed9b36ae.html)
  
  
  ---
  
  