summaryrefslogtreecommitdiff
path: root/robot/mode_grid.c
diff options
context:
space:
mode:
authorlonkaars <loek@pipeframe.xyz>2022-06-24 11:42:23 +0200
committerlonkaars <loek@pipeframe.xyz>2022-06-24 11:42:23 +0200
commit40f6164ba6187a0160af9fe200bbd1d729e8c03b (patch)
tree84246633f40cb0c5d858168f63a5933d18006db3 /robot/mode_grid.c
parent2e537232404bf5123bc92e7218156ec03160c68f (diff)
added TARQ to robot and client
Diffstat (limited to 'robot/mode_grid.c')
-rw-r--r--robot/mode_grid.c32
1 files changed, 14 insertions, 18 deletions
diff --git a/robot/mode_grid.c b/robot/mode_grid.c
index 4364b67..7e6db49 100644
--- a/robot/mode_grid.c
+++ b/robot/mode_grid.c
@@ -19,12 +19,11 @@ w2_s_grid_coordinate g_w2_destination;
w2_e_orientation g_w2_direction;
int g_w2_detection = 0;
-int g_w2_transition; //used for the crosswalk, used to count black lines
-char g_w2_x_location = 0; //current location in grid
+int g_w2_transition; // used for the crosswalk, used to count black lines
+char g_w2_x_location = 0; // current location in grid
char g_w2_y_location = 0;
-
-//used for the crosswalk from maze to grid
+// used for the crosswalk from maze to grid
void w2_crosswalk_stroll() {
while (g_w2_sensors[0] < 100 && g_w2_sensors[1] < 100 && g_w2_sensors[2] < 100 &&
g_w2_sensors[3] < 100 && g_w2_sensors[4] < 100) {
@@ -57,7 +56,7 @@ void w2_grid_crossway_detection() {
g_w2_position = read_line(g_w2_sensors, IR_EMITTERS_ON);
}
-//main function for grid mode
+// main function for grid mode
void w2_grid_follow_line() {
unsigned int last_proportional = 0;
long integral = 0;
@@ -75,9 +74,10 @@ void w2_grid_follow_line() {
if (power_difference < -max) power_difference = -max;
if (g_w2_sensors[0] >= 500 && g_w2_sensors[1] >= 250 && g_w2_sensors[2] >= 500 &&
- g_w2_sensors[3] >= 250 && g_w2_sensors[4] >= 500) { //crossways/intersections
+ g_w2_sensors[3] >= 250 && g_w2_sensors[4] >= 500) { // crossways/intersections
break;
- } else if (g_w2_sensors[0] >= 500 && g_w2_sensors[1] >= 200 && g_w2_sensors[4] < 100) { //left corners
+ } else if (g_w2_sensors[0] >= 500 && g_w2_sensors[1] >= 200 &&
+ g_w2_sensors[4] < 100) { // left corners
break;
} else if (g_w2_sensors[4] >= 500 && g_w2_sensors[3] >= 200 &&
g_w2_sensors[0] < 100) { // for the south and west borders of the grid
@@ -99,22 +99,20 @@ void w2_grid_follow_line() {
}
}
-//begin location when entering the grid
+// begin location when entering the grid
void w2_begin_location() {
g_w2_location.x = 4;
g_w2_location.y = 0;
g_w2_direction = W2_ORT_WEST;
}
-
-//location of grid exit
+// location of grid exit
void w2_end_destination() {
g_w2_destination.x = 4;
g_w2_destination.y = 4;
}
-
-//turns are used to get the correct orientation when picking up orders
+// turns are used to get the correct orientation when picking up orders
void w2_turn_north() {
switch (g_w2_direction) {
case W2_ORT_NORTH:
@@ -201,8 +199,7 @@ void w2_turn_east() {
g_w2_direction = W2_ORT_EAST;
}
-
-//signals when the product is picked
+// signals when the product is picked
void w2_arrived_message() {
if (g_w2_location.x == g_w2_destination.x && g_w2_location.y == g_w2_destination.y) {
play_frequency(400, 500, 7);
@@ -210,8 +207,7 @@ void w2_arrived_message() {
}
}
-
-//go to correct x coordinate
+// go to correct x coordinate
void w2_go_to_x() {
if (g_w2_location.x != g_w2_destination.x) {
while (g_w2_location.x != g_w2_destination.x) {
@@ -232,7 +228,7 @@ void w2_go_to_x() {
}
}
-//go to correct y coordinate
+// go to correct y coordinate
void w2_go_to_y() {
if (g_w2_location.y != g_w2_destination.y) {
while (g_w2_location.y != g_w2_destination.y) {
@@ -253,7 +249,7 @@ void w2_go_to_y() {
}
}
-//main function for grid mode
+// main function for grid mode
void w2_mode_grid() {
set_motors(0, 0);
delay(500);