Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
37 commits
Select commit Hold shift + click to select a range
9ca19a4
basic
LiamGallagher737 Apr 19, 2025
d4bc085
dummy data
LiamGallagher737 Apr 19, 2025
c662ee5
ir sensor arrows
LiamGallagher737 Apr 19, 2025
cd99478
make translational vectors stand out and labeled
LiamGallagher737 Apr 19, 2025
bb98135
rotational vector labels
LiamGallagher737 Apr 19, 2025
ec7ebec
quit when window is closed
LiamGallagher737 Apr 19, 2025
5ac8000
remove old constants
LiamGallagher737 Apr 19, 2025
f285cbd
Update color sensor label
LiamGallagher737 Apr 19, 2025
d909a5a
remove unused vars
LiamGallagher737 Apr 19, 2025
8d3bb01
rotate whole robot for compass
LiamGallagher737 Apr 19, 2025
50de58f
rotation vectors above robot
LiamGallagher737 Apr 19, 2025
739d120
maybe working arduino json
LiamGallagher737 Apr 19, 2025
519558a
motor speed
LiamGallagher737 Apr 19, 2025
100fcdc
swap wheel circles for arrows
LiamGallagher737 Apr 19, 2025
2a51d19
move rotational vectors up
LiamGallagher737 Apr 19, 2025
6418d5b
Redesign
LiamGallagher737 Apr 19, 2025
c522595
more realistic compass dummy data
LiamGallagher737 Apr 19, 2025
a4b172f
commit 157
LiamGallagher737 Apr 23, 2025
d05d880
rust?!?!??!!!!
LiamGallagher737 Apr 25, 2025
18527d3
demo data
LiamGallagher737 Apr 25, 2025
070c958
remove motors for now
LiamGallagher737 Apr 25, 2025
a0ddac7
remove example bs
LiamGallagher737 Apr 25, 2025
92f08a1
white backgroud with black outlined robot
LiamGallagher737 Apr 25, 2025
092cf47
fps counter
LiamGallagher737 Apr 25, 2025
3a6563d
ir sensor arrows
LiamGallagher737 Apr 25, 2025
642e147
rotate robot with compass
LiamGallagher737 Apr 25, 2025
d8b7c14
scale
LiamGallagher737 Apr 25, 2025
82dfcf4
ir sensor text
LiamGallagher737 Apr 25, 2025
f1295cc
motors
LiamGallagher737 Apr 25, 2025
177fc81
rotational vectors
LiamGallagher737 Apr 25, 2025
7609bdc
tidy up comments
LiamGallagher737 Apr 25, 2025
d26ef67
python be gone
LiamGallagher737 Apr 25, 2025
a438fd7
Merge branch 'main' into visualisation
LiamGallagher737 Apr 25, 2025
991efa1
remove venv and add to gitignore pt. 2
LiamGallagher737 Apr 25, 2025
d993e29
Merge branch 'main' into visualisation
LiamGallagher737 Apr 25, 2025
a0d5474
translational vector labels
LiamGallagher737 Apr 25, 2025
f17af1f
Merge branch 'main' into visualisation
LiamGallagher737 Apr 26, 2025
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
The diff you're trying to view is too large. We only load the first 3000 changed files.
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,2 +1,4 @@
build
.vscode/c_cpp_properties.json
visualisation/target
Simulations/venv
6 changes: 6 additions & 0 deletions BallSensors.h
Original file line number Diff line number Diff line change
Expand Up @@ -173,6 +173,12 @@ class BallSensors
return Heading(strongestSensorAngle * DEG_TO_RAD);
}

float *getSensorValues()
{
updateSensorReadings();
return sensorValues;
}

/// @brief Streams sensor data as CSV over Serial.
/// The output format is:
/// reading1,reading2,...,reading8,angle1,angle2,...,angle8,ball_heading,detected_flag
Expand Down
23 changes: 23 additions & 0 deletions FutBot.ino
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,10 @@
#include "Strategy.h"
#include "Sonar.h"
#include "ColourSensor.h"
#include "Json.h"
#include <Wire.h>

#define VISUALIZATION
#define PRINT_CTX

// Compass Calibration Parameters
Expand All @@ -27,6 +29,7 @@ const int BLUE_SIGNATURE = 2;

// Start-of-game Calibration Parameters
Heading downfield_heading = Heading(0);

bool yellowwards = true; // is the opp goal yellow?

// Peripheral objects
Expand Down Expand Up @@ -110,6 +113,10 @@ void DoCalibration() {
void loop() {
Context ctx = UpdateSensors();

#ifdef VISUALIZATION
SendJson();
#endif // VISUALIZATION

#ifdef PRINT_CTX
ctx.SerialPrint();
Serial.println();
Expand Down Expand Up @@ -174,4 +181,20 @@ Context UpdateSensors() {


return ctx;
}

void SendJson()
{
Readings readings = {
.translational = {},
.translational_count = 0,
.rotational = {},
.rotational_count = 0,
.motors = {.fl = 0, .fr = 0, .r = 0},
.compass = ctx.compass.as_degrees(),
.color = {.r = 0, .g = 0, .b = 0},
.ir = ball_sensors->getSensorValues(),
};

SendReadingsJson(readings);
}
83 changes: 83 additions & 0 deletions Json.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,83 @@
#pragma once
#ifndef JSON_H
#define JSON_H

#include <ArduinoJson.h>

const int VECTOR_SIZE = 5;

struct Readings
{
struct Translational
{
float x;
float y;
const char *source;
} translational[VECTOR_SIZE];
int translational_count;

struct Rotational
{
float val;
const char *source;
} rotational[VECTOR_SIZE];
int rotational_count;

struct Motors
{
float fl;
float fr;
float r;
} motors;

float compass;

struct Color
{
int r;
int g;
int b;
} color;

float *ir;
};

/// @brief Send readings over serial in JSON
/// @param readings The readings to send
void SendReadingsJson(Readings &readings)
{
JsonDocument doc;
Comment thread
LiamGallagher737 marked this conversation as resolved.

doc["compass"] = readings.compass;

doc["color"]["r"] = readings.color.r;
doc["color"]["g"] = readings.color.g;
doc["color"]["b"] = readings.color.b;

doc["motors"]["fl"] = readings.motors.fl;
doc["motors"]["fr"] = readings.motors.fr;
doc["motors"]["r"] = readings.motors.r;

for (int i = 0; i < 8; i++)
{
doc["ir"][i] = readings.ir[i];
}

for (int i = 0; i < readings.translational_count; i++)
{
doc["translational"][i]["x"] = readings.translational[i].x;
doc["translational"][i]["y"] = readings.translational[i].y;
doc["translational"][i]["source"] = readings.translational[i].source;
}

for (int i = 0; i < readings.rotational_count; i++)
{
doc["rotational"][i]["val"] = readings.rotational[i].val;
doc["rotational"][i]["source"] = readings.rotational[i].source;
}

serializeJson(doc, Serial);
Serial.println();
}

#endif
Binary file removed Simulations/venv/.DS_Store
Binary file not shown.
241 changes: 0 additions & 241 deletions Simulations/venv/bin/Activate.ps1

This file was deleted.

Loading