[chronojump: 1/2] Revert "Merge branch 'master' of gitlab.gnome.org:GNOME/chronojump"
- From: Daniel Garcia Moreno <danigm src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [chronojump: 1/2] Revert "Merge branch 'master' of gitlab.gnome.org:GNOME/chronojump"
- Date: Wed, 23 Oct 2019 08:56:37 +0000 (UTC)
commit 9811ba8a464272403afd9a3249821c2dcf181dba
Author: Daniel GarcĂa Moreno <dani danigm net>
Date: Wed Oct 23 10:48:00 2019 +0200
Revert "Merge branch 'master' of gitlab.gnome.org:GNOME/chronojump"
This reverts commit d6001e7cd41c2be6b801bafe9f649d208c033143, reversing
changes made to b532f0026ffa87b39e4a18e691f77f98883506ae.
arduino/raceAnalyzer/raceAnalyzer.ino | 92 ++++++++++++++---------------------
r-scripts/forcePosition.R | 27 ++++------
2 files changed, 46 insertions(+), 73 deletions(-)
---
diff --git a/arduino/raceAnalyzer/raceAnalyzer.ino b/arduino/raceAnalyzer/raceAnalyzer.ino
index f9b533ab..5e3f82f9 100644
--- a/arduino/raceAnalyzer/raceAnalyzer.ino
+++ b/arduino/raceAnalyzer/raceAnalyzer.ino
@@ -2,10 +2,9 @@
#include <Adafruit_ADS1015.h>
#include <EEPROM.h>
-//TODO: Test the Texas Instrument ADS1256
Adafruit_ADS1115 loadCell;
-int encoderPinA = 3; //Pin associated with the encoder interruption
+int encoderPinA = 3;
int encoderPinB = 4;
volatile int encoderDisplacement = 0;
int lastEncoderDisplacement = 0;
@@ -16,7 +15,7 @@ unsigned long lastSampleTime = micros();
unsigned long sampleTime = 0;
//Version of the firmware
-String version = "Race_Analyzer-0.2";
+String version = "Race_Analyzer-0.1";
int pps = 10; //Pulses Per Sample. How many pulses are needed to get a sample
int ppsAddress = 0; //Where is stored the pps value in the EEPROM
@@ -27,7 +26,7 @@ int offsetAddress = 2;
float calibrationFactor = 0.140142;
int calibrationAddress = 4;
-float metersPerPulse = 0.003003; //Value for the manual race encoder
+float metersPerPulse = 0.003003;
int metersPerPulseAddress = 8;
//Wether the sensor has to capture or not
@@ -40,10 +39,7 @@ boolean procesSample = false;
boolean binaryFormat = false;
//baud rate of the serial communication
-unsigned long baudRate = 2000000;
-
-//Number of samples sent. Just for debugging
-int samplesSent = 0;
+unsigned long baudRate = 1000000;
void setup() {
@@ -83,7 +79,7 @@ void setup() {
//if metersPerPulse is not a number it means that it has never been set. We use the default value
if (isnan(metersPerPulse)){
- metersPerPulse = 0.003003;
+ metersPerPulse = 0.140142;
EEPROM.put(metersPerPulseAddress, metersPerPulse);
}
@@ -95,6 +91,7 @@ void setup() {
}
void loop() {
+ //double totalForce = 0;
long int totalForce = 0;
int nReadings = 0;
int offsettedData = 0;
@@ -104,15 +101,16 @@ void loop() {
if (capturing)
{
- //TODO: If the value of the force is negative, send a 0
+ //With a diameter is of 160mm, each pulse is 2.513274mm. 4 pulses equals 1.00531cm
while (!procesSample) {
offsettedData = readOffsettedData(0);
//Serial.println(offsettedData);
totalForce += offsettedData;
+ //force = readOffsettedData(0);
+ //totalForce += force;
nReadings++;
//If some string comes from Serial process the sample
- //This makes that the sample after getting the command "end_capture:" has less pulses than pps
if (Serial.available() > 0) {
sampleTime = micros();
lastEncoderDisplacement = encoderDisplacement;
@@ -121,6 +119,8 @@ void loop() {
}
}
+ //int lastEncoderDisplacement = encoderDisplacement; //Assigned to another variable for in the case that
encoder displacement changes before printing it
+
//Managing the timer overflow
if (sampleTime > lastSampleTime) //No overflow
{
@@ -134,28 +134,24 @@ void loop() {
lastSampleTime = sampleTime;
//Sending in text mode
-// Serial.print(lastEncoderDisplacement);
-// Serial.print(";");
-// Serial.print(totalTime);
-// Serial.print(";");
-// Serial.println(totalForce / nReadings);
-
-
- //Sending in binary mode
- //sendInt(lastEncoderDisplacement);
- sendLong(totalTime);
- //sendInt(offsettedData);
- sendInt(514);
-
- //End of the binari sample
-// Serial.write(0xff);
-// Serial.write(0xff);
-// Serial.write(0xff);
-// Serial.write(0xff);
+ Serial.print(lastEncoderDisplacement);
+ Serial.print(";");
+ Serial.print(totalTime);
+ Serial.print(";");
+ Serial.println(totalForce / nReadings);
-
- procesSample = false; //Keep acumulating pulses without processing the sample until [pps] samples
is reached
- samplesSent++;
+ procesSample = false;
+
+ // //Sending in binary mode
+ // sendInt(lastEncoderDisplacement);
+ // sendInt(totalTime);
+ // sendInt(offsettedData);
+ //
+ // //End of the binari sample
+ // Serial.write(0xff);
+ // Serial.write(0xff);
+ // Serial.write(0xff);
+ // Serial.write(0xff);
}
}
@@ -164,11 +160,11 @@ void changingA() {
changingTime = micros();
if (digitalRead(encoderPinB) == HIGH) {
encoderDisplacement--;
+ //digitalWrite(13, HIGH);
} else {
encoderDisplacement++;
+ //digitalWrite(13, LOW);
}
-
- //Checking if the number of pulses equals the pulses per sample (clockwise or couterclockwise)
if (abs(encoderDisplacement) >= pps) {
lastEncoderDisplacement = encoderDisplacement; //We need to save this value because it can change very
quickly
sampleTime = changingTime; //We need to save this value because it can change very
quickly
@@ -226,25 +222,18 @@ void serialEvent()
void start_capture()
{
- Serial.print("Starting capture;PPS:");
- Serial.println(pps);
+ Serial.println("Starting capture...");
totalTime = 0;
lastSampleTime = micros();
sampleTime = lastSampleTime + 1;
//First sample with a low speed is mandatory to good detection of the start
-
-// Serial.print(0);
-// Serial.print(";");
-// Serial.print(1);
-// Serial.print(";");
-// Serial.println(0);
-
- //sendInt(0);
- sendLong(1);
- sendInt(514); //Fake force. Fixed number for debugging
-
+ Serial.print(0);
+ Serial.print(";");
+ Serial.print(1);
+ Serial.print(";");
+ Serial.println(0);
capturing = true;
encoderDisplacement = 0;
}
@@ -252,13 +241,7 @@ void start_capture()
void end_capture()
{
capturing = false;
-
- //sendLong(4294967295);
- //sendInt(32767);
- Serial.print("\nCapture ended. Samples sent: ");
- Serial.println(samplesSent);
- Serial.print("TotalTime :");
- Serial.println(totalTime);
+ Serial.println("Capture ended");
}
void get_version()
@@ -437,7 +420,6 @@ void set_baud_rate(String inputString)
Serial.println(baudRate);
}
-//TODO: Write in binary mode
void start_simulation(void)
{
float vmax = 10.0;
diff --git a/r-scripts/forcePosition.R b/r-scripts/forcePosition.R
index 7db1c2bf..205000f6 100644
--- a/r-scripts/forcePosition.R
+++ b/r-scripts/forcePosition.R
@@ -6,7 +6,7 @@ getDynamicsFromForceSensor <- function(file = "/home/xpadulles/.local/share/Chro
stiffness = 71.93, #71.93 N/m measured in the black rubber
angle = 0,
smooth = 5,
- conMinDisplacement = 0.1, eccMinDisplacement = 0.1
+ minDisplacement = 0.1
)
{
forceSensor = read.csv(file, sep =";", dec = ",", header = TRUE)
@@ -72,7 +72,7 @@ getDynamicsFromForceSensor <- function(file = "/home/xpadulles/.local/share/Chro
# par(new = T)
#Getting the basic information of each repetition
- repetitions = getRepetitions(dynamics[, "time"], dynamics[, "position"], dynamics[, "rawForce"],
conMinDisplacement, eccMinDisplacement)
+ repetitions = getRepetitions(dynamics[, "time"], dynamics[, "position"], dynamics[, "rawForce"],
minDisplacement)
plot(#dynamics[, "time"]
dynamics[, "position"]
@@ -113,7 +113,7 @@ getDynamicsFromForceSensor <- function(file = "/home/xpadulles/.local/share/Chro
)
}
-getRepetitions <- function(time, position, force, conMinDisplacement, eccMinDisplacement){
+getRepetitions <- function(time, position, force, minDisplacement){
#The comments supposes that the current phase is concentric. In the case that the phase is eccentric
#the signal is inverted by multiplying it by -1.
@@ -138,13 +138,7 @@ getRepetitions <- function(time, position, force, conMinDisplacement, eccMinDisp
#Detecting the first phase type
if(position[currentSample] > position[possibleExtremeSample])
- {
- concentric = 1
- minDisplacement = eccMinDisplacement
-
- } else {
- concentric = -1
- minDisplacement = conMinDisplacement}
+ {concentric = 1} else {concentric = -1}
#print(paste("starting in mode:", concentric) )
@@ -179,11 +173,7 @@ getRepetitions <- function(time, position, force, conMinDisplacement, eccMinDisp
#Changing the phase from concentric to eccentril or viceversa
concentric = -concentric
- if (concentric == 1){
- minDisplacement = eccMinDisplacement
- } else {
- minDisplacement = conMinDisplacement
- }
+ # print(paste("Current phase is", concentric))
#Calculate mean RFD and mean speed of the phase
lastRFD = (force[currentSample] - force[lastExtremeSample]) / (time[currentSample] -
time[lastExtremeSample])
@@ -201,11 +191,12 @@ getRepetitions <- function(time, position, force, conMinDisplacement, eccMinDisp
, meanSpeeds = meanSpeeds[2:length(meanSpeeds)]))
}
-testDir = "/home/xpadulles/Descargas/Piscina-mati/separat-per-punticoma/"
-allFiles = dir(testDir)
+testDir = "/home/xpadulles/chronojump/r-scripts/tests/"
+allFiles = dir("/home/xpadulles/chronojump/r-scripts/tests/")
-for(i in 1:5)
+for(i in 1:length(allFiles))
{
dynamics = getDynamicsFromForceSensor(file = paste(testDir, allFiles[i], sep ="")
,smooth = 10, totalMass = 0, stiffness = 71.93, angle = 0,
minDisplacement = .5)
}
+
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]