LARS
LARS (Light Augmented Reality System) is an open-source framework for light-based interaction and real-time tracking in multi-robot experiments. Inspired by ARK, LARS extends the augmented reality paradigm to robotic collectives by projecting dynamic visual cues and environments onto the arena, enabling new experimental possibilities for collective robotics research, education, and outreach. LARS features integrated tracking, light projection, and modular experiment control with a user-friendly Qt GUI.
Loading...
Searching...
No Matches
worldmodel.h
1#ifndef WORLDMODEL_H
2#define WORLDMODEL_H
3
4#include <QList>
5#include <QDebug>
6#include <QColor>
7#include <QPainter>
8#include <opencv2/opencv.hpp>
9
10#include <boost/graph/adjacency_list.hpp>
11#include <boost/graph/graph_traits.hpp>
12#include <boost/graph/graphviz.hpp>
13
14#include <igraph/igraph.h>
15
17//typedef boost::adjacency_list<boost::vecS, boost::vecS, boost::undirectedS> Graph;
18//typedef boost::graph_traits<Graph>::vertex_descriptor Vertex;
19//typedef boost::graph_traits<Graph>::edge_descriptor Edge;
20
21enum BrushType {
22 GRADIENT,
23 IMAGE,
24 SOLID,
25 NULL_BRUSH
26};
27
28
29struct wmCircle {
30 QPoint pos;
31 int r;
32 QColor col;
33 int thickness;
34 std::string text;
35 bool transparent;
36};
37
38
39
40class WorldModel
41{
42public:
43 explicit WorldModel();
44 double time;
45
46 // QPoint fieldTL = QPoint(0,0);
47 // QSize fieldSize = QSize(1000,1000);
48
49 // to put the wood margins in the shade
50#ifdef FOR_KILOBOT
51 QPoint fieldTL = QPoint(390,0);
52 QSize fieldSize = QSize(1000,1200);
53#else
54 QPoint fieldTL = QPoint(135,120);
55 QSize fieldSize = QSize(1000,1000);
56#endif
57
58
59 // Markers Pos in Projected Space: set 1
60 // QPoint marker0_pos = QPoint(1100,500);
61 // QPoint marker1_pos = QPoint(1100,1000);
62 // QPoint marker2_pos = QPoint(1600,500);
63 // QPoint marker3_pos = QPoint(1600,1000);
64
65#ifdef FOR_KILOBOT
66 int arenaWidth = 1030;
67 int arenaHeight = 1030;
68 QPoint marker0_pos = QPoint(395, 0);
69// QPoint marker0_pos = QPoint(1100+50, 300);
70#else
71
72 // Largest arena for THYMIO LARGER
73 int arenaWidth = 1560;
74 int arenaHeight = 930;
75 QPoint marker0_pos = QPoint(140, 140);
76
77
78// Largest arena for THYMIO
79// int arenaWidth = 1350;
80// int arenaHeight = 700;
81// QPoint marker0_pos = QPoint(340, 300);
82#endif
83
84 QPoint marker1_pos = QPoint(marker0_pos.x(), marker0_pos.y() + arenaHeight);
85 QPoint marker2_pos = QPoint(marker0_pos.x() + arenaWidth, marker0_pos.y());
86 QPoint marker3_pos = QPoint(marker0_pos.x() + arenaWidth, marker0_pos.y() + arenaHeight);
87
88 int marker_length = 50;
89 QPoint marker0_BR = QPoint(marker0_pos + QPoint(marker_length,marker_length));
90
91 QRect expFieldRect;
92 QPolygon expFieldPoints;
93 BrushType expFieldType, robBrushType;
94
95 int noiseTileNo = 50, noiseTimeIntv = -1;
96 double noiseStrength = 0.2;
97
98 QPixmap arenaImg, arenaProcessedImg;
99
100 QRect insideRect = QRect(0,0,0,0);
101 QRect outsideRect;
102
103 cv::Size capSize = cv::Size(960,600); // cv::Size(600,400);
104
105 QList<QPoint> pointsToDraw;
106
107 QPoint centroid;
108
109 QList<QPoint> rob_Type0_pos;
110 QList<bool> rob_toEnlight;
111
112 QVector<QPoint> kiloPosVec, kiloPosVecOnFrame;
113 QVector<cv::Scalar> kiloColor;
114 QVector<QVector <QPoint>> rob_traces;
115
116 QBrush *brush_robotCustom_0 = new QBrush(QColor::fromRgb(3, 252, 248), Qt::SolidPattern);
117 bool boolNullBrushForRobots = false;
118 int robRad = 50;
119
120 QPoint ballPos = QPoint(0,0);
121 QPointF ballVel = QPointF(1.0,1.0);
122 int ballSpeed = 10, ballRad = 60;
123
124// Graph robot_graph;
125
126 // Pos@Cap = ScaleArena2Cap * Pos@Arena + biasArena2Cap
127 // QVector2D<float> scaleArena2Cap;
128 // QVector2D<float> biasArena2Cap;
129
130
131 // Painter Bias (TOP LEFT)
132 int bias_X = 0, bias_Y = 0;
133
134 // Field HSV
135 QColor fieldCol;
136 // int fieldH = 0, fieldS = 0, fieldV = 0;
137
138 bool loadImgBackground;
139
140 void setFieldColorHSV(int H, int S, int V);
141 void setFieldColor(QColor color);
142 void setFieldSize(QSize size);
143 void setRobotCustomColor(QColor color);
144 void setNullRobotCustomBrush(bool boolNullBrush);
145
146// void create_empty_graph(QList <QPoint> points);
147
148 bool drawTrace = false, drawBoundary = true, drawHeatMap = false, drawColCircles = false, drawRobCircles = false, drawInitPoint = false;
149 bool drawNetwork = false, drawVoronoii = false, drawCentroid = false, drawWithColors = true, spatialNetwork=false, drawBall=false;
150
151 int dummy_var = 0, dummy_var2=0;
152
153 QVector <wmCircle> circles2Draw;
154
155 cv::Mat heatMap;
156
157public slots:
158 // void setFieldH(int H);
159 // void setFieldV(int V);
160
161 // Knowledge *kn;
162
163 //----Graphical Debug-----
164 // QList<Segment2D> voronoi;
165 // bool showVoronoi;
166 // QList<Vector2D> selected;
167
168 // //---UDP 2 Matlab
169 // bool sendUDP;
170 // int indexOfUDP;
171 // QString whichUDP;
172
173};
174
175#endif // WORLDMODEL_H
Definition worldmodel.h:29