Rotation Sensor#
Introduction#
The V5 Rotation Sensor measures precise rotational movement, position, and speed relative to its position on the robot.

This page uses rotation_sensor as the example Rotation Sensor name. Replace it with your own configured name as needed.
Below is a list of available methods:
set_position– Sets the current position of the Rotation Sensor to a specific value.angle– Returns the current angle of the sensor between 0 and 359.99 degrees.position– Returns the total rotational position in degrees or turns.velocity– Returns how fast the sensor is rotating.reset_position– Sets the current position of the Rotation Sensor to 0.set_reversed– Inverts the Rotation Sensor output so positive values become negative, and negative values become positive. This method works the same as setting thereverseparameter toTruewhen using theRotationconstructor.changed– Registers a function to be called whenever whenever the Rotation Sensor’s value changes.
Constructor – Manually initialize a Rotation Sensor.
Rotation– Creates a Rotation Sensor.
set_position#
set_position sets the current position of the Rotation Sensor to a value in degrees.
Usage:
rotation_sensor.set_position(position, units)
Parameters |
Description |
|---|---|
position |
The position to set the Rotation Sensor to. |
units |
Optional. The unit of measurement:
|
# Set the Rotation Sensor to 2.5 Turns
rotation_sensor.set_position(2.5, TURNS)
angle#
angle returns the current angle of the sensor as a float.
Usage:
rotation_sensor.angle(units)
Parameters |
Description |
|---|---|
units |
Optional. The unit of measurement:
|
position#
position returns the total rotational position.
Usage:
rotation_sensor.position(units)
Parameters |
Description |
|---|---|
units |
Optional. The unit of measurement:
|
velocity#
velocity returns how fast the sensor is rotating.
Usage:
rotation_sensor.velocity(units)
Parameters |
Description |
|---|---|
units |
The unit of measurement:
|
reset_position#
reset_position sets the current position of the Rotation Sensor to 0.
Usage:
rotation_sensor.reset_position()
Parameters |
Description |
|---|---|
This method has no parameters. |
set_reversed#
set_reversed inverts the Rotation Sensor output so positive values become negative, and negative values become positive. This method works the same as setting the reverse parameter to True when using the Rotation constructor.
Usage:
motor_1.set_reversed(value)
Parameters |
Description |
|---|---|
|
Boolean value to set the direction reversed or not:
|
changed#
changed registers a function to be called whenever the Rotation Sensor’s value changes.
Usage:
rotation_sensor.changed(callback, arg)
Parameters |
Description |
|---|---|
|
A previously defined function that executes when the Rotation Sensor’s value changes. |
|
Optional. A tuple containing arguments to pass to the callback function. See Using Functions with Parameters for more information. |
def my_function():
brain.screen.print("Rotated!")
# Call my_function whenever rotation_sensor's value changes
rotation_sensor.changed(my_function)
Constructor#
Constructors are used to manually create Rotation objects, which are necessary for configuring a Rotation Sensor outside of VEXcode.
Rotation#
Rotation creates a Rotation Sensor.
Usage:
Rotation(smartport)
Parameter |
Description |
|---|---|
|
The Smart Port that the Rotation Sensor is connected to, written as |
|
Optional. Sets whether the Rotation Sensor’s output should be inverted.
|
# Create an inverted Rotation Sensor in Port 10
rotation_sensor = Rotation(Ports.PORT10, True)