AST_Monitor package - API

AST-Monitor — A wearable Raspberry Pi computer for cyclists

Basic data module

class basic_data.BasicData(hr_data_path: str, gps_data_path: str)

Bases: object

Class for storing and tracking the basic training data in real time.

Parameters:
  • hr_data_path (str) – path to the file that contains HR data

  • gps_data_path (str) – path to the file that contains GPS data

calculate_speed() None

Calculating the speed between the previous and the current trackpoint.

read_current_gps() None

Reading the current GPS position from the file.

read_current_hr() None

Reading the current HR from the file.

Digital Twin module

class digital_twin.DigitalTwin(proposed_heart_rate: int, duration: int, tick_time: float, basic_data)

Bases: object

Class that represents a digital twin that uses a mathematical prediction model to analyze an exercise in the real time.

Parameters:
  • predicted_heart_rate (int) – a predicted heart rate of an interval (speed or rest segment) in beats per minute

  • duration (int) – duration of an interval in minutes

calculate_prediction(trimp_delta: float, average_heart_rate: float, proposed_heart_rate: int, time_delta: float, expected_trackpoints: int) float

Calculating the predicted heart rate.

Parameters:
  • trimp_delta (float) – the calculated TRIMP difference

  • average_heart_rate (float) – the average heart rate of the interval in beats per minute

  • proposed_heart_rate (int) – the proposed heart rate of the interval in beats per minute

  • time_delta (float) – the time difference in seconds

  • expected_trackpoints (int) – the number of expected trackpoints

Returns:

the proposed heart rate

Return type:

float

predict_heart_rate() None

Digital twin algorithm that monitors the athlete performance in the real time and calculates the predicted heart rate.

read_control_data() tuple

Reading the current heart rate and the interval duration.

Returns:

current heart rate, current duration

Return type:

tuple[int, float]

GPS Sensor module

class gps_sensor.GpsSensor(gps_path: str = 'sensor_data/gps.txt')

Bases: object

Class for working with GPS sensor.

Parameters:

gps_path (str) – path to file for storing GPS data

get_gps_data() None

Method for listening the channel for obtaining GPS data from sensor.

Note: Example is based on source code from

https://github.com/adafruit/Adafruit_CircuitPython_GPS

write_gps_data_to_file(longitude: float, latitude: float, altitude: float) None

Method for writing GPS data to text file.

Parameters:
  • longitude (float) – longitude on Earth

  • latitude (float) – latitude on Earth

  • altitude (float) – current altitude

HR Sensor module

class hr_sensor.HrSensor(hr_path='sensor_data/hr.txt')

Bases: object

Class for working with HR sensor.

Parameters:

hr_path (str) – path to file for storing HR data

get_hr_data() None

Method for listening the channel for obtaining HR data from sensor.

Note: Example is based on source code from

https://github.com/Tigge/openant/blob/master/examples/heart_rate_monitor.py

on_data(data) None

Extracting and writing heart rate data to file.

Parameters:

() (data) – list that contains heart rate

write_hr_data_to_file(hr: int) None

Method for writing hr data to text file.

Parameters:

hr (int) – heart rate

Interval Training module

Main Window module

class mainwindow.Ui_MainWindow

Bases: object

retranslateUi(MainWindow)
setupUi(MainWindow)

Model module

Simulation module

Training Session module

class training_session.TrainingSession

Bases: object

Class for tracking training sessions.

add_ascent(current_elevation: float) None

Adding to the total ascent.

Parameters:

current_elevation (float) – current elevation in meters

add_distance(distance: float) None

Adding to the total distance.

Parameters:

distance (float) – distance in meters

calculate_time() None

Method for calculating the current time of the session.

Write log module

class write_log.WriteLog

Bases: object

Class for writing log.

static write_interval_training_header(file: str)

Method for writing interval training header.

Parameters:

file – str path to the log file

static write_interval_training_trackpoint(file: str, digital_twin)

Method for writing interval training trackpoint.

Parameters:
  • file – str path to the log file

  • digital_twin – DigitalTwin the Digital Twin