Skip to content
Closed
Show file tree
Hide file tree
Changes from 70 commits
Commits
Show all changes
74 commits
Select commit Hold shift + click to select a range
9bb74c8
preliminary push
MahdMalik Mar 31, 2025
b7fd9b5
code to begin testing light sensor. As of current, detects change by …
MahdMalik Apr 1, 2025
a2fc11f
now detecting difference in colors
MahdMalik Apr 7, 2025
95e82c5
added weighted sum
MahdMalik Apr 7, 2025
ac2e09c
almost finished adding a delay to checking different color, seems to…
MahdMalik Apr 8, 2025
4625b20
fixed bug, now cooldown works correctly. Will try to rewrite to remov…
MahdMalik Apr 9, 2025
fdedf6b
refactored code to be more elegeant and clear
MahdMalik Apr 9, 2025
0a6b6a3
added print statement
MahdMalik Apr 9, 2025
0549656
Update README.md
MahdMalik Apr 14, 2025
229036a
Update README.md
MahdMalik Apr 14, 2025
a988f78
Update README.md
MahdMalik Apr 14, 2025
aea0e69
Update README.md
MahdMalik Apr 14, 2025
b9c43c6
Update README.md
MahdMalik Apr 14, 2025
9d4e0d4
Update README.md
MahdMalik Apr 14, 2025
0b13c70
Update README.md
MahdMalik Apr 14, 2025
d66a83a
now tracking the sensor values
MahdMalik Apr 14, 2025
e0684ef
Merge branch 'light-sensors' of https://github.com/Comet-Robotics/che…
MahdMalik Apr 14, 2025
81cfa45
now tracking the sensor values
MahdMalik Apr 14, 2025
d8437eb
FORCE PUSH WE BALL
MahdMalik Apr 14, 2025
4c86505
now light sensor stops on change, some more testing needs to be done …
MahdMalik Apr 15, 2025
0285d5b
Update README.md
MahdMalik Apr 15, 2025
3801978
some reverse working at least, that's nice
MahdMalik Apr 15, 2025
326e2d4
Merge branch 'light-sensors' of https://github.com/Comet-Robotics/che…
MahdMalik Apr 15, 2025
55be84f
reversing to make up for speed working, not very well but it works. I…
MahdMalik Apr 20, 2025
4f4d9b0
Update README.md
MahdMalik Apr 20, 2025
58096cd
alright, I think that movement should be pretty good and doesn't need…
MahdMalik Apr 20, 2025
14378dd
made main.cpp not do as jmuch and moved more code into control.cpp, a…
MahdMalik Apr 21, 2025
ee21354
way to get angle ready
MahdMalik Apr 21, 2025
c98a803
light sensor started tweaking out so wasn't able to make too much pro…
MahdMalik Apr 22, 2025
536e723
i am heisenberg
MahdMalik Apr 22, 2025
2965502
STRONG AURA: WE BALL GRAHH! Now it seems the turning is working somew…
MahdMalik Apr 22, 2025
b71877d
Merge branch 'main' of https://github.com/Comet-Robotics/chessbots-em…
MahdMalik Apr 28, 2025
93e7e28
wallahi we're so back, light sensors are working again. Did change th…
MahdMalik Apr 29, 2025
86cf7b3
getting a bit closer to having reliable movement, it seems an issue i…
MahdMalik Apr 29, 2025
94be21b
its working better now, doesn't seem to be reversing. One thing is it…
MahdMalik Apr 30, 2025
35c61d7
IT'S FINALLY TURNING IN A STABLE MANNER, STARTED FROM THE BOTTOM NOW …
MahdMalik Apr 30, 2025
caf8412
Update README.md
MahdMalik May 5, 2025
62e0ce1
light sensor bros we're so back
MahdMalik May 5, 2025
e67c48d
Merge branch 'light-sensors' of https://github.com/Comet-Robotics/che…
MahdMalik May 5, 2025
d5214d0
going to implement a hardware timer to be more accureate than just it…
MahdMalik May 6, 2025
a58adfb
angle made more accurate, need to try to test at terminal velocity th…
MahdMalik May 6, 2025
9452b1a
got low-diffed by pid/encoder turning, might just instead try to turn…
MahdMalik May 9, 2025
56db840
have an idea on how to reverse, should ask colin if I should use the …
MahdMalik May 9, 2025
00befab
wallahi im finished
MahdMalik May 9, 2025
4d7531b
nvm we're back
MahdMalik May 10, 2025
4f9a87c
WE COMING IN ON SATURDAY WITH THIS ONE 🗣️ ️‍🔥️‍🔥️‍🔥
MahdMalik May 10, 2025
20f0591
so it seems PID doesn't react too kindly to when you constantly incre…
MahdMalik May 10, 2025
aa2f86e
alt solution in the meantime: continuously move bot at intervals inst…
MahdMalik May 10, 2025
21b47ca
gonna have to dive into the pid function and see what's going wrong
MahdMalik May 10, 2025
2edaaeb
it seems i'm at least getting closer to getting the pid to be success…
MahdMalik May 10, 2025
0060c29
WALLAHI WE'RE SO BACK, PID IS FIXED NOW I JUST NEED TO TEST THE TURN …
MahdMalik May 10, 2025
8ad9249
WALLAHI WE'RE SO FINISHED, LIGHT SENSOR ACTING UP NOW, I'M SO CLOSE A…
MahdMalik May 11, 2025
10c60f7
alright so at at least now I know that the light sensors failing is c…
MahdMalik May 11, 2025
d5d1273
ok so the bot is moving fine on hard surfaces like wood but not the t…
MahdMalik May 11, 2025
6d817c3
so the light sensors crash out depending what surface the bot is on w…
MahdMalik May 11, 2025
5170ba9
alright so now I got the pid fixed when it would overshoot heavily by…
MahdMalik May 12, 2025
cbb0f6d
I DON'T KNOW WHY I HAVE TO DIVIDE THE ANGLE BY 2 BUT NOW IT ALIGNS A…
MahdMalik May 12, 2025
b4ee1f8
ok even after a bit of debugging I still have no idea why I divide by…
MahdMalik May 12, 2025
453477a
'I'm going to go back to being that guy. Since they all seem to have…
MahdMalik May 12, 2025
b540ed6
alright as I suspected, centering will actually be fairly easy. One t…
MahdMalik May 12, 2025
45f8346
centering around one axis roughly completed
MahdMalik May 12, 2025
6aebfa6
CENTERING WORKS GRAHHHHH
MahdMalik May 12, 2025
8f130d5
centering seems a bit acceptable, sometimes the motor jitters and is …
MahdMalik May 13, 2025
83f5bd5
stalling issue seems to be fixed (at least as far as I can see), now …
MahdMalik May 13, 2025
01a29a3
rewriting some code to be more clear, I need to fix this issue there …
MahdMalik May 13, 2025
cdba882
made centering a bit more accurate (I think)
MahdMalik May 13, 2025
07c58a1
cleaned up trapezoidal profile
MahdMalik May 13, 2025
87bf49e
done commenting and cleaning up code in control.cpp
MahdMalik May 13, 2025
26c79c7
sped up movement while keeping it safe
MahdMalik May 13, 2025
7f40f48
made a failsafe for the occasional jittering where it doesn't quite r…
MahdMalik May 13, 2025
e08198b
fixed a bug where if I put a timer on the jittering it'd skip the nex…
MahdMalik May 15, 2025
7dd9fdd
TRAPEZOIDAL PROFILE BEAT THE ALLEGATIONS ON GOD!! so it turns out tha…
MahdMalik May 16, 2025
043960c
task should be done now, tested it like 5 times and didn't seem to en…
MahdMalik May 16, 2025
ef03e6a
Add ability to center forever for Kickoff. Centering in general needs…
xXDMOGXx Sep 4, 2025
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -5,3 +5,4 @@
.vscode/settings.json
.vscode/ipch
env.h
/.history
Binary file added Getting Angle to Rotate for Alignment.pdf
Binary file not shown.
Binary file not shown.
4 changes: 0 additions & 4 deletions README.md

