旋转传感器#
介绍#
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.
类构造函数#
rotation Rotation1 = rotation(
int32_t index,
bool reverse = false );
类析构函数#
Destroys the rotation object and releases associated resources.
virtual ~rotation();
参数#
范围 |
类型 |
描述 |
|---|---|---|
|
|
The Smart Port that the Rotation Sensor is connected to, written as |
|
|
Determines whether the reported angle and position values are reversed:
|
示例#
// Create a rotation instance in Port 1
rotation Rotation1 = rotation(PORT1);
成员功能#
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 );
范围 |
类型 |
描述 |
|---|---|---|
|
|
要设置的位置值。 |
|
|
The units that represent
|
此函数不返回值。
angle#
返回旋转传感器测量的角度。
Available Functionsdouble angle( rotationUnits units = degrees );
范围 |
类型 |
描述 |
|---|---|---|
|
|
The unit that represents the angle:
|
返回一个双精度浮点数,表示旋转传感器以指定单位测量的角度。
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#
返回旋转传感器的当前位置。
Available Functionsdouble position( rotationUnits units );
范围 |
类型 |
描述 |
|---|---|---|
|
|
The units that represent the position:
|
返回一个双精度浮点数,表示旋转传感器的当前位置,单位为指定单位。
velocity#
返回旋转传感器的速度。
Available Functionsdouble velocity( velocityUnits units );
范围 |
类型 |
描述 |
|---|---|---|
|
|
The unit that represents the detected velocity:
|
返回一个双精度浮点数,表示旋转传感器的速度,单位为指定单位。