RaidZeroLib
Coroutine robot framework for VEX V5
Loading...
Searching...
No Matches
rz::MotorDevice Class Referencefinal

V5 Smart Motor. Its built-in encoder is exposed as sensors on the same snapshot. More...

#include <MotorDevice.hpp>

Inheritance diagram for rz::MotorDevice:
rz::Device rz::Motor rz::Component

Classes

struct  Config

Public Types

enum class  Cartridge { Red , Green , Blue }

Public Member Functions

 MotorDevice (std::uint8_t port)
 MotorDevice (std::uint8_t port, Config config)
void setVoltage (Voltage voltage) override
 Commands a voltage, clamped to the motor's range. Positive drives the mechanism forward.
bool connected () const override
Sensor< Angle > & encoder () noexcept
 Output shaft angle (after the cartridge).
Sensor< AngularVelocity > & velocity () noexcept
 Output shaft velocity as estimated by the motor.
Public Member Functions inherited from rz::Device
std::uint8_t port () const noexcept
bool deviceConnected () const noexcept
 Whether this tick's read succeeded.
std::uint32_t deviceEpoch () const noexcept
 Increments on every (re)connection.
Public Member Functions inherited from rz::Component
 Component (const Component &)=delete
Component & operator= (const Component &)=delete
 Component (Component &&)=delete
Component & operator= (Component &&)=delete
virtual ~Component ()
std::string_view name () const noexcept
 Used in log and error messages.
Public Member Functions inherited from rz::Motor
 Motor ()=default
 Motor (const Motor &)=delete
Motor & operator= (const Motor &)=delete
 Motor (Motor &&)=delete
Motor & operator= (Motor &&)=delete
virtual ~Motor ()=default

Additional Inherited Members

Static Public Member Functions inherited from rz::Device
static void validatePorts ()
 Throws std::runtime_error if two devices are constructed on the same port.
Static Public Member Functions inherited from rz::Component
static Task runAll ()
 Runs the loop of every component constructed so far, in construction order, until cancelled. rz::robot runs it; tests without rz::robot run it alongside their script.
Protected Member Functions inherited from rz::Device
 Device (std::uint8_t port, std::string_view kind)
 ~Device () override
Protected Member Functions inherited from rz::Component
 Component (std::string_view name)

Detailed Description

V5 Smart Motor. Its built-in encoder is exposed as sensors on the same snapshot.

Member Enumeration Documentation

◆ Cartridge

enum class rz::MotorDevice::Cartridge
strong
Enumerator
Red 

100 rpm

Green 

200 rpm

Blue 

600 rpm

Constructor & Destructor Documentation

◆ MotorDevice() [1/2]

rz::MotorDevice::MotorDevice ( std::uint8_t port)
inlineexplicit

◆ MotorDevice() [2/2]

rz::MotorDevice::MotorDevice ( std::uint8_t port,
Config config )

Member Function Documentation

◆ connected()

bool rz::MotorDevice::connected ( ) const
inlinenodiscardoverridevirtual

Implements rz::Motor.

◆ encoder()

Sensor< Angle > & rz::MotorDevice::encoder ( )
inlinenodiscardnoexcept

Output shaft angle (after the cartridge).

◆ setVoltage()

void rz::MotorDevice::setVoltage ( Voltage voltage)
overridevirtual

Commands a voltage, clamped to the motor's range. Positive drives the mechanism forward.

Implements rz::Motor.

◆ velocity()

Sensor< AngularVelocity > & rz::MotorDevice::velocity ( )
inlinenodiscardnoexcept

Output shaft velocity as estimated by the motor.


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