LightLib
PROS library for VEX V5: EKF/MCL localization, RAMSETE path following, high-level chassis API
Loading...
Searching...
No Matches
okapi::RotationSensor Class Reference

#include <rotationSensor.hpp>

Inheritance diagram for okapi::RotationSensor:
okapi::ContinuousRotarySensor okapi::RotarySensor okapi::ControllerInput< double >

Public Member Functions

 RotationSensor (std::uint8_t iport, bool ireversed=false)
 A rotation sensor in a V5 port.
 
double get () const override
 Get the current rotation in degrees.
 
std::int32_t reset () override
 Reset the sensor to zero.
 
double controllerGet () override
 Get the sensor value for use in a control loop.
 
double getVelocity () const
 Get the current rotational velocity estimate in degrees per second.
 
- Public Member Functions inherited from okapi::RotarySensor
virtual ~RotarySensor ()
 

Protected Attributes

std::uint8_t port
 
std::int8_t reversed {1}
 

Detailed Description

Definition at line 12 of file rotationSensor.hpp.

Constructor & Destructor Documentation

◆ RotationSensor()

okapi::RotationSensor::RotationSensor ( std::uint8_t  iport,
bool  ireversed = false 
)

A rotation sensor in a V5 port.

auto r = RotationSensor(1);
auto reversedR = RotationSensor(1, true);
Parameters
iportThe V5 port the device uses.
ireversedWhether the sensor is reversed. This will set the reversed state in the kernel.

Member Function Documentation

◆ controllerGet()

double okapi::RotationSensor::controllerGet ( )
overridevirtual

Get the sensor value for use in a control loop.

This method might be automatically called in another thread by the controller.

Returns
The same as get.

Implements okapi::ControllerInput< double >.

◆ get()

double okapi::RotationSensor::get ( ) const
overridevirtual

Get the current rotation in degrees.

Returns
The current rotation in degrees or PROS_ERR_F if the operation failed, setting errno.

Implements okapi::RotarySensor.

◆ getVelocity()

double okapi::RotationSensor::getVelocity ( ) const

Get the current rotational velocity estimate in degrees per second.

Returns
The current rotational velocity estimate in degrees per second or PROS_ERR_F if the operation failed, setting errno.

◆ reset()

std::int32_t okapi::RotationSensor::reset ( )
overridevirtual

Reset the sensor to zero.

Returns
1 if the operation was successful or PROS_ERR if the operation failed, setting errno.

Implements okapi::ContinuousRotarySensor.

Member Data Documentation

◆ port

std::uint8_t okapi::RotationSensor::port
protected

Definition at line 61 of file rotationSensor.hpp.

◆ reversed

std::int8_t okapi::RotationSensor::reversed {1}
protected

Definition at line 62 of file rotationSensor.hpp.


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