trikRuntime
colorSensorWorker.h
Go to the documentation of this file.
1 /* Copyright 2014 - 2015 CyberTech Labs Ltd.
2  *
3  * Licensed under the Apache License, Version 2.0 (the "License");
4  * you may not use this file except in compliance with the License.
5  * You may obtain a copy of the License at
6  *
7  * http://www.apache.org/licenses/LICENSE-2.0
8  *
9  * Unless required by applicable law or agreed to in writing, software
10  * distributed under the License is distributed on an "AS IS" BASIS,
11  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12  * See the License for the specific language governing permissions and
13  * limitations under the License. */
14 
15 #pragma once
16 
17 #include <QtCore/QObject>
18 #include <QtCore/QString>
19 #include <QtCore/QReadWriteLock>
20 #include <QtCore/QVector>
21 
23 
24 namespace trikControl {
25 
29 {
30  Q_OBJECT
31 
32 public:
40  ColorSensorWorker(const QString &script, const QString &inputFile, const QString &outputFile, int m, int n
41  , DeviceState &state, trikHal::HardwareAbstractionInterface &hardwareAbstraction);
42 
43  ~ColorSensorWorker() override;
44 
45 public slots:
48  void init(bool showOnDisplay);
49 
53  QVector<int> read(int m, int n);
54 
55 private:
56  QString sensorName() const override;
57 
58  void onNewData(const QString &dataLine) override;
59 
62  QVector<QVector<QVector<int>>> mReading;
63 
65  QVector<QVector<QVector<int>>> mReadingBuffer;
66 
68  bool mShowOnDisplay = true;
69 };
70 
71 }
Helper class to track device state (off, starting, ready, stopping, fail).
Definition: deviceState.h:26
Worker object that processes color sensor output and updates stored reading.
Definition: colorSensorWorker.h:28
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...
Definition: colorSensorWorker.cpp:61
Definition: trikCommunicator.h:27
~ColorSensorWorker() override
Definition: colorSensorWorker.cpp:51
void init()
Launch sensor.
Definition: abstractVirtualSensorWorker.cpp:61
ColorSensorWorker(const QString &script, const QString &inputFile, const QString &outputFile, int m, int n, DeviceState &state, trikHal::HardwareAbstractionInterface &hardwareAbstraction)
Constructor.
Definition: colorSensorWorker.cpp:23
Base class for all virtual sensor workers.
Definition: abstractVirtualSensorWorker.h:38
script
Definition: system.py:83
Hardware abstraction, provides devices that are used to communicate with robot hardware or emulate it...
Definition: hardwareAbstractionInterface.h:29