This file was deleted.

12 changes: 10 additions & 2 deletions include/robot/control.h
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,18 @@ void drive(float leftPower, float rightPower, std::string id);
void driveTicks(int tickDistance, std::string id);
void turn(float angleRadians, std::string id);
void stop();
void readLight();
void readLight(int loopDelayMs);
void startMotorAndEncoderTest();
bool checkMoveFinished();
void startDriveTest();
bool checkIfCanUpdateMovement();
void createDriveUntilNewTile();
void determineNextChoice();
uint8_t driveUntilNewTile();
void driveTestOff();
void controlLoop(int loopDelayMs);
void updateCritRange();
void controlLoop(int loopDelayMs, int8_t framesUntilPrint);
void updateCentering();
void updateToNextDistance();

#endif
3 changes: 2 additions & 1 deletion include/robot/lightSensor.h
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,10 @@
#include "Arduino.h"

void setupIR();
void readGarbageVals();
void activateIR();
void deactivateIR();
void startLightReading();
void startLightReading(bool* onFirstTile, bool* waitingForLight);
void readLightLevels();

#endif
4 changes: 3 additions & 1 deletion include/robot/trapezoidalProfile.h
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
#include <cstdint>

struct MotionProfile {
double maxVelocity;
double maxAcceleration;
Expand All @@ -7,7 +9,7 @@ struct MotionProfile {
double targetVelocity;
};

double updateTrapezoidalProfile(MotionProfile &profile, double dt);
double updateTrapezoidalProfile(MotionProfile &profile, double dt, int8_t framesUntilprint, int critRange);

template <typename T>
T clamp(T value, T minValue, T maxValue) {
Expand Down
2 changes: 2 additions & 0 deletions include/utils/config.h
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,8 @@ extern gpio_num_t PHOTODIODE_B_PIN;
extern gpio_num_t PHOTODIODE_C_PIN;
extern gpio_num_t PHOTODIODE_D_PIN;

extern gpio_num_t ONBOARD_LED_PIN;

extern int TICKS_PER_ROTATION;
extern float TRACK_WIDTH_INCHES;
extern float WHEEL_DIAMETER_INCHES;
Expand Down
1 change: 1 addition & 0 deletions include/utils/timer.h
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@

// Built-In Libraries
#include <vector>
//we're gonna need this if we need to use delays which require functions
#include <functional>

// This callback allows you to just pass in the pointer of a function as a parameter
Expand Down
22 changes: 20 additions & 2 deletions src/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,10 @@

int delayMilliseconds = 20;

//alright SCREW YOU serial monitor i won't print every frame then if you wanna play that game

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this line made me audibly chuckle. nice

const int8_t PRINT_INTERVAL = 60;
int8_t framesUntilPrint = 60;

// Setup gets run at startup
void setup() {
// Serial port for debugging purposes
Expand All @@ -35,6 +39,9 @@ void setup() {

if (DO_DRIVE_TEST) startDriveTest();

delay(2000);

//start reading the light
if (DO_DRIVE_TICKS_TEST) driveTicks(20000, "NULL");

if (DO_HARDWARE_TEST) timerDelay(5000, &startMotorAndEncoderTest);
Expand All @@ -45,22 +52,33 @@ void loop() {
// Checks if any timers have expired
timerStep();

if (!RUN_OFFLINE) {
if (!RUN_OFFLINE)
{
// Checks whether bot is still connected to WiFi. Reconnect if not
if (getWiFiConnectionStatus() && !checkWiFiConnection()) reconnectWiFI();
// Checks whether bot is still connected to the server. Reconnect if not
if (getServerConnectionStatus() && !checkServerConnection()) reconnectServer();

// If the bot is connected to the server, check for received data, and accept it if available
if (getServerConnectionStatus()) acceptData();
// Checks whether bot is still connected to the server. Reconnect if not
if (getServerConnectionStatus() && !checkServerConnection()) reconnectServer();

// If the bot is connected to the server, check for received data, and accept it if available
if (getServerConnectionStatus()) acceptData();
}

// Run control loop
controlLoop(delayMilliseconds);
controlLoop(delayMilliseconds, framesUntilPrint);

// This delay determines how often the code in loop is run
// (Forcefully pauses the thread for about the amount of milliseconds passed in)
delay(delayMilliseconds);
framesUntilPrint--;
if(framesUntilPrint < 0)
{
framesUntilPrint = PRINT_INTERVAL;
}
}

// This is used at the end of each file due to the name definition at the beginning
Expand Down
Loading