Commit 5ae843a7 authored by Patric Schmitz's avatar Patric Schmitz

add manual gain mode for second experiment (pascale november 2017)

parent c1724f73
......@@ -36,7 +36,7 @@ namespace {
const float targetDistanceMin = 1.f;
float gainIncrement = 0.f;
float gainIncrementMagnitude = 0.1f/3.f;
float gainIncrementMagnitude = 0.1f/2.f;
}
AcousticThresholdExperiment::AcousticThresholdExperiment(
......@@ -112,7 +112,7 @@ void AcousticThresholdExperiment::reset() {
LogError("gain: " + to_string(kinematic.getRotationGain()));
LogError("gainIncrement: " + to_string(gainIncrement));
sendAcousticTransform();
// sendAcousticTransform();
}
void AcousticThresholdExperiment::startTrial() {
......@@ -133,15 +133,26 @@ void AcousticThresholdExperiment::frameTrial() {
if(glm::distance(headOnGround,
targets[0]->getPosition()) < targetActiveRadius) {
dataCapture.LogTargetCollected(kinematic, targets[0]->getPosition());
targetCollected();
placeTargets();
// sendAcousticTransform();
}
}
void AcousticThresholdExperiment::targetCollected() {
dataCapture.LogTargetCollected(kinematic, targets[0]->getPosition());
placeTargets();
if(mode == E1Continuous) {
kinematic.setRotationGain(
kinematic.getRotationGain() + gainIncrement);
LogError("gain: " + to_string(kinematic.getRotationGain()));
sendAcousticTransform();
}
else if(mode == E2Manual) {
kinematic.setRotationGain(newGainAfterTarget);
//newGainAfterTarget = 1.f;
LogError("gain: " + to_string(kinematic.getRotationGain()));
}
}
......@@ -253,33 +264,50 @@ void AcousticThresholdExperiment::setupControlServer() {
auto bytes_received = read(socket, buffer.data(), sizeof(buffer) - 1);
if (bytes_received >= 2) {
if(buffer[0] == 'r')
// if(buffer[0] == 'c')
// {
// mode = E1Continuous;
// reset();
// LogError("set to mode: CONTINUOUS (gain
// }
if(buffer[0] == 'm')
{
float gain = float(strtod(buffer.data() + 2, nullptr));
dataCapture.LogUserReset(gain);
LogError("User reset: " + to_string(gain));
newGainAfterTarget = gain;
defaultRotationGain = 1.f;
mode = E2Manual;
LogError("set to mode: MANUAL (gain " + to_string(gain) + ")");
}
// if(buffer[0] == 'r')
// {
// // float gain = float(strtod(buffer.data() + 2, nullptr));
// // dataCapture.LogUserReset(gain);
// // LogError("User reset: " + to_string(gain));
// }
else if(buffer[0] == 's')
{
targetStartActive = true;
} else
{
bool gain_up = (buffer[0] == '1');
bool radio_shown = (buffer[1] == '1');
bool gain_inc = (buffer[0] == '1');
float gain = float(strtod(buffer.data() + 3, nullptr));
float gain = float(strtod(buffer.data() + 2, nullptr));
if (gain != 0.f)
{
defaultRotationGain = gain;
}
gainIncreasing = gain_up;
mode = E1Continuous;
// LogError("set to mode: CONTINUOUS (gain
gainIncreasing = gain_inc;
gainIncrement = (gainIncreasing ? 1.f : -1.f) *
gainIncrementMagnitude;
if (radioModel) radioModel->setVisible(radio_shown);
LogError("AcousticThresholdExperiment: received update");
// if (radioModel) radioModel->setVisible(radio_shown);
// LogError("AcousticThresholdExperiment: received update");
LogError("gainIncrement: " + to_string(gainIncrement));
LogError("radio visible: " + to_string(radio_shown));
// LogError("radio visible: " + to_string(radio_shown));
}
} else {
//close(socket);
......
......@@ -34,6 +34,11 @@ public:
void setRadioModel(Model* model) { radioModel = model; }
private:
enum Mode {
E1Continuous,
E2Manual
};
void startTrial();
void frameTrial();
......@@ -47,6 +52,8 @@ private:
void sendAcousticTransform();
void setupControlServer();
void targetCollected();
bool trialRunning;
std::unique_ptr<PlayerTarget> targetStart;
......@@ -65,6 +72,10 @@ private:
Model* radioModel = nullptr;
DataCaptureManager& dataCapture;
Mode mode = E1Continuous;
// int numTargetsUntilGainChange = 0;
float newGainAfterTarget = 1.0f;
};
#endif //GEARVRAPP_ACOUSTICTHRESHOLDEXPERIMENT_H
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment