trikRuntime
objectSensorWorker.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:
39  ObjectSensorWorker(const QString &script, const QString &inputFile, const QString &outputFile
40  , qreal toleranceFactor, DeviceState &state, trikHal::HardwareAbstractionInterface &hardwareAbstraction);
41 
42  ~ObjectSensorWorker() override;
43 
44 public slots:
47  void init(bool showOnDisplay);
48 
50  void detect();
51 
54  QVector<int> read();
55 
58  QVector<int> getDetectParameters() const;
59 
60 private:
61  QString sensorName() const override;
62 
63  void onNewData(const QString &dataLine) override;
64 
66  QVector<int> mReading;
67 
69  QVector<int> mReadingBuffer{0, 0, 0};
70 
72  qreal mToleranceFactor = 1.0;
73 
75  bool mShowOnDisplay = true;
76 
78  QVector<int> mDetectParametersBuffer{0, 0, 0, 0, 0, 0};
79 
81  QVector<int> mDetectParameters{0, 0, 0, 0, 0, 0};
82 };
83 
84 }
void detect()
Detects the color of an object in center of current frame and memorizes it.
Definition: objectSensorWorker.cpp:36
QVector< int > read()
Returns current raw x coordinate of detected object.
Definition: objectSensorWorker.cpp:41
Helper class to track device state (off, starting, ready, stopping, fail).
Definition: deviceState.h:26
Worker object that processes object sensor output and updates stored reading.
Definition: objectSensorWorker.h:28
ObjectSensorWorker(const QString &script, const QString &inputFile, const QString &outputFile, qreal toleranceFactor, DeviceState &state, trikHal::HardwareAbstractionInterface &hardwareAbstraction)
Constructor.
Definition: objectSensorWorker.cpp:19
QVector< int > getDetectParameters() const
Get values returned by last "detect" operation.
Definition: objectSensorWorker.cpp:46
~ObjectSensorWorker() override
Definition: objectSensorWorker.cpp:26
Definition: trikCommunicator.h:27
void init()
Launch sensor.
Definition: abstractVirtualSensorWorker.cpp:61
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