maelstrom is a library for PROS. Made to access data and information in cases where the robot can’t be connected to a computer and so that data can be accessed at a later time, even when the program is terminated. Developed by Gaston from V5RC Team 6104G Tempest
In the integrated PROS terminal, run the command pros c add-depot maelstrom https://lunar-eclipse255.github.io/maelstrom/template.json
cd
into your pros project
Make sure you are in the kernel version 4.1.0, your version can be found out with pros c info-project
Apply the library to the project with pros c apply maelstrom
Put #include "maelstrom/api.hpp"
in your main.h
To get the library/template, head over to the releases page and download maelstrom@
Move the zip file to the pros project
Make sure you are in the kernel version 4.1.0, your version can be found out with pros c info-project
Run pros c fetch maelstrom@<version>.zip
in order to import the template
Apply the library to the project with pros c apply maelstrom
Put #include "maelstrom/api.hpp"
in your main.h
From this Github repository download the folder called logs
Put that folder in the root of the SD Card
In the root of the SD Card make a folder called logs
In the folder logs make a file called run_nums.txt
On the first line of run_nums.txt write R0
initialize()
in main.cpp call init()
:
init(bool run_error_log, bool run_data_log, std::vector<int> left_motor_ports, std::vector<int> right_motor_ports, int battery_threshold);
std::vector<int> left_motor_ports
`` is for inputting the ports of your left motors in the form of a std::vectorstd::vector<int> right_motor_ports
` is for inputting the ports of your right motors in the form of a std::vectorint battery_threshold
is for inputting at what battery level do you want to be warned about std::vector<int> left_motors = {1, -2, 3};
std::vector<int> right_motors = {-4, 5, -6};
maelstrom::logging::init(true, true, left_motors, right_motors, 50);
initialize()
use this code to run the error logger in background of autonomous and driver control.
pros::Task error_logger(maelstrom::logging::robot_faults_log);
opcontrol()
and before the while (true)
loop put this line of code that in the background writes to the data log file the current coordinates of the robot:
pros::Task coords_logging(maelstrom::logging::robot_coords_log);
opcontrol()
but inside the while (true)
loop call this function that updates the coordinates that maelstrom::logging::robot_coords_log()
uses
void set_robot_coords(double x, double y, double theta);
maelstrom::logging::set_robot_coords(x_pos, y_pos, theta_heading);
maelstrom::logging::write_to_file(std::string message, log_file file);
this function can be used to write a message to either the log or error file
E_ERROR_LOG
to write to the error log file and E_DATA_LOG
to write to the data log file. maelstrom::logging::write_to_file("Good Luck", maelstrom::logging::E_DATA_LOG);
task_complete(std::string task_name, bool completion);
to write to the error log file if a task was completed or not
maelstrom::logging::task_complete("Auton", auton_complete);
would write Auton Complete
to the error log file if auton_complete was true, and Auton Incomplete
if auton_complete was false
battery(int battery_threshold);
can be used to see if the battery percentage is lower than an int threshold. This funtion is used in robot_faults_log()
to logto the error log file if the battery is too low but can also be used seperately
maelstrom::logging::battery(50);
motor_connected(int port);
can be used to get if a motor is disconnected at a port specified by int port
. It will return true if the motor is connected and false if the motor is disconnected. This funtion is used in robot_faults_log()
to log to the error log file if a drive motor is disconnected but can also be used seperately
maelstrom::logging::motor_connected(20);
get_current_date_time();
returns the time since the program began in a std::string in the format minutes:seconds:milliseconds
for example 1:50:55
maelstrom::logging::get_current_date_time();
init()
:
* PROS Brain Terminal Error Messages: * When the program starts there are three error message that could appear in the Brain terminal, “Somethings is wrong with run_nums.txt”, where something is wrong with the file, often caused if the SD Card isn’t plugged in or thi file doesn’t exist. There is also, “Somethings is wrong with error_logfile”, which appears when the error logfile couldn’t be created. Lastly there is, “Somethings is wrong with data_logfile” where the data logfile couldn’t be created. If any of these error happen it will appear in the Brain Terminal and return false to the init function, so undefined behavior doesn’t happen from later functions trying to access these files.
robot_faults_log()
:
When the controller enters autonomous mode this message will display on the error logfile, along with a timestamp in the format minute:second:millisecond
When the controller enters driver mode (opcontrol) this message will display on the error logfile, along with a timestamp
These next four are motor faults. These faults were all simulated in the code due to most of them coming up rarely. This was done by telling the program that the motors had these faults even though it didn’t. All cases were tested with the simulation (0x00-0x0F). So far only Over Temp and No faults has been proven to work in reality. The progress of this can be tracked in Issue #11. Even though they haven’t been tested in reality they should work.
This error message is written to the error logfile when a motor is overheated, along with the motor that is overheated. An all clear message is sent when the motor is back to a normal temperature. Both messages are accompanied with a timestamp.
This error message is written to the error logfile when a motor has a H-Bridge fault, along with which motor has the fault. An all clear message is sent when the motor is back to normal. Both messages are accompanied with a timestamp.
This error message is written to the error logfile if a motor is taking too much current, along with which motor that is over current. An all clear message is sent when the motor is back to a normal current. Both messages are accompanied with a timestamp.
This error message is written to the error logfile if too much current is flowing through an H-Bridge of a motor, along with which motor that this is affecting. An all clear message is sent when the H-Bridge is back to a normal current. Both messages are accompanied with a timestamp.
A message is written to the error logfile when a drive motor (specified in the init()
function) disconnects, along with the port of the motor. A message is also written when the motor reconnects. This also works for drive motors that were disconnected before the program started. This is accompanied with a timestamp.
A message is written to the error logfile when the battery is below the threshold specified in the init()
function. This is accompanied with a timestamp.
robot_coords_log()
This function writes the current coords of the robot (given by the user) to the data logfile every 0.5s. This is accompanied with a timestamp.
write_to_file()
task_complete()
This function writes to the error logfile that a task was complete or incomplete, task name, and boolean given by user. This is accompanied by a timestamp.
Every function except for maelstrom::logging::motor_connected()
, maelstrom::logging::get_current_date_time()
, maelstrom::logging::battery()
, and maelstrom::logging::set_robot_coords()
needs the function maelstrom::logging::init()
to have been called
maelstrom::logging::robot_coords_log()
needs maelstrom::logging::set_robot_coords()
to update the coordinates or maelstrom::logging::robot_coords_log()
will always log the coordinates as NaN
You can contact me through Discord if any issues arise, I am Gaston | 6104G on many VEX Discord Servers.