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
kilobotexperiment.h
1#ifndef KILOBOTEXPERIMENT_H
2#define KILOBOTEXPERIMENT_H
3
4#include <QObject>
5#include <QDebug>
6#include <QLayout>
7#include "kilobotenvironment.h"
8#include "kilobot.h"
9#include <QColor>
10#include <opencv2/core/core.hpp>
11
12class KilobotExperiment : public QObject
13{
14 Q_OBJECT
15public:
16 KilobotExperiment() {}
17 virtual ~KilobotExperiment()
18 {
19 }
20
21 int serviceInterval = 100; // ms
22
23 virtual QWidget * createGUI() {return NULL;}
24
25signals:
26 void updateKilobotStates();
27 void getInitialKilobotStates();
28 void experimentComplete();
29 void saveImage(QString);
30 void saveVideoFrames(QString,unsigned int);
31 void signalKilobot(kilobot_message);
32 void broadcastMessage(kilobot_broadcast);
33 void setTrackingType(int);
34 void sendBroadcastingState(bool);
35
36 // drawing
37 void drawCircle(QPointF pos, float r, QColor col, int thickness, std::string text, bool transparent=false);
38 void drawLine(std::vector<cv::Point> pos, QColor col, int thickness, std::string text, bool transparent);
39 void clearDrawings();
40 void drawCircleOnRecordedImage(QPointF pos, float r, QColor col, int thickness, std::string text);
41 void clearDrawingsOnRecordedImage();
42
43
44public slots:
45 virtual void initialise(bool) = 0;
46 virtual void stopExperiment() {}
47 virtual void run() {}
48 void setRuntimeIdentificationLock(bool lock) {this->runtimeIdentificationLock = lock;}
49 void GetMsgsQueueState(bool state){ ThereIsMsgsToSend=state;}
50
58 void updateStateRequiredCode(Kilobot* kilobot, Kilobot kilobotCopy)
59 {
60 //qDebug() << "pre set state 2";
61 // store pointer for connecting
62 this->currKilobot = kilobot;
63 updateKilobotState(kilobotCopy);
64 }
65
73 void setupInitialStateRequiredCode(Kilobot* kilobot, Kilobot kilobotCopy)
74 {
75 //qDebug() << "pre set state";
76 // store pointer for connecting
77 this->currKilobot = kilobot;
78 // switch the signal from setup to standard
79 kilobot->disconnect(SIGNAL(sendUpdateToExperiment(Kilobot*,Kilobot)));
80 connect(kilobot,SIGNAL(sendUpdateToExperiment(Kilobot*,Kilobot)), this, SLOT(updateStateRequiredCode(Kilobot*,Kilobot)));
81 setupInitialKilobotState(kilobotCopy);
82 }
83
84 void signalKilobotExpt(kilobot_message msg)
85 {
86 emit signalKilobot(msg);
87 }
88
89protected:
90 double time;
91 bool runtimeIdentificationLock = false;
92 bool ThereIsMsgsToSend=false;
93
94 void setCurrentKilobotEnvironment(KilobotEnvironment * environment) {
95 if (currKilobot != NULL && environment != NULL) {
96 QObject::disconnect(currKilobot,SIGNAL(sendUpdateToHardware(Kilobot)), 0, 0);
97 QObject::connect(currKilobot,SIGNAL(sendUpdateToHardware(Kilobot)), environment, SLOT(updateVirtualSensor(Kilobot)));
98 }
99 }
100
101 virtual void updateKilobotState(Kilobot) {} // provided in derived class to implement experiment logic for Kilobot state updates
102 virtual void setupInitialKilobotState(Kilobot) {}
103
104private:
105 Kilobot * currKilobot = NULL;
106
107
108};
109
110
111
112#endif // KILOBOTEXPERIMENT_H
void setupInitialStateRequiredCode(Kilobot *kilobot, Kilobot kilobotCopy)
setupInitialStateRequiredCode
Definition kilobotexperiment.h:73
void updateStateRequiredCode(Kilobot *kilobot, Kilobot kilobotCopy)
updateStateRequiredCode
Definition kilobotexperiment.h:58
Definition kilobot.h:118
Definition kilobot.h:31
Definition kilobot.h:25