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
kilobot.h
1/*
2 * Kilobot.h
3 *
4 * Created on: 16 Sep 2016
5 * Author: marshall
6 */
7
8#ifndef KILOBOT_H_
9#define KILOBOT_H_
10
11#include <stdint.h>
12#include <QPointF>
13#include <QVector>
14
15enum lightColour {
16 OFF,
17 RED,
18 GREEN,
19 BLUE
20};
21
22typedef uint16_t kilobot_id;
23typedef unsigned char kilobot_channel_colour;
24//typedef unsigned char kilobot_message_type;
25typedef struct {
26 uint8_t type :4;
27 kilobot_id id :10;
28 uint16_t data :10;
30
32 uint8_t type;
33 QVector < uint8_t > data;
34};
35
36#define uint8_t_LENGTH 10 // in bits
37#define KILOBOT_MESSAGE_TYPE_LENGTH 4 // in bits
38#define KILOBOT_MESSAGE_DATA_LENGTH 10 // in bits
39#define KILOBOT_MAX_COLOUR 255 // colour channel
40#define KILOBOT_REFRESH_DELAY 3 // in milliseconds
41
42#define KILOBOT_MAX_ID 1024 //
43
44#define UNASSIGNED_ID INT16_MAX
45
46/*enum tracking_type {
47 POS_ONLY,
48 LED_ONLY,
49 ADAPTIVE_LED_ONLY,
50 POS_LED,
51 POS_ADAPTIVE_LED,
52};*/
53
54enum tracking_flags {
55 POS = 1 << 0,
56 LED = 1 << 1,
57 ADAPTIVE_LED = 1 << 2,
58 ROT = 1 << 3
59};
60
61
62#include <QObject>
63
64/*struct kilobot_colour
65{
66 kilobot_channel_colour r;
67 kilobot_channel_colour g;
68 kilobot_channel_colour b;
69};*/
70typedef lightColour kilobot_colour;
71
72
73class ColourBuffer{
74public:
75 ColourBuffer() : ColourBuffer(1) {}
76 ~ColourBuffer() {}
77 ColourBuffer(int size);
78 void addColour(lightColour newColour);
79 lightColour getAvgColour();
80 lightColour getLastColour() {return buffer.at(buffer.size()-1);}
81
82private:
83 int buffer_size;
84 QVector < lightColour > buffer;
85
86};
87
88class OrientationBuffer{
89public:
90 OrientationBuffer() : OrientationBuffer(1) {}
91 ~OrientationBuffer() {}
92 OrientationBuffer(int size) : buffer_size(size) {}
93 void addOrientation(QPointF newOrientation);
94 QPointF getAvgOrientation();
95 QPointF getLastOrientation() {return buffer.at(buffer.size()-1);}
96
97private:
98 int buffer_size;
99 QVector < QPointF > buffer;
100
101};
102
103class PositionBuffer{
104public:
105 PositionBuffer() : PositionBuffer(1) {}
106 ~PositionBuffer() {}
107 PositionBuffer(int size) : buffer_size(size) {}
108 void addPosition(QPointF newPosition);
109 QPointF getOrientationFromPositions();
110 QPointF getLastPosition() {return buffer.at(buffer.size()-1);}
111
112private:
113 int buffer_size;
114 QVector < QPointF > buffer;
115
116};
117
118class Kilobot : public QObject {
119 Q_OBJECT
120public:
121 Kilobot(kilobot_id identifier, QPointF position, QPointF velocity, kilobot_colour colourValues);
122 Kilobot() {}
123 ~Kilobot();
124 // copy constructor
125 Kilobot(const Kilobot& other);
126 kilobot_id getID();
127 void setID(kilobot_id);
128 QPointF getPosition();
129 QPointF getVelocity();
130 kilobot_colour getLedColour();
131 //kilobot_colour resolveKilobotState(stateColours);
132 void updateState(QPointF position, QPointF velocity, kilobot_colour colourValues);
133
140 void updateHardware();
141
149 void updateExperiment();
150
151 int lightThreshold = 230;
152
153 ColourBuffer colBuffer = ColourBuffer(5);
154 OrientationBuffer velocityBuffer = OrientationBuffer(5);
155 PositionBuffer posBuffer = PositionBuffer(6);
156
157signals:
158 void sendUpdateToHardware(Kilobot);
159 void sendUpdateToExperiment(Kilobot*,Kilobot);
160
161private:
162 kilobot_id id = UNASSIGNED_ID;
163 QPointF pos = QPointF(0,0);
164 QPointF vel = QPointF(1,1);
165 kilobot_colour col = OFF;
166
167};
168
169#endif // KILOBOT_H
Definition kilobot.h:73
void updateExperiment()
updateExperiment Copy the Kilobot (for thread safety) and signal the experiment to update the hardwar...
Definition kilobot.cpp:152
void updateHardware()
updateHardware Copy the Kilobot (for thread safety) and signal the environment to update the hardware...
Definition kilobot.cpp:146
Definition kilobot.h:88
Definition kilobot.h:103
Definition kilobot.h:31
Definition kilobot.h:25