Wyatt  1.0.1
Public Member Functions | List of all members
EncoderAdapter Class Reference

#include <EncoderAdapter.h>

Inheritance diagram for EncoderAdapter:
Inheritance graph
[legend]
Collaboration diagram for EncoderAdapter:
Collaboration graph
[legend]

Public Member Functions

 EncoderAdapter (int channelA, int channelB, int ticksPerRev, Hardware hardware)
 
 ~EncoderAdapter () override
 
void * run () override
 
long getCount ()
 
void resetCount ()
 
double getSpeedRPM ()
 
std::list< IMessage * > * read () override
 
void write (IMessage *message) override
 
- Public Member Functions inherited from Thread
int start ()
 
int join ()
 
int detach ()
 
void signal (int signal)
 
pthread_t self ()
 
- Public Member Functions inherited from IHardwareInterface
virtual ~IHardwareInterface ()
 

Additional Inherited Members

- Protected Attributes inherited from Thread
std::atomic< int > m_signal
 

Detailed Description

Hardware adapter for the Pololu encoders. This class polls pins on the RaspberryPi, counts the number of ticks, and translates this data into a specific RPM. Periodically, the communicator requests the current RPM of the encoders to inject it into the EncoderSensor object. TODO: This class should translate the data into a specific velocity in cm/s

Definition at line 21 of file EncoderAdapter.h.

Constructor & Destructor Documentation

EncoderAdapter::EncoderAdapter ( int  channelA,
int  channelB,
int  ticksPerRev,
Hardware  hardware 
)

Counts a two-channel encoder.

Parameters
channelAWiringPi Pin for channel A.
channelBWiringPi Pin for channel B.
ticksPerRevNumber of ticks per revolution on this encoder.

Definition at line 4 of file EncoderAdapter.cpp.

EncoderAdapter::~EncoderAdapter ( )
override

Destructs the encoder counter.

Definition at line 19 of file EncoderAdapter.cpp.

Member Function Documentation

long EncoderAdapter::getCount ( )

Get the current count from the encoder.

Returns
a long, the encoder count (+/-)

Definition at line 62 of file EncoderAdapter.cpp.

double EncoderAdapter::getSpeedRPM ( )

Get the encoder current speed in RPM.

Returns
A speed in RPM.

Definition at line 81 of file EncoderAdapter.cpp.

std::list< IMessage * > * EncoderAdapter::read ( )
overridevirtual

Read a list containing a message with the current encoder count for this encoder, and a message with the current speed.

Returns
A message list object containing the count/speed for this encoder.

Implements IHardwareInterface.

Definition at line 72 of file EncoderAdapter.cpp.

void EncoderAdapter::resetCount ( )

Reset the encoder count to 0.

Definition at line 67 of file EncoderAdapter.cpp.

void * EncoderAdapter::run ( )
overridevirtual

Runs the encoder counter worker thread.

Returns
nothing

Implements Thread.

Definition at line 24 of file EncoderAdapter.cpp.

void EncoderAdapter::write ( IMessage msg)
inlineoverridevirtual

Write a message to the peripheral. Deletes the message pointer.

Parameters
msgA Message to be sent

Implements IHardwareInterface.

Definition at line 62 of file EncoderAdapter.h.


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