> For the complete documentation index, see [llms.txt](https://docs.revrobotics.com/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.revrobotics.com/duo-control/hello-robot-blocks/part-3/autonomous-navigation-blocks/turning-the-drivetrain-using-run_to_position.md).

# Turning the Drivetrain Using RUN\_TO\_POSITION

Often times, like in the program created during [Part 2: Robot Control](/duo-control/hello-robot-blocks/part-2.md), we use the ![](/files/iyrTK3g728cFKdP6epwm) block to set the drivetrain motors to a set power or power based on a joystick's inputs. The combined power going to both motors help to determine the direction the robot moves or turns.&#x20;

However, in `RUN_TO_POSITION` mode the encoder counts are used instead of <img src="/files/-MVwRA9auYOOqnGmzAX7" alt="" data-size="original"> to dictate directionality of the motor.&#x20;

* [x] If a target position value is greater than the current position of the encoder, the motor moves forward.
* [x] If the target position value is less than the current position of the encoder, the motor moves backwards.

Since speed an directionality impacts how a robot turns, target position and velocity need to be edited to get the robot to turn. Consider the following code:&#x20;

<figure><img src="/files/isXK6xNxH5XWvAMhWwpQ" alt=""><figcaption><p>Example encoder code with turning</p></figcaption></figure>

The `rightTarget` has been changed to be a negative target position. Assuming that the encoder starts at zero due to `STOP_AND_RESET_ENCODER` this causes the robot to turn to the right.&#x20;

Notice the velocity is the same for both motors. If you try running this code, you can see that the robot pivots along its center of rotation.&#x20;

To get a wider turn, try changing the velocity so that the right motor is running at a lower velocity than the left motor. Adjust the velocity and target position as needed to get the turn you need.


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter, and the optional `goal` query parameter:

```
GET https://docs.revrobotics.com/duo-control/hello-robot-blocks/part-3/autonomous-navigation-blocks/turning-the-drivetrain-using-run_to_position.md?ask=<question>&goal=<endgoal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is optional and describes the broader end goal you are ultimately trying to accomplish on behalf of the user. GitBook uses it to tailor the answer towards what is most useful for that goal.

The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
