Aria
2.8.0
|
Interface to digital and analog I/O and switched power outputs on MTX core (used in Pioneer LX and other MTX-based robots). More...
#include <ArMTXIO.h>
Public Types | |
enum | Direction { DIGITAL_INPUT, DIGITAL_OUTPUT, INVALID } |
Public Member Functions | |
ArMTXIO (const char *dev="/dev/mtx") | |
Constructor. More... | |
bool | closeIO (void) |
tries to close the device. Returns false if operation failed More... | |
bool | getAnalogValue (int port, double *val) |
bool | getAnalogValue (double *val) |
This returns a conversion of the bits to a decimal value, currently assumed to be in the 0-5V range. More... | |
bool | getAnalogValueRaw (int port, int *val) |
bool | getAnalogValueRaw (int *val) |
bool | getBumperInput (unsigned char *val) |
gets the bumper Input Monitoring Reg | |
unsigned char | getCompatibilityCode () |
gets the Compatibility Code | |
bool | getDigitalInputBit (int bank, int bit) |
Get one bit of an input bank. bank and bit are 0-indexed. | |
unsigned char | getFirmwareRevision () |
gets the Firmware Revision | |
unsigned char | getFirmwareVersion () |
gets the Firmware Version | |
unsigned char | getFPGAType () |
gets the MTX FPGA Type | |
bool | getLIDARSafety (unsigned char *val) |
gets the LIDAR Safety Status Register | |
bool | getLightPole (unsigned char *val) |
get the Light Pole IO Output Control Register | |
bool | getLPCTimeUSec (ArTypes::UByte4 *timeUSec) |
ArRetFunctor1< bool, ArTypes::UByte4 * > * | getLPCTimeUSecCB (void) |
bool | getMotionPowerStatus (unsigned char *val) |
gets the motion power status | |
bool | getPowerStatus1 (unsigned char *val) |
gets the Power Status Register | |
bool | getPowerStatus2 (unsigned char *val) |
gets the Power Status Register 2 | |
bool | isAnalogSupported (void) |
returns true if analog values are supported | |
bool | isEnabled (void) |
returns true if the device is opened and operational | |
int | lock (void) |
Lock global (shared) mutex for all ArMTXIO instances. More... | |
bool | setDigitalOutputBit (int bank, int bit) |
Set one bit of an output bank. bank and bit are 0-indexed. | |
bool | setLightPole (unsigned char *val) |
sets the Light Pole IO Output Control Register | |
bool | setPowerOutput (int bank, int bit, bool on) |
Set one power output. bank and bit are 0-indexed. | |
int | tryLock () |
Try to lock without blocking (see ArMutex::tryLock()) | |
int | unlock (void) |
Unlock global (shared) mutex for all ArMTXIO instances. More... | |
virtual | ~ArMTXIO (void) |
Destructor. More... | |
Direction | getDigitalBankDirection (int bank) |
Get/set value of digital IO banks (see class description above) Banks are 0-indexed. | |
bool | setDigitalBankOutputs (int bank, unsigned char val) |
bool | getDigitalBankInputs (int bank, unsigned char *val) |
Returns the bits of the digital input bank. More... | |
bool | getDigitalBankOutputs (int bank, unsigned char *val) |
Returns the state of the bits as they are currently set in the outputs. More... | |
bool | setPeripheralPowerBankOutputs (int bank, unsigned char val) |
get/set value of power output controls (see robot manual for information on what components and user outputs are controlled). More... | |
bool | getPeripheralPowerBankOutputs (int bank, unsigned char *val) |
bool | getDigitalIOInputMon1 (unsigned char *val) |
gets the values of digital input/output monitoring registers 1 & 2 More... | |
bool | getDigitalIOInputMon2 (unsigned char *val) |
Returns the bits of the digital IO Input Monitoring 1. More... | |
bool | getDigitalIOOutputMon1 (unsigned char *val) |
bool | getDigitalIOOutputMon2 (unsigned char *val) |
bool | setSemaphore1 (unsigned char *val) |
gets/sets the Semaphore Registers | |
bool | getSemaphore1 (unsigned char *val) |
bool | setSemaphore2 (unsigned char *val) |
bool | getSemaphore2 (unsigned char *val) |
bool | setSemaphore3 (unsigned char *val) |
bool | getSemaphore3 (unsigned char *val) |
bool | setSemaphore4 (unsigned char *val) |
bool | getSemaphore4 (unsigned char *val) |
bool | getESTOPStatus1 (unsigned char *val) |
gets the ESTOP status Registers | |
bool | getESTOPStatus2 (unsigned char *val) |
bool | getESTOPStatus3 (unsigned char *val) |
bool | getESTOPStatus4 (unsigned char *val) |
bool | compareESTOPStatus4HighNibbleAgainst (int val) |
Compares the high nibble of this byte against the passed in val, returns true if it matches. | |
bool | getDigitalOutputControl1 (unsigned char *val) |
gets/sets Digital IO Output Control Registers 1 & 2 | |
bool | setDigitalOutputControl1 (unsigned char *val) |
bool | getDigitalOutputControl2 (unsigned char *val) |
bool | setDigitalOutputControl2 (unsigned char *val) |
bool | getPeripheralPower1 (unsigned char *val) |
gets/sets the Peripheral Power Control Regs 1 & 2 These control power to core and robot components, and to user/auxilliary power outputs. More... | |
bool | setPeripheralPower1 (unsigned char *val) |
bool | getPeripheralPower2 (unsigned char *val) |
bool | setPeripheralPower2 (unsigned char *val) |
bool | getPeripheralPower3 (unsigned char *val) |
bool | setPeripheralPower3 (unsigned char *val) |
bool | getLIDARControl (unsigned char *val) |
gets/sets the LIDAR Control Reg | |
bool | setLIDARControl (unsigned char *val) |
bool | getAnalogIOBlock1 (int analog, unsigned short *val) |
gets analog Block 1 & 2 | |
bool | getAnalogIOBlock2 (int analog, unsigned short *val) |
bool | setAnalogIOBlock2 (int analog, unsigned short *val) |
Protected Member Functions | |
bool | getLPCTimer0 (unsigned char *val) |
bool | getLPCTimer1 (unsigned char *val) |
bool | getLPCTimer2 (unsigned char *val) |
bool | getLPCTimer3 (unsigned char *val) |
Protected Attributes | |
bool | myAnalogEnabled |
unsigned char | myCompatibilityCode |
unsigned char | myDigitalBank1 |
unsigned char | myDigitalBank2 |
unsigned char | myDigitalBank3 |
unsigned char | myDigitalBank4 |
ArRetFunctorC< bool, ArMTXIO > | myDisconnectCB |
bool | myEnabled |
int | myFD |
unsigned char | myFirmwareRevision |
unsigned char | myFirmwareVersion |
unsigned char | myFPGAType |
ArRetFunctor1C< bool, ArMTXIO, ArTypes::UByte4 * > | myLPCTimeUSecCB |
int | myNumBanks |
Static Protected Attributes | |
static ArMutex | ourMutex |
Interface to digital and analog I/O and switched power outputs on MTX core (used in Pioneer LX and other MTX-based robots).
On Linux this class uses the mtx
driver to interface with the MTX digital and analog IO, and control switched power outputs.
The mtx
driver module must be loaded for this interface to work.
The mtx
interface (/dev/mtx
) is opened automatically in the ArMTXIO constructor. If successful, isEnabled() will then return true.
The MTX IO is organized as two sets of 8-bit "banks" of inputs, and two 8-bit "banks" of outputs.
To read the state input, use getDigitalIOInputMon1() and getDigitalIOInputMon2(), or getDigitalBankInputs() with bank index 0 or 1.
To set state of output, use setDigitalOutputControl1() and setDigitalOutputControl2(), or setDigitalBankOutputs() with bank index 2 or 3.
Multile ArMTXIO objects may be instatiated; a shared may be locked and unlocked by calling lock() and unlock().
ArMTXIO::ArMTXIO | ( | const char * | dev = "/dev/mtx" | ) |
Constructor.
Constructor for the ArMTXIO class.
This will open the device named by dev (the default is "/dev/amrio" if the argument is omitted). It will find the number of digital banks and set the to inputs. It will also attempt to take an analog reading, which will fail if there is not analog chip present. If the conversion fails it will disable the analog portion of the code.
Check isEnabled() to see if the device was properly opened during construction.
|
virtual |
Destructor.
Attempt to close the device if it was opened
bool ArMTXIO::closeIO | ( | void | ) |
tries to close the device. Returns false if operation failed
Close the device when Aria exits.
|
inline |
bool ArMTXIO::getAnalogValue | ( | double * | val | ) |
This returns a conversion of the bits to a decimal value, currently assumed to be in the 0-5V range.
Returns an analog value converted from the raw reading to a scale if 0-5V.
val | the address of the double to store the reading in |
|
inline |
bool ArMTXIO::getDigitalBankInputs | ( | int | bank, |
unsigned char * | val | ||
) |
Returns the bits of the digital input bank.
bool ArMTXIO::getDigitalBankOutputs | ( | int | bank, |
unsigned char * | val | ||
) |
Returns the state of the bits as they are currently set in the outputs.
bank | which bank to check |
val | the byte to write the values into |
bool ArMTXIO::getDigitalIOInputMon1 | ( | unsigned char * | val | ) |
gets the values of digital input/output monitoring registers 1 & 2
Returns the bits of the digital IO Input Monitoring 1.
bool ArMTXIO::getDigitalIOInputMon2 | ( | unsigned char * | val | ) |
Returns the bits of the digital IO Input Monitoring 1.
bool ArMTXIO::getPeripheralPower1 | ( | unsigned char * | val | ) |
gets/sets the Peripheral Power Control Regs 1 & 2 These control power to core and robot components, and to user/auxilliary power outputs.
Refer to robot manual for information on which components and outputs are controlled by which bits in the peripheral power bitmasks.
|
inline |
Lock global (shared) mutex for all ArMTXIO instances.
This allows multiple access to MTX IO (through multiple ArMTXIO objects).
bool ArMTXIO::setDigitalBankOutputs | ( | int | bank, |
unsigned char | val | ||
) |
bank | the bank number to use for mtx only 2 & 3 are outputs |
val | the status of the 8-bits in a single byte. |
bool ArMTXIO::setPeripheralPowerBankOutputs | ( | int | bank, |
unsigned char | val | ||
) |
get/set value of power output controls (see robot manual for information on what components and user outputs are controlled).
Banks are 0-indexed.
|
inline |
Unlock global (shared) mutex for all ArMTXIO instances.
This allows multiple access to MTX IO (through multiple ArMTXIO objects).