Wyatt
1.0.1
|
#include <EncoderAdapter.h>
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 |
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.
EncoderAdapter::EncoderAdapter | ( | int | channelA, |
int | channelB, | ||
int | ticksPerRev, | ||
Hardware | hardware | ||
) |
Counts a two-channel encoder.
channelA | WiringPi Pin for channel A. |
channelB | WiringPi Pin for channel B. |
ticksPerRev | Number of ticks per revolution on this encoder. |
Definition at line 4 of file EncoderAdapter.cpp.
|
override |
Destructs the encoder counter.
Definition at line 19 of file EncoderAdapter.cpp.
long EncoderAdapter::getCount | ( | ) |
Get the current count from the encoder.
Definition at line 62 of file EncoderAdapter.cpp.
double EncoderAdapter::getSpeedRPM | ( | ) |
Get the encoder current speed in RPM.
Definition at line 81 of file EncoderAdapter.cpp.
|
overridevirtual |
Read a list containing a message with the current encoder count for this encoder, and a message with the current speed.
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.
|
overridevirtual |
Runs the encoder counter worker thread.
Implements Thread.
Definition at line 24 of file EncoderAdapter.cpp.
|
inlineoverridevirtual |
Write a message to the peripheral. Deletes the message pointer.
msg | A Message to be sent |
Implements IHardwareInterface.
Definition at line 62 of file EncoderAdapter.h.