-
Notifications
You must be signed in to change notification settings - Fork 5
/
Copy pathsimulator.h
71 lines (60 loc) · 2.02 KB
/
simulator.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
#ifndef SIMULATOR_H
#define SIMULATOR_H
#include <mutex>
#include <QVariantMap>
#include <QVariantList>
#include <QVector2D>
#include <QJSValue>
//! A light wrapper of Aseba-enabled simulated Thymio in Enki
class Simulator: public QObject
{
Q_OBJECT
signals:
//! The simulation is finished.
void simulationCompleted(const QVariantList& log) const;
//! The simulation has messages to print
void notify(const QString& level, const QString& description, const QStringList& arguments) const;
public slots:
//! Run the simulation.
//! If there is an error in the arguments, it is returned, otherwise "" is returned.
QString runProgram(const QVariantMap& scenario, const QVariantMap& events, const QString& source, QJSValue callback = QJSValue()) const;
};
namespace Enki
{
template<typename AsebaRobot>
class DirectlyConnected;
class AsebaThymio2;
typedef DirectlyConnected<AsebaThymio2> DirectAsebaThymio2;
}
//! A light wrapper of a Thymio in the simulator
class ThymioRobotInterface: public QObject
{
Q_OBJECT
Q_PROPERTY(QVector2D position READ position)
Q_PROPERTY(double orientation READ orientation)
Q_PROPERTY(QVariantList horizontalSensors READ horizontalSensors)
Q_PROPERTY(QVariantList groundSensors READ groundSensors)
Q_PROPERTY(QVariantList nativeCalls READ nativeCalls)
public:
ThymioRobotInterface(Enki::DirectAsebaThymio2& thymio);
QVector2D position() const;
double orientation() const;
QVariantList horizontalSensors() const;
QVariantList groundSensors() const;
QVariantList nativeCalls() const;
Q_INVOKABLE void tap();
Q_INVOKABLE void clap();
Q_INVOKABLE void pressBackwardButton();
Q_INVOKABLE void releaseBackwardButton();
Q_INVOKABLE void pressLeftButton();
Q_INVOKABLE void releaseLeftButton();
Q_INVOKABLE void pressCenterButton();
Q_INVOKABLE void releaseCenterButton();
Q_INVOKABLE void pressForwardButton();
Q_INVOKABLE void releaseForwardButton();
Q_INVOKABLE void pressRightButton();
Q_INVOKABLE void releaseRightButton();
protected:
Enki::DirectAsebaThymio2& thymio;
};
#endif // SIMULATOR_H