aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--client/i18n/nl_nl.h115
-rw-r--r--robot/mode_chrg.c5
-rw-r--r--robot/mode_grid.c89
-rw-r--r--robot/mode_halt.c1
-rw-r--r--robot/mode_maze.c15
-rw-r--r--robot/mode_scal.c1
-rw-r--r--robot/mode_spin.c2
-rw-r--r--robot/modes.c1
-rw-r--r--robot/movement.c12
9 files changed, 170 insertions, 71 deletions
diff --git a/client/i18n/nl_nl.h b/client/i18n/nl_nl.h
new file mode 100644
index 0000000..94c3241
--- /dev/null
+++ b/client/i18n/nl_nl.h
@@ -0,0 +1,115 @@
+#pragma once
+
+#define W2_UI_CLI_USAGE "gebruik: %s <seriele port>\n"
+#define W2_UI_CLI_SERPORT_ERROR "seriele port open fout\n"
+#define W2_UI_CLI_INITSCR_FAIL "ncurses initscr() fout\n"
+#define W2_UI_CONN_STAT_CONNECTED "verbonden"
+#define W2_UI_CONN_STAT_DISCONNECTED "Verbindng verloren"
+#define W2_UI_CONN_STAT_PING "ping"
+#define W2_UI_BATT_STAT_BATTERY "batterij"
+#define W2_UI_EXPT_STAT_WARNINGS "waarshuwing(en)"
+#define W2_UI_EXPT_STAT_ERRORS "error(s)"
+
+#define W2_UI_MODE_CHRG "oplaadstation"
+#define W2_UI_MODE_DIRC "handbesturing"
+#define W2_UI_MODE_GRID "grid"
+#define W2_UI_MODE_HALT "noodstop"
+#define W2_UI_MODE_LCAL "lijn kalibratie"
+#define W2_UI_MODE_MAZE "doolhof"
+#define W2_UI_MODE_SCAL "sensor kalibratie"
+#define W2_UI_MODE_SPIN "natte vloer simulatie"
+
+#define W2_UI_TAB_LABEL_START "info"
+#define W2_UI_TAB_LABEL_DIRC "handbesturing"
+#define W2_UI_TAB_LABEL_ERRCATCH "logs"
+#define W2_UI_TAB_LABEL_MCFG "kaart"
+#define W2_UI_TAB_LABEL_ORDERS "orders"
+#define W2_UI_TAB_LABEL_MODES "modus instellen"
+
+#define W2_UI_TAB_START_MESSAGE "" \
+ "welcome to the wall-e2 console application!\n" \
+ "this is client version " W2_BUILD_STR "\n" \
+ "\n" \
+ "this application is functionally similar to a BIOS.\n" \
+ "here's a brief summary of keyboard commands:\n" \
+ "\n" \
+ "<tab> switch to next tab\n" \
+ "<ctrl-c> exit\n" \
+ "\n" \
+
+#define W2_UI_ERROR_SEVERITY_CRIT "CRIT"
+#define W2_UI_ERROR_SEVERITY_WARN "WARN"
+#define W2_UI_ERROR_SEVERITY_INFO "INFO"
+#define W2_UI_ERROR_SEVERITY_VERB "VERB"
+
+#define W2_UI_ERROR_INT_W2_E_UNKNOWN "W2_E_UNKNOWN"
+#define W2_UI_ERROR_INT_W2_E_CRIT_CONN_LOST "W2_E_CRIT_CONN_LOST"
+#define W2_UI_ERROR_INT_W2_E_CRIT_COM_UNAVAILABLE "W2_E_CRIT_COM_UNAVAILABLE"
+#define W2_UI_ERROR_INT_W2_E_CRIT_LINE_LOST "W2_E_CRIT_LINE_LOST"
+#define W2_UI_ERROR_INT_W2_E_CRIT_OBSTACLE_STUCK "W2_E_CRIT_OBSTACLE_STUCK"
+#define W2_UI_ERROR_INT_W2_E_CRIT_VERSION_INCOMPATIBLE "W2_E_CRIT_VERSION_INCOMPATIBLE"
+#define W2_UI_ERROR_INT_W2_E_WARN_BATTERY_LOW "W2_E_WARN_BATTERY_LOW"
+#define W2_UI_ERROR_INT_W2_E_WARN_OBSTACLE_DETECTED "W2_E_WARN_OBSTACLE_DETECTED"
+#define W2_UI_ERROR_INT_W2_E_WARN_CYCLE_EXPIRED "W2_E_WARN_CYCLE_EXPIRED"
+#define W2_UI_ERROR_INT_W2_E_WARN_UNCAUGHT_ERROR "W2_E_WARN_UNCAUGHT_ERROR"
+#define W2_UI_ERROR_INT_W2_E_WARN_ERR_BUFFER_FULL "W2_E_WARN_ERR_BUFFER_FULL"
+#define W2_UI_ERROR_INT_W2_E_WARN_LINE_LOST "W2_E_WARN_LINE_LOST"
+#define W2_UI_ERROR_INT_W2_E_WARN_SERCOMM_BUFFER_FULL "W2_E_WARN_SERCOMM_BUFFER_FULL"
+#define W2_UI_ERROR_INT_W2_E_WARN_VERSION_INCOMPATIBLE "W2_E_WARN_VERSION_INCOMPATIBLE"
+#define W2_UI_ERROR_INT_W2_E_WARN_SERIAL_NOISY "W2_E_WARN_SERIAL_NOISY"
+#define W2_UI_ERROR_INT_W2_E_WARN_MODE_HISTORY_BUFFER_IOB "W2_E_WARN_MODE_HISTORY_BUFFER_IOB"
+#define W2_UI_ERROR_INT_W2_E_WARN_PING_TIMEOUT "W2_E_WARN_PING_TIMEOUT"
+
+#define W2_UI_ERROR_USR_W2_E_UNKNOWN "onbekende error code"
+#define W2_UI_ERROR_USR_W2_E_CRIT_CONN_LOST "verbinding met de robot verloren"
+#define W2_UI_ERROR_USR_W2_E_CRIT_COM_UNAVAILABLE "COM-port niet beschikbaar"
+#define W2_UI_ERROR_USR_W2_E_CRIT_LINE_LOST "lijn verloren en niet mogelijk automatisch te detecteren"
+#define W2_UI_ERROR_USR_W2_E_CRIT_OBSTACLE_STUCK "obstakel gedetecteerd, robot staat klem"
+#define W2_UI_ERROR_USR_W2_E_CRIT_VERSION_INCOMPATIBLE "versie komt niet overeen, update de robot voor de nieuwste versie"
+#define W2_UI_ERROR_USR_W2_E_WARN_BATTERY_LOW "batterij bijna leeg, de robot gaat naar het oplaadstation"
+#define W2_UI_ERROR_USR_W2_E_WARN_OBSTACLE_DETECTED "obstakel gedetecteerd, robot wacht af"
+#define W2_UI_ERROR_USR_W2_E_WARN_CYCLE_EXPIRED "maximale cyclus tijd overschreden"
+#define W2_UI_ERROR_USR_W2_E_WARN_UNCAUGHT_ERROR "onopgemerkte fout gedetecteerd"
+#define W2_UI_ERROR_USR_W2_E_WARN_ERR_BUFFER_FULL "error buffer zit vol"
+#define W2_UI_ERROR_USR_W2_E_WARN_LINE_LOST "lijn verloren, initieer automatische lijn detectie"
+#define W2_UI_ERROR_USR_W2_E_WARN_SERCOMM_BUFFER_FULL "seriele communicatie buffer is vol"
+#define W2_UI_ERROR_USR_W2_E_WARN_VERSION_INCOMPATIBLE "versie komt niet overeen, dit kan leiden tot problemen"
+#define W2_UI_ERROR_USR_W2_E_WARN_SERIAL_NOISY "ongeldige seriele informatie gedetecteerd, (ruisend kanaal / controleer de verbinding?)"
+#define W2_UI_ERROR_USR_W2_E_WARN_MODE_HISTORY_BUFFER_IOB "mode geschiedenisbuffer index is buiten bereik"
+#define W2_UI_ERROR_USR_W2_E_WARN_PING_TIMEOUT "ping time-out"
+
+#define W2_UI_ORDER_CMD_HELP "help"
+#define W2_UI_ORDER_CMD_START "start"
+#define W2_UI_ORDER_CMD_COORDINATE "coördinaat"
+#define W2_UI_ORDER_CMD_DONE "klaar"
+#define W2_UI_ORDER_CMD_SEND "verstuur"
+
+#define W2_UI_ORDER_MSG_ERROR "onbekend commando, type 'help' om een lijst te krijgen van alle mogelijke commando's\n\n"
+#define W2_UI_ORDER_MSG_HELP \
+ "commando's:\n" \
+ "\n" \
+ W2_UI_ORDER_CMD_HELP ": print deze lijst\n" \
+ W2_UI_ORDER_CMD_START ": start een order\n" \
+ W2_UI_ORDER_CMD_COORDINATE " <x> <y>: voeg een coördinaat toe aan het huidige order\n" \
+ W2_UI_ORDER_CMD_DONE ": voltooi de huidige bestelling\n" \
+ W2_UI_ORDER_CMD_SEND ": verstuur het laatst voltooide order naar de robot\n\n"
+#define W2_UI_ORDER_MSG_ORDER_START_OK "order gestart\n\n"
+#define W2_UI_ORDER_MSG_ORDER_START_ERR "order wordt al verwekt\n\n"
+#define W2_UI_ORDER_MSG_ORDER_APPEND_OK "coördinaat toegevoegd aan bestelling\n\n"
+#define W2_UI_ORDER_MSG_ORDER_APPEND_ERR "geen order actief\n\n"
+#define W2_UI_ORDER_MSG_ORDER_DONE_OK "order opgeslagen\n\n"
+#define W2_UI_ORDER_MSG_ORDER_DONE_ERR "geen order actief\n\n"
+#define W2_UI_ORDER_MSG_ORDER_SENT "order verzonden naar de robot\n\n"
+
+#define W2_UI_MODES_INFO \
+ "Druk toetsen (0-9) voor:\n" \
+ "\n" \
+ "1 - kies doolhof modus\n" \
+ "2 - kies grid modus\n" \
+ "3 - noodstop\n" \
+ "4 - kies oplaad modus\n" \
+ "5 - natte vloer simulatie\n" \
+ "6 - calibreer sensoren\n" \
+ "\n" \
+ "0 - vorige\n" \
+
diff --git a/robot/mode_chrg.c b/robot/mode_chrg.c
index 5b733af..7cf9a9c 100644
--- a/robot/mode_chrg.c
+++ b/robot/mode_chrg.c
@@ -4,7 +4,7 @@
#include "movement.h"
#include "orangutan_shim.h"
-int g_w2_charged_status;
+int g_w2_charged_status; //used to detect the charging station (once)
void w2_short_drive() {
set_motors(50, 50);
@@ -12,6 +12,7 @@ void w2_short_drive() {
set_motors(0, 0);
}
+//charging station
void w2_home() {
set_motors(0, 0);
delay_ms(150);
@@ -28,6 +29,7 @@ void w2_home() {
delay_ms(2000);
}
+//crosswalk from charging station back to maze
void w2_charge_cross_walk() {
if (g_w2_transition == 0) {
set_motors(-30, 30);
@@ -59,6 +61,7 @@ void w2_charge_cross_walk() {
}
}
+//main function for charge mode
void w2_mode_chrg() {
unsigned int last_proportional = 0;
long integral = 0;
diff --git a/robot/mode_grid.c b/robot/mode_grid.c
index 16dbef3..d493a1a 100644
--- a/robot/mode_grid.c
+++ b/robot/mode_grid.c
@@ -7,6 +7,8 @@ int g_w2_order_number;
int g_w2_maze_status = 0;
+
+//product coordinates
w2_s_grid_coordinate g_w2_order[4] = {
{0, 0},
{1, 1},
@@ -17,6 +19,8 @@ w2_s_grid_coordinate g_w2_location;
w2_s_grid_coordinate g_w2_destination;
w2_e_orientation g_w2_direction;
+
+//give coordinates for grid
void w2_location_message() {
clear();
print_long(g_w2_location.x);
@@ -25,13 +29,15 @@ void w2_location_message() {
delay(200);
}
+
int g_w2_detection = 0;
-int g_w2_transition;
-char g_w2_x_location = 0;
+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
void w2_crosswalk_stroll() {
- print("hoi");
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) {
set_motors(15, 15);
@@ -65,6 +71,7 @@ void w2_grid_crossway_detection() {
g_w2_position = read_line(g_w2_sensors, IR_EMITTERS_ON);
}
+//main function for grid mode
void w2_grid_follow_line() {
unsigned int last_proportional = 0;
long integral = 0;
@@ -82,9 +89,9 @@ 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) {
+ 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) {
+ } 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
@@ -106,17 +113,22 @@ void w2_grid_follow_line() {
}
}
+//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
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
void w2_turn_north() {
switch (g_w2_direction) {
case W2_ORT_NORTH:
@@ -175,7 +187,6 @@ void w2_turn_south() {
case W2_ORT_EAST:
w2_grid_rotation_half_right();
- ;
break;
}
@@ -204,16 +215,20 @@ void w2_turn_east() {
g_w2_direction = W2_ORT_EAST;
}
+
+//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) {
clear();
- print("ORDER ");
+ print("PRODUCT");
print_long(g_w2_order_number);
play_frequency(400, 500, 7);
delay(500);
}
}
+
+//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) {
@@ -234,6 +249,7 @@ void w2_go_to_x() {
}
}
+//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) {
@@ -254,6 +270,7 @@ void w2_go_to_y() {
}
}
+//main function for grid mode
void w2_mode_grid() {
set_motors(0, 0);
clear();
@@ -273,6 +290,7 @@ void w2_mode_grid() {
delay(1000);
w2_go_to_x();
w2_go_to_y();
+ w2_arrived_message();
}
w2_end_destination();
@@ -280,61 +298,6 @@ void w2_mode_grid() {
delay(1000);
w2_go_to_y();
w2_go_to_x();
- w2_turn_east(); // this was uncommented (6.3)
+ w2_turn_east();
w2_modes_swap(W2_M_CHRG);
}
-
-/*
-void w2_mode_maze() {
- unsigned int last_proportional = 0;
- long integral = 0;
-
- clear();
- print("MAZE");
-
- g_w2_transition = 0;
-
- // This is the "main loop" - it will run forever.
- while (1) {
- // Get the position of the line. Note that we *must* provide
- // the "sensors" argument to read_line() here, even though we
- // are not interested in the individual sensor readings.
- g_w2_position = read_line(g_w2_sensors, IR_EMITTERS_ON);
-
- // The "proportional" term should be 0 when we are on the line.
- int proportional = ((int)g_w2_position) - 2000;
-
- // Compute the derivative (change) and integral (sum) of the
- // position.
- int derivative = proportional - last_proportional;
- integral += proportional;
-
- // Remember the last position.
- last_proportional = proportional;
-
- // Compute the difference between the two motor power settings,
- // m1 - m2. If this is a positive number the robot will turn
- // to the right. If it is a negative number, the robot will
- // turn to the left, and the magnitude of the number determines
- // the sharpness of the turn.
- int power_difference = proportional / 20 + integral / 10000 + derivative * 3 / 2;
-
- // Compute the actual motor settings. We never set either motor
- // to a negative value.
-
- const int max = 60;
- if (power_difference > max) power_difference = max;
- if (power_difference < -max) power_difference = -max;
-
- if (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) { } else 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) { w2_crossway_detection(); } else if (g_w2_sensors[0] >= 500 && g_w2_sensors[1] >= 200 &&
-g_w2_sensors[4] < 100) { w2_half_rotation_left(); } else { if (power_difference < 0 &&
-(g_w2_sensors[2] > 100 || g_w2_sensors[3] > 100 || g_w2_sensors[1] > 100)) set_motors(max +
-power_difference, max); else if (power_difference > 0 && (g_w2_sensors[2] > 100 || g_w2_sensors[3] >
-100 || g_w2_sensors[1] > 100)) set_motors(max, max - power_difference);
- }
- }
-}
-*/
diff --git a/robot/mode_halt.c b/robot/mode_halt.c
index 083d45b..8bd051e 100644
--- a/robot/mode_halt.c
+++ b/robot/mode_halt.c
@@ -1,4 +1,5 @@
#include "mode_halt.h"
#include "orangutan_shim.h"
+//emergency stop
void w2_mode_halt() { set_motors(0, 0); }
diff --git a/robot/mode_maze.c b/robot/mode_maze.c
index eb75e3c..0350205 100644
--- a/robot/mode_maze.c
+++ b/robot/mode_maze.c
@@ -6,6 +6,8 @@
unsigned int g_w2_last_proportional = 0;
long g_w2_integral = 0;
+
+//main function for maze mode
void w2_mode_maze() {
// PID controller
g_w2_position = read_line(g_w2_sensors, IR_EMITTERS_ON);
@@ -20,14 +22,17 @@ void w2_mode_maze() {
if (power_difference < -max) power_difference = -max;
if (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) {
+ g_w2_sensors[3] < 100 && g_w2_sensors[4] < 100) { //dead ends
w2_crosswalk_stroll();
- } else 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) {
+ }
+ else 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 or intersection
w2_maze_rotation_half_left();
- } else if (g_w2_sensors[0] >= 500 && g_w2_sensors[1] >= 200 && g_w2_sensors[4] < 100) {
+ }
+ else if (g_w2_sensors[0] >= 500 && g_w2_sensors[1] >= 200 && g_w2_sensors[4] < 100) { //left corners
w2_maze_rotation_half_left();
- } else {
+ }
+ else { //normal line following
if (power_difference < 0 &&
(g_w2_sensors[2] > 100 || g_w2_sensors[3] > 100 || g_w2_sensors[1] > 100))
set_motors(max + power_difference, max);
diff --git a/robot/mode_scal.c b/robot/mode_scal.c
index b0efa09..8835183 100644
--- a/robot/mode_scal.c
+++ b/robot/mode_scal.c
@@ -2,6 +2,7 @@
#include "modes.h"
#include "orangutan_shim.h"
+//callibrates the robot
void w2_mode_scal() {
for (int counter = 0; counter < 80; counter++) {
if (counter < 20 || counter >= 60) {
diff --git a/robot/mode_spin.c b/robot/mode_spin.c
index 9ee83b0..79f9dea 100644
--- a/robot/mode_spin.c
+++ b/robot/mode_spin.c
@@ -1,4 +1,6 @@
#include "mode_spin.h"
#include "orangutan_shim.h"
+
+//wet floor simulation
void w2_mode_spin() { set_motors(255, -255); }
diff --git a/robot/modes.c b/robot/modes.c
index 4995d6f..aedc02a 100644
--- a/robot/modes.c
+++ b/robot/modes.c
@@ -16,6 +16,7 @@ w2_e_mode g_w2_mode_history[W2_MODE_HISTORY_BUFFER_SIZE];
uint8_t g_w2_mode_history_index = 0;
void (*g_w2_modes[W2_MODE_COUNT])();
+//all of the different modi
void w2_modes_init() {
g_w2_modes[W2_M_CHRG] = &w2_mode_chrg;
g_w2_modes[W2_M_DIRC] = &w2_mode_dirc;
diff --git a/robot/movement.c b/robot/movement.c
index 61a944b..37d66d5 100644
--- a/robot/movement.c
+++ b/robot/movement.c
@@ -1,9 +1,11 @@
#include "movement.h"
#include "orangutan_shim.h"
-unsigned int g_w2_sensors[5] = {0};
-unsigned int g_w2_position = 0;
+unsigned int g_w2_sensors[5] = {0}; //IR sensors on the bottom of the robot
+unsigned int g_w2_position = 0; //position on the black line
+
+//full rotation maze/charge
void w2_maze_rotation_full() {
set_motors(0, 0);
delay_ms(500);
@@ -14,6 +16,7 @@ void w2_maze_rotation_full() {
delay_ms(500);
}
+//left turn maze/charge
void w2_maze_rotation_half_left() {
set_motors(0, 0);
set_motors(50, 50);
@@ -24,6 +27,8 @@ void w2_maze_rotation_half_left() {
g_w2_position = read_line(g_w2_sensors, IR_EMITTERS_ON);
delay_ms(500);
}
+
+//right turn maze/charge
void w2_maze_rotation_half_right() {
set_motors(0, 0);
set_motors(50, 50);
@@ -37,6 +42,7 @@ void w2_maze_rotation_half_right() {
delay_ms(500);
}
+//180 turn in grid
void w2_grid_rotation_full() {
set_motors(60, -60);
delay_ms(540);
@@ -44,6 +50,7 @@ void w2_grid_rotation_full() {
g_w2_position = read_line(g_w2_sensors, IR_EMITTERS_ON);
}
+//left turn in grid
void w2_grid_rotation_half_left() {
set_motors(-30, 30);
delay_ms(600);
@@ -51,6 +58,7 @@ void w2_grid_rotation_half_left() {
g_w2_position = read_line(g_w2_sensors, IR_EMITTERS_ON);
}
+//right turn in grid
void w2_grid_rotation_half_right() {
set_motors(30, -30);
delay_ms(600);