diff --git a/positionCapture/positionCapture.pde b/positionCapture/positionCapture.pde index 8b0824d..297a765 100644 --- a/positionCapture/positionCapture.pde +++ b/positionCapture/positionCapture.pde @@ -15,6 +15,11 @@ String filename=""; int recordingStartTime; int linesWritten; +//Matrix Weights +String mwheader[] = new String[32]; +float matrixweights[][] = new float[32][32]; //[servo][weight] +int matrixrows=0; //when matrix received this will be the number of rows + void setup() { size(800,600); background(0); @@ -77,6 +82,32 @@ void draw() { } + }else if (list[0].equalsIgnoreCase("mwheader")) { //is matrix weights header message + for (int i=0;i1000) { + last_loop_sendmatrix_millis=loopmillis; + transmit_matrix_weights(); + } } diff --git a/protesis_03_dxl/servo-control.cpp b/protesis_03_dxl/servo-control.cpp index dc029ce..e938779 100644 --- a/protesis_03_dxl/servo-control.cpp +++ b/protesis_03_dxl/servo-control.cpp @@ -16,13 +16,15 @@ int rpm_to_dxl_servo_speed(const int rpm); Mood mood; -float matrix_weights[SERVO_COUNT][6]; //mapping outputs, sensors/moods +#define WEIGHT_COUNT 6 //enter number of weights here for array size +float matrix_weights[SERVO_COUNT][WEIGHT_COUNT]; //mapping outputs, sensors/moods #define W_PITCH 0 #define W_ROLL 1 #define W_NOISE 2 #define W_NOISESLOW 3 #define W_SIN 4 #define W_COS 5 +String weightNames[] = {"Pitch","Roll","Noise","NoiseSlow","Sin","Cos"}; unsigned long last_overloaderror_millis; @@ -108,6 +110,30 @@ void matrix_weights_update(){ } +bool trasmitMatrixWeightsHeaderFlag=false; +void transmit_matrix_weights() { + if (!trasmitMatrixWeightsHeaderFlag) { //transmit header only one time + trasmitMatrixWeightsHeaderFlag=true; + Serial.print("mwheader"); //matrixweight header + for (int i=0;i