Brick
Loading...
Searching...
No Matches
crust::Rotation Class Reference

#include <rotation.h>

Description

Class implementing the V5 Rotation Sensor.

Provides functions for getting angle (wrapped), position (continuous), and angular velocity. The sensor is able to be reversed, and its position can be set.

Inheritance diagram for crust::Rotation:

Public Member Functions

 Rotation (int port, bool reversed=false)
 Constructs a Rotation Sensor.
Rotation2d angle () const
 Gets the shaft's absolute orientation within one revolution.
units::Angle position () const
 Gets the shaft's accumulated rotation relative to the current zero point.
units::AngularVelocity velocity () const
 Gets the shaft's angular velocity.
void set_position (units::Angle position)
 Sets the accumulated position to a continuous units::Angle.
void set_position (Rotation2d position)
 Sets the accumulated position to a wrapped Rotation2d.
void reset_position ()
 Sets the accumulated position to zero.
void set_reversed (bool reversed)
 Configures the direction reported.
bool reversed () const
 Gets the sensor's reversal flag.
Public Member Functions inherited from crust::Device
int port () const
 Gets the physical Smart Port number.
bool installed () const
 Checks whether the expected device is currently connected.

Additional Inherited Members

Protected Member Functions inherited from crust::Device
 Device (int port, int expected_type)
 Resolves and caches the C SDK handle for a physical Smart Port.
 ~Device ()=default
 Destroys the device.
_V5_Device * handle () const
 Provides the device handle associated with this port.

Constructor & Destructor Documentation

◆ Rotation()

crust::Rotation::Rotation ( int port,
bool reversed = false )
explicit

Constructs a Rotation Sensor.

Parameters
portPhysical Smart Port number [1, 21].
reversedTrue to reverse the reported direction.

Member Function Documentation

◆ angle()

Rotation2d crust::Rotation::angle ( ) const

Gets the shaft's absolute orientation within one revolution.

Returns
Wrapped orientation represented by a Rotation2d.
Note
set_position() does not affect this value! The offset for this function can be set manually in the brain's devices tab.

◆ position()

units::Angle crust::Rotation::position ( ) const

Gets the shaft's accumulated rotation relative to the current zero point.

Returns
Continuous units::Angle that can span multiple revolutions.

◆ reset_position()

void crust::Rotation::reset_position ( )

Sets the accumulated position to zero.

Note
Does not change the result of angle().

◆ reversed()

bool crust::Rotation::reversed ( ) const

Gets the sensor's reversal flag.

Returns
True if sensor is reversed.

◆ set_position() [1/2]

void crust::Rotation::set_position ( Rotation2d position)

Sets the accumulated position to a wrapped Rotation2d.

Parameters
positionvalue to set.
Note
Rounds to the nearest 0.01 degree, wraps a rounded full revolution to zero. Does not change the result of angle().

◆ set_position() [2/2]

void crust::Rotation::set_position ( units::Angle position)

Sets the accumulated position to a continuous units::Angle.

Parameters
positionvalue to set.
Note
Rounds to the nearest 0.01 degree for the C SDK. Does not change the result of angle().

◆ set_reversed()

void crust::Rotation::set_reversed ( bool reversed)

Configures the direction reported.

Parameters
reversedTrue to reverse the sensor.

◆ velocity()

units::AngularVelocity crust::Rotation::velocity ( ) const

Gets the shaft's angular velocity.

Returns
units::AngularVelocity.

The documentation for this class was generated from the following file: