Sensor de rotación#
Introducción#
The rotation class is used to control and access data from the V5 Rotation Sensor. The Rotation Sensor measures angular position, total rotation, and rotational velocity.
Constructor de clases#
rotation Rotation1 = rotation(
int32_t index,
bool reverse = false );
Instructor de clase#
Destroys the rotation object and releases associated resources.
virtual ~rotation();
Parámetros#
Parámetro |
Tipo |
Descripción |
|---|---|---|
|
|
The Smart Port that the Rotation Sensor is connected to, written as |
|
|
Determines whether the reported angle and position values are reversed:
|
Ejemplos#
// Create a rotation instance in Port 1
rotation Rotation1 = rotation(PORT1);
Funciones de los miembros#
The rotation class includes the following member functions:
setPosition— Sets the current position of the Rotation Sensor.angle— Returns the detected angle of the Rotation Sensor.position— Returns the detected position of the Rotation Sensor.velocity— Returns the detected velocity of the Rotation Sensor.
Before calling any rotation member functions, a rotation instance must be created, as shown below:
// Create a rotation instance in Port 1
rotation Rotation1 = rotation(PORT1);
setPosition#
Sets the position of the Rotation Sensor. The position returned by position is set to this value.
void setPosition(
double value,
rotationUnits units );
Parámetro |
Tipo |
Descripción |
|---|---|---|
|
|
El valor de posición a establecer. |
|
|
The units that represent
|
Esta función no devuelve ningún valor.
angle#
Devuelve el ángulo medido por el sensor de rotación.
Available Functionsdouble angle( rotationUnits units = degrees );
Parámetro |
Tipo |
Descripción |
|---|---|---|
|
|
The unit that represents the angle:
|
Devuelve un valor de tipo double que representa el ángulo medido por el sensor de rotación en las unidades especificadas.
Examples// Get the current angle of the Rotation Sensor
double angle = Rotation1.angle(degrees);
// Print the current angle of the Rotation Sensor to the
// Brain's screen.
Brain.Screen.print(angle);
position#
Devuelve la posición actual del sensor de rotación.
Available Functionsdouble position( rotationUnits units );
Parámetro |
Tipo |
Descripción |
|---|---|---|
|
|
The units that represent the position:
|
Devuelve un valor de tipo double que representa la posición actual del sensor de rotación en las unidades especificadas.
velocity#
Devuelve la velocidad del sensor de rotación.
Available Functionsdouble velocity( velocityUnits units );
Parámetro |
Tipo |
Descripción |
|---|---|---|
|
|
The unit that represents the detected velocity:
|
Devuelve un valor de tipo double que representa la velocidad del sensor de rotación en las unidades especificadas.