Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
training.cpp
- Committer:
- MarcelPortmann
- Date:
- 2020-05-17
- Revision:
- 4:4e871024310a
- Parent:
- 2:0df0d0be0664
- Child:
- 5:da9b6946a035
File content as of revision 4:4e871024310a:
/*
Hear cold stand a discription
*/
#include "training.h"
//#include "math.h"
training::training()
{
fail_pos = 0;
time_short = 0;
time_long = 0;
}
void training::load_training(string name)
{
int i = 0;
tr_name = name;
int sice = 50;
//sice = loading.size(tr_name)
for(i = 0; i<sice; i++) { // loads the whole trainings data into data vector
loading.AuslesenPositionsdaten(tr_name,i);
temp.time = loading.zahl[0];
temp.pos[0] = loading.zahl[1];
temp.pos[1] = loading.zahl[2];
temp.pos[2] = loading.zahl[3];
temp.start = loading.zahl[4]; // fragen wegen status eintrag
temp.end = loading.zahl[5];
data_vec.push_back(temp);
}
}
void training::start_training(void)
{
fail_pos = 0;
time_short = 0;
time_long = 0;
point_count = 0;
repet = 0;
}
int training::compire_point(float posx,float posy,float posz, int time)
{
float temp_pos[3] = {};
float dist = 0, timediv = 0;
int resetval = 0;
if(data_vec[point_count].start) { // counts the repetitions
repet++;
resetval = 1;
}
temp_pos[0] = posx - data_vec[point_count].pos[0]; // calculates distance curent to needed
temp_pos[1] = posx - data_vec[point_count].pos[1];
temp_pos[2] = posx - data_vec[point_count].pos[2];
dist = sqrt(pow(temp_pos[0],2)+pow(temp_pos[1],2)+pow(temp_pos[2],2));
if(dist>= POSTOL) { // counts position fail
fail_pos++;
}
if(data_vec[point_count].end) { // counts time too short and time too long
resetval = 2;
timediv = time - (data_vec[point_count].time);
if(timediv>=TIMETOL) {
time_long++;
}
if(timediv<=(-TIMETOL)) {
time_short++;
}
}
point_count++;
if(point_count>= data_vec.size()) { // resets the piontecount after a complet cycle
point_count = 0;
}
return resetval;
}
int* training::get_status(void)
{
status_array[0] = fail_pos;
status_array[1] = time_short;
status_array[2] = time_long;
status_array[3] = repet;
return status_array;
}
void training::end_training(string name)
{
// writhe status to memory / update memory
fail_pos = 0;
time_short = 0;
time_long = 0;
point_count = 0;
repet = 0;
data_vec.clear();
}