Skip to content

Commit

Permalink
Merge branch 'develop'
Browse files Browse the repository at this point in the history
  • Loading branch information
balandinodidonato committed Dec 10, 2016
2 parents 09daff0 + 2bdc196 commit 682c0f5
Show file tree
Hide file tree
Showing 9 changed files with 86 additions and 123 deletions.
4 changes: 2 additions & 2 deletions Myo Mapper/Builds/MacOSX/Info-App.plist
Original file line number Diff line number Diff line change
Expand Up @@ -15,11 +15,11 @@
<key>CFBundlePackageType</key>
<string>APPL</string>
<key>CFBundleShortVersionString</key>
<string>2.2.6</string>
<string>2.4.6</string>
<key>CFBundleSignature</key>
<string>????</string>
<key>CFBundleVersion</key>
<string>2.2.6.22</string>
<string>2.4.6.40</string>
<key>LSApplicationCategoryType</key>
<string>public.app-category.music</string>
<key>NSHighResolutionCapable</key>
Expand Down
2 changes: 1 addition & 1 deletion Myo Mapper/Source/MainComponent.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,7 @@ void MainComponent::timerCallback()
orientation.setValues(myoData[id].orientationRaw);
pose.setPoseLabel(myoData[id].pose+" - "+String(myoData[id].poseID));

osc.sendOSC(id, myoData[id].emgRaw, myoData[id].emgScaled, myoData[id].mav, myoData[id].mavWfL, myoData[id].gyro, myoData[id].gyroWl, myoData[id].acceleration, myoData[id].accelerationWl, myoData[id].orientationRaw, orientation.getValue(), orientation.getWl(), myoData[id].pose, myoData[id].poseID);
osc.sendOSC(id, myoData[id].emgRaw, myoData[id].emgScaled, myoData[id].emgScaledAbs, myoData[id].mav, myoData[id].mavWfL, myoData[id].gyro, myoData[id].gyroWfL, myoData[id].gyroScaled, myoData[id].gyroScaledWfL, myoData[id].acceleration, myoData[id].accelerationWfL, myoData[id].accelerationScaled, myoData[id].accelerationScaledWfL, myoData[id].orientationRaw, orientation.getValue(), orientation.getWl(), myoData[id].pose, myoData[id].poseID);


if(osc.vibrate)
Expand Down
12 changes: 9 additions & 3 deletions Myo Mapper/Source/MyoData.h
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,18 @@ struct MyoData
{
std::array<int8_t, 8> emgRaw;
std::array<float, 8> emgScaled;
std::array<float, 8> emgScaledAbs;
Vector3D< float > gyro;
Vector3D< float > gyroWl;
Vector3D< float > gyroScaled;
Vector3D< float > gyroWfL;
Vector3D< float > gyroScaledWfL;
Vector3D< float > acceleration;
Vector3D< float > accelerationWl;
Vector3D< float > orientationScaled;
Vector3D< float > accelerationScaled;
Vector3D< float > accelerationWfL;
Vector3D< float > accelerationScaledWfL;
Vector3D< float > orientationRaw;
Vector3D< float > orientationScaled;
Vector3D< float > orientationScaledWfL;
String pose;
int poseID;
float mav;
Expand Down
33 changes: 25 additions & 8 deletions Myo Mapper/Source/MyoListener.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -97,25 +97,41 @@ void MyoListener::onAccelerometerData(myo::Myo* myo, uint64_t timestamp, const m
{
int myoID = getMyoID(myo);
if(myoID == -1) return;

myoData[myoID].acceleration.x = accel.x();
myoData[myoID].acceleration.y = accel.y();
myoData[myoID].acceleration.z = accel.z();
myoData[myoID].acceleration.y = accel.x();
myoData[myoID].acceleration.z = accel.x();

myoData[myoID].accelerationScaled.x = (accel.x()+16)*0.03125;
myoData[myoID].accelerationScaled.y = (accel.y()+16)*0.03125;
myoData[myoID].accelerationScaled.z = (accel.z()+16)*0.03125;

accWfL.set3DValue(myoData[myoID].acceleration);
myoData[myoID].accelerationWl = accWfL.get3DValue();
myoData[myoID].accelerationWfL = accWfL.get3DValue();

accScaledWfL.set3DValue(myoData[myoID].accelerationScaled);
myoData[myoID].accelerationScaledWfL = accScaledWfL.get3DValue();
}

void MyoListener::onGyroscopeData(myo::Myo* myo, uint64_t timestamp, const myo::Vector3<float>& gyro)
{

int myoID = getMyoID(myo);
if(myoID == -1) return;

myoData[myoID].gyro.x = gyro.x();
myoData[myoID].gyro.y = gyro.y();
myoData[myoID].gyro.z = gyro.z();

myoData[myoID].gyroScaled.x = (gyro.x()+2000)* 0.00025;
myoData[myoID].gyroScaled.y = (gyro.y()+2000)* 0.00025;
myoData[myoID].gyroScaled.z = (gyro.z()+2000)* 0.00025;

gyroWfL.set3DValue(myoData[myoID].gyro);
myoData[myoID].gyroWl = gyroWfL.get3DValue();
myoData[myoID].gyroWfL = gyroWfL.get3DValue();

gyroScaledWfL.set3DValue(myoData[myoID].gyroScaled);
myoData[myoID].gyroScaledWfL = gyroScaledWfL.get3DValue();

}

Expand Down Expand Up @@ -157,8 +173,9 @@ void MyoListener::onEmgData(myo::Myo* myo, uint64_t timestamp, const int8_t* emg

for (size_t i = 0; i < 8; i++) {
myoData[myoID].emgRaw[i] = emg[i];
myoData[myoID].emgScaled[i] = abs(emg[i])*0.0078125f;
emgSum = emgSum + myoData[myoID].emgScaled[i];
myoData[myoID].emgScaled[i] = (emg[i]+127)*0.003921568627;
myoData[myoID].emgScaledAbs[i] = std::abs(emg[i]*0.0078125);
emgSum = emgSum + myoData[myoID].emgScaledAbs[i];
}

myoData[myoID].mav = emgSum * 0.125;
Expand Down
6 changes: 6 additions & 0 deletions Myo Mapper/Source/MyoListener.h
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,13 @@ class MyoListener : public myo::DeviceListener

WaveformLength accWfL;
WaveformLength gyroWfL;

WaveformLength accScaledWfL;
WaveformLength gyroScaledWfL;

WaveformLength mavWfL;


};


Expand Down
42 changes: 27 additions & 15 deletions Myo Mapper/Source/OSC.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -65,41 +65,53 @@ void OSC::setSender(String HostAddress, int Port){
void OSC::sendOSC(int id,
std::array<int8_t, 8> emgRaw,
std::array<float, 8> emgScaled,
std::array<float, 8> emgScaledAbs,
float mav,
float mavWl,
Vector3D< float > gyro,
Vector3D< float > gyroWl,
Vector3D< float > gyroWfL,
Vector3D< float > gyroScaled,
Vector3D< float > gyroScaledWfL,
Vector3D< float > acceleration,
Vector3D< float > accelerationWl,
Vector3D< float > accelerationWfL,
Vector3D< float > accelerationScaled,
Vector3D< float > accelerationScaledWfL,
Vector3D< float > orientationRaw,
Vector3D< float > orientationScaled,
Vector3D< float > orientationWl,
Vector3D< float > orientationWfL,
String pose,
int poseID
)
{
String ID = String (id);

sender.send ("/myo"+ID+"/EMG/raw", (int) emgRaw[0], (int) emgRaw[1], (int) emgRaw[2], (int) emgRaw[3], (int) emgRaw[4], (int) emgRaw[5], (int) emgRaw[6], (int) emgRaw[7]);
sender.send ("/myo"+ID+"/EMG/scaled", (float) emgScaled[0], (float) emgScaled[1], (float) emgScaled[2], (float) emgScaled[3], (float) emgScaled[4], (float) emgScaled[5], (float) emgScaled[6], (float) emgScaled[7]);
sender.send("/myo"+ID+"/EMGs/mav", (float) mav);
sender.send("/myo"+ID+"/EMGs/wl", (float) mavWl);
sender.send("/myo"+ID+"/orientation/raw", (float) orientationRaw.x, (float) orientationRaw.y, (float) orientationRaw.z);
sender.send("/myo"+ID+"/orientation/scaled", (float) orientationScaled.x, (float) orientationScaled.y, (float) orientationScaled.z);
sender.send("/myo"+ID+"/orientation/scaledWfL", (float) orientationWfL.x, (float) orientationWfL.y, (float) orientationWfL.z);

sender.send("/myo"+ID+"/gyro/raw", (float) gyro.x, (float) gyro.y, (float) gyro.z);
sender.send("/myo"+ID+"/gyro/wl", (float) gyroWl.x, (float) gyroWl.y, (float) gyroWl.z);
sender.send("/myo"+ID+"/gyro/rawWfL", (float) gyroWfL.x, (float) gyroWfL.y, (float) gyroWfL.z);
sender.send("/myo"+ID+"/gyro/scaled", (float) gyroScaled.x, (float) gyroScaled.y, (float) gyroScaled.z);
sender.send("/myo"+ID+"/gyro/scaledWfL", (float) gyroScaledWfL.x, (float) gyroScaledWfL.y, (float) gyroScaledWfL.z);

sender.send("/myo"+ID+"/acceleration/raw", (float) acceleration.x, (float) acceleration.y, (float) acceleration.z);
sender.send("/myo"+ID+"/acceleration/wl", (float) accelerationWl.x, (float) accelerationWl.y, (float) accelerationWl.z);
sender.send("/myo"+ID+"/acceleration/rawWfL", (float) accelerationWfL.x, (float) accelerationWfL.y, (float) accelerationWfL.z);
sender.send("/myo"+ID+"/acceleration/scaled", (float) accelerationScaled.x, (float) accelerationScaled.y, (float) accelerationScaled.z);
sender.send("/myo"+ID+"/acceleration/scaledWfL", (float) accelerationScaledWfL.x, (float) accelerationScaledWfL.y, (float) accelerationScaledWfL.z);

sender.send("/myo"+ID+"/orientation/raw", (float) orientationRaw.x, (float) orientationRaw.y, (float) orientationRaw.z);
sender.send("/myo"+ID+"/orientation/scaled", (float) orientationScaled.x, (float) orientationScaled.y, (float) orientationScaled.z);
sender.send("/myo"+ID+"/orientation/wl", (float) orientationWl.x, (float) orientationWl.y, (float) orientationWl.z);
sender.send ("/myo"+ID+"/EMG/raw", (int) emgRaw[0], (int) emgRaw[1], (int) emgRaw[2], (int) emgRaw[3], (int) emgRaw[4], (int) emgRaw[5], (int) emgRaw[6], (int) emgRaw[7]);

sender.send ("/myo"+ID+"/EMG/scaled", (float) emgScaled[0], (float) emgScaled[1], (float) emgScaled[2], (float) emgScaled[3], (float) emgScaled[4], (float) emgScaled[5], (float) emgScaled[6], (float) emgScaled[7]);
sender.send ("/myo"+ID+"/EMG/scaledAbs", (float) emgScaledAbs[0], (float) emgScaledAbs[1], (float) emgScaledAbs[2], (float) emgScaledAbs[3], (float) emgScaledAbs[4], (float) emgScaledAbs[5], (float) emgScaledAbs[6], (float) emgScaledAbs[7]);
sender.send("/myo"+ID+"/EMG/mav", (float) mav);
sender.send("/myo"+ID+"/EMG/mav", (float) mav);
sender.send("/myo"+ID+"/EMG/mavWfL", (float) mavWl);

sender.send("/myo"+ID+"/pose", (int) poseID, (String) pose);

sender.send("/myo"+ID+"/all", (float) orientationScaled.x, (float) orientationScaled.y, (float) orientationScaled.z, (float) orientationWl.x, (float) orientationWl.y, (float) orientationWl.z, (float) acceleration.x, (float) acceleration.y, (float) acceleration.z, (float) accelerationWl.x, (float) accelerationWl.y, (float) accelerationWl.z, (float) gyro.x, (float) gyro.y, (float) gyro.z, (float) gyroWl.x, (float) gyroWl.y, (float) gyroWl.z, (float) mav, (float) mavWl);
sender.send("/myo"+ID+"/allEMG", (float) orientationScaled.x, (float) orientationScaled.y, (float) orientationScaled.z, (float) orientationWl.x, (float) orientationWl.y, (float) orientationWl.z, (float) acceleration.x, (float) acceleration.y, (float) acceleration.z, (float) accelerationWl.x, (float) accelerationWl.y, (float) accelerationWl.z, (float) gyro.x, (float) gyro.y, (float) gyro.z, (float) gyroWl.x, (float) gyroWl.y, (float) gyroWl.z, (float) mav, (float) mavWl, (float) emgScaled[0], (float) emgScaled[1], (float) emgScaled[2], (float) emgScaled[3], (float) emgScaled[4], (float) emgScaled[5], (float) emgScaled[6], (float) emgScaled[7]);

sender.send("/myo"+ID+"/all", (float) orientationScaled.x, (float) orientationScaled.y, (float) orientationScaled.z, (float) orientationWfL.x, (float) orientationWfL.y, (float) orientationWfL.z, (float) accelerationScaled.x, (float) accelerationScaled.y, (float) accelerationScaled.z, (float) accelerationScaledWfL.x, (float) accelerationScaledWfL.y, (float) accelerationScaledWfL.z, (float) gyroScaled.x, (float) gyroScaled.y, (float) gyroScaled.z, (float) gyroScaledWfL.x, (float) gyroScaledWfL.y, (float) gyroScaledWfL.z, (float) mav, (float) mavWl);
sender.send("/myo"+ID+"/allEMG", (float) (float) orientationScaled.x, (float) orientationScaled.y, (float) orientationScaled.z, (float) orientationWfL.x, (float) orientationWfL.y, (float) orientationWfL.z, (float) accelerationScaled.x, (float) accelerationScaled.y, (float) accelerationScaled.z, (float) accelerationScaledWfL.x, (float) accelerationScaledWfL.y, (float) accelerationScaledWfL.z, (float) gyroScaled.x, (float) gyroScaled.y, (float) gyroScaled.z, (float) gyroScaledWfL.x, (float) gyroScaledWfL.y, (float) gyroScaledWfL.z, (float) mav, (float) mavWl, (float) emgScaledAbs[0], (float) emgScaledAbs[1], (float) emgScaledAbs[2], (float) emgScaledAbs[3], (float) emgScaledAbs[4], (float) emgScaledAbs[5], (float) emgScaledAbs[6], (float) emgScaledAbs[7]);
sender.send("/wek/inputs", (float) orientationScaled.x, (float) orientationScaled.y, (float) orientationScaled.z, (float) accelerationScaled.x, (float) accelerationScaled.y, (float) accelerationScaled.z, (float) gyroScaled.x, (float) gyroScaled.y, (float) gyroScaled.z, (float) mav, (float) mavWl);
}

// ============== END SENDER ==============
Expand Down
11 changes: 8 additions & 3 deletions Myo Mapper/Source/OSC.h
Original file line number Diff line number Diff line change
Expand Up @@ -20,15 +20,20 @@ class OSC : public Component,
void sendOSC(int id,
std::array<int8_t, 8> emgRaw,
std::array<float, 8> emgScaled,
std::array<float, 8> emgScaledAbs,
float mav,
float mavWl,
Vector3D< float > gyro,
Vector3D< float > gyroWl,
Vector3D< float > gyroWfL,
Vector3D< float > gyroScaled,
Vector3D< float > gyroScaledWfL,
Vector3D< float > acceleration,
Vector3D< float > accelerationWl,
Vector3D< float > accelerationWfL,
Vector3D< float > accelerationScaled,
Vector3D< float > accelerationScaledWfL,
Vector3D< float > orientationRaw,
Vector3D< float > orientationScaled,
Vector3D< float > orientationWl,
Vector3D< float > orientationWfL,
String pose,
int poseID);

Expand Down
1 change: 1 addition & 0 deletions Myo Mapper/Source/orientation.cpp
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
#include "orientation.h"
#include "juce_Array.h"

Orientation::Orientation()
{
Expand Down
Loading

0 comments on commit 682c0f5

Please sign in to comment.