trikRuntime
trikControl::ColorSensorWorker Class Reference

Worker object that processes color sensor output and updates stored reading. More...

#include <colorSensorWorker.h>

Inheritance diagram for trikControl::ColorSensorWorker:
Collaboration diagram for trikControl::ColorSensorWorker:

Public Slots

void init (bool showOnDisplay)
 Initializes a camera. More...
 
QVector< int > read (int m, int n)
 Returns dominant color in given cell of a grid as a vector [R; G; B] in RGB color scale. More...
 
- Public Slots inherited from trikControl::AbstractVirtualSensorWorker
virtual void stop ()
 Stops detection until init() will be called again. More...
 

Public Member Functions

 ColorSensorWorker (const QString &script, const QString &inputFile, const QString &outputFile, int m, int n, DeviceState &state, trikHal::HardwareAbstractionInterface &hardwareAbstraction)
 Constructor. More...
 
 ~ColorSensorWorker () override
 
- Public Member Functions inherited from trikControl::AbstractVirtualSensorWorker
 AbstractVirtualSensorWorker (const QString &script, const QString &inputFile, const QString &outputFile, DeviceState &state, trikHal::HardwareAbstractionInterface &hardwareAbstraction)
 Constructor. More...
 
 ~AbstractVirtualSensorWorker () override
 
Status status () const override
 Returns current status of the device. More...
 
- Public Member Functions inherited from trikControl::DeviceInterface
 DeviceInterface ()=default
 
virtual ~DeviceInterface ()=default
 

Additional Inherited Members

- Public Types inherited from trikControl::DeviceInterface
enum  Status {
  Status::permanentFailure, Status::temporaryFailure, Status::off, Status::starting,
  Status::ready, Status::stopping
}
 Device status. More...
 
- Signals inherited from trikControl::AbstractVirtualSensorWorker
void stopped ()
 Emitted when sensor is stopped successfully. More...
 
- Static Public Member Functions inherited from trikControl::DeviceInterface
static Status combine (const DeviceInterface &underlying, const DeviceInterface::Status &dependent)
 Helper method to return status of a device relying on other device to work. More...
 
- Protected Member Functions inherited from trikControl::AbstractVirtualSensorWorker
void init ()
 Launch sensor. More...
 
void sendCommand (const QString &command)
 If sensor is ready, sends a command to its input FIFO, otherwise queues this command and sends it later. More...
 

Detailed Description

Worker object that processes color sensor output and updates stored reading.

Meant to be executed in separate thread.

Constructor & Destructor Documentation

ColorSensorWorker::ColorSensorWorker ( const QString &  script,
const QString &  inputFile,
const QString &  outputFile,
int  m,
int  n,
DeviceState state,
trikHal::HardwareAbstractionInterface hardwareAbstraction 
)

Constructor.

Parameters
script- file name of a scrit used to start or stop a sensor.
inputFile- sensor input fifo. Note that we will write data here, not read it.
outputFile- sensor output fifo. Note that we will read sensor data from here.
m- horisontal dimension of a sensor.
n- vertical dimension of a sensor.
state- shared state of a sensor.
ColorSensorWorker::~ColorSensorWorker ( )
override

Member Function Documentation

void ColorSensorWorker::init ( bool  showOnDisplay)
slot

Initializes a camera.

Parameters
showOnDisplay- true if we want an image from a camera to be drawn on robot display.
QVector< int > ColorSensorWorker::read ( int  m,
int  n 
)
slot

Returns dominant color in given cell of a grid as a vector [R; G; B] in RGB color scale.

If m or n are out of range, returns [-1; -1; -1]. Can be accessed directly from other thread.


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