Skip to content

Commit

Permalink
handle gyro and impulse as lists
Browse files Browse the repository at this point in the history
  • Loading branch information
ben-wes committed Nov 29, 2024
1 parent 9606efc commit af9f7b5
Show file tree
Hide file tree
Showing 3 changed files with 159 additions and 178 deletions.
14 changes: 7 additions & 7 deletions dsshow.pd_lua
Original file line number Diff line number Diff line change
Expand Up @@ -199,16 +199,16 @@ end

function ds:in_1_quat(atoms)
if not self.track_orientation then self.track_orientation = true end
if atoms[1] == "w" then self.state.quat_w = atoms[2] end
if atoms[1] == "x" then self.state.quat_x = atoms[2] end
if atoms[1] == "y" then self.state.quat_y = atoms[2] end
if atoms[1] == "z" then self.state.quat_z = atoms[2] end
self.state.quat_w = atoms[1] or 1
self.state.quat_x = atoms[2] or 0
self.state.quat_y = atoms[3] or 0
self.state.quat_z = atoms[4] or 0
end

function ds:in_1_impulse(atoms)
if atoms[1] == "x" then self.state.impulse_x = atoms[2] end
if atoms[1] == "y" then self.state.impulse_y = atoms[2] end
if atoms[1] == "z" then self.state.impulse_z = atoms[2] end
self.state.impulse_x = atoms[1] or 0
self.state.impulse_y = atoms[2] or 0
self.state.impulse_z = atoms[3] or 0
end

function ds:in_1_button(atoms)
Expand Down
176 changes: 85 additions & 91 deletions sensors2impulse.pd
Original file line number Diff line number Diff line change
@@ -1,6 +1,4 @@
#N canvas 208 233 495 611 10;
#X obj 53 51 inlet;
#X text 399 190 smooth;
#N canvas 208 291 495 611 10;
#X text 440 348 hip;
#X obj 61 384 +;
#X obj 97 361 f;
Expand All @@ -10,18 +8,6 @@
#X text 125 361 y[n-1];
#X text 111 326 x[n-1];
#X text 112 410 alpha;
#X obj 54 211 +;
#X obj 54 169 t f b;
#X obj 103 191 f;
#X obj 103 212 * 0.9;
#X obj 174 211 +;
#X obj 174 169 t f b;
#X obj 223 191 f;
#X obj 223 212 * 0.9;
#X obj 304 211 +;
#X obj 304 169 t f b;
#X obj 353 191 f;
#X obj 353 212 * 0.9;
#X obj 181 384 +;
#X obj 217 361 f;
#X obj 205 327 f;
Expand All @@ -38,80 +24,88 @@
#X text 375 361 y[n-1];
#X text 361 326 x[n-1];
#X text 362 410 alpha;
#X obj 312 409 * 0.8;
#X obj 182 409 * 0.8;
#X obj 62 409 * 0.8;
#X obj 54 190 * 0.09;
#X obj 174 190 * -0.09;
#X obj 304 190 * 0.09;
#X obj 61 467 pack f f f;
#X obj 61 548 outlet;
#X obj 61 488 list prepend impulse;
#X obj 61 509 list trim;
#X text 399 190 smooth;
#X obj 54 211 +;
#X obj 54 169 t f b;
#X obj 103 191 f;
#X obj 174 211 +;
#X obj 174 169 t f b;
#X obj 223 191 f;
#X obj 304 211 +;
#X obj 304 169 t f b;
#X obj 353 191 f;
#X obj 53 51 inlet;
#X obj 53 85 route accel;
#X msg 59 474 impulse x \$1;
#X msg 177 473 impulse y \$1;
#X msg 311 474 impulse z \$1;
#X obj 53 122 route x y z;
#X obj 59 548 outlet;
#X obj 311 517 pack f f f;
#X obj 311 548 outlet;
#X connect 0 0 45 0;
#X connect 3 0 41 0;
#X connect 4 0 3 1;
#X connect 5 0 6 1;
#X connect 6 0 3 0;
#X connect 7 0 6 0;
#X connect 7 1 5 1;
#X connect 7 2 5 0;
#X connect 7 3 4 0;
#X connect 11 0 13 1;
#X connect 11 0 7 0;
#X connect 12 0 42 0;
#X connect 12 1 13 0;
#X connect 13 0 14 0;
#X connect 14 0 11 1;
#X connect 15 0 17 1;
#X connect 15 0 27 0;
#X connect 16 0 43 0;
#X connect 16 1 17 0;
#X connect 17 0 18 0;
#X connect 18 0 15 1;
#X connect 19 0 21 1;
#X connect 19 0 35 0;
#X connect 20 0 44 0;
#X connect 20 1 21 0;
#X connect 21 0 22 0;
#X connect 22 0 19 1;
#X connect 23 0 40 0;
#X connect 24 0 23 1;
#X connect 25 0 26 1;
#X connect 26 0 23 0;
#X connect 27 0 26 0;
#X connect 27 1 25 1;
#X connect 27 2 25 0;
#X connect 27 3 24 0;
#X connect 31 0 39 0;
#X connect 32 0 31 1;
#X connect 33 0 34 1;
#X connect 34 0 31 0;
#X connect 35 0 34 0;
#X connect 35 1 33 1;
#X connect 35 2 33 0;
#X connect 35 3 32 0;
#X connect 39 0 32 1;
#X connect 39 0 48 0;
#X connect 39 0 51 2;
#X connect 40 0 24 1;
#X connect 40 0 47 0;
#X connect 40 0 51 1;
#X connect 41 0 4 1;
#X connect 41 0 46 0;
#X connect 41 0 51 0;
#X connect 42 0 11 0;
#X connect 43 0 15 0;
#X connect 44 0 19 0;
#X connect 45 0 49 0;
#X connect 46 0 50 0;
#X connect 47 0 50 0;
#X connect 48 0 50 0;
#X connect 49 0 12 0;
#X connect 49 1 16 0;
#X connect 49 2 20 0;
#X connect 51 0 52 0;
#X obj 53 122 unpack f f f;
#X obj 353 213 * 0.9;
#X obj 222 212 * 0.9;
#X obj 103 212 * 0.9;
#X obj 54 190 * 0.1;
#X obj 174 190 * -0.1;
#X obj 304 190 * 0.1;
#X obj 312 410 * 0.95;
#X obj 182 409 * 0.95;
#X obj 62 409 * 0.95;
#X connect 1 0 50 0;
#X connect 2 0 1 1;
#X connect 3 0 4 1;
#X connect 4 0 1 0;
#X connect 5 0 4 0;
#X connect 5 1 3 1;
#X connect 5 2 3 0;
#X connect 5 3 2 0;
#X connect 9 0 49 0;
#X connect 10 0 9 1;
#X connect 11 0 12 1;
#X connect 12 0 9 0;
#X connect 13 0 12 0;
#X connect 13 1 11 1;
#X connect 13 2 11 0;
#X connect 13 3 10 0;
#X connect 17 0 48 0;
#X connect 18 0 17 1;
#X connect 19 0 20 1;
#X connect 20 0 17 0;
#X connect 21 0 20 0;
#X connect 21 1 19 1;
#X connect 21 2 19 0;
#X connect 21 3 18 0;
#X connect 25 0 27 0;
#X connect 27 0 28 0;
#X connect 28 0 26 0;
#X connect 30 0 32 1;
#X connect 30 0 5 0;
#X connect 31 0 45 0;
#X connect 31 1 32 0;
#X connect 32 0 44 0;
#X connect 33 0 35 1;
#X connect 33 0 13 0;
#X connect 34 0 46 0;
#X connect 34 1 35 0;
#X connect 35 0 43 0;
#X connect 36 0 38 1;
#X connect 36 0 21 0;
#X connect 37 0 47 0;
#X connect 37 1 38 0;
#X connect 38 0 42 0;
#X connect 39 0 40 0;
#X connect 40 0 41 0;
#X connect 41 0 31 0;
#X connect 41 1 34 0;
#X connect 41 2 37 0;
#X connect 42 0 36 1;
#X connect 43 0 33 1;
#X connect 44 0 30 1;
#X connect 45 0 30 0;
#X connect 46 0 33 0;
#X connect 47 0 36 0;
#X connect 48 0 18 1;
#X connect 48 0 25 2;
#X connect 49 0 10 1;
#X connect 49 0 25 1;
#X connect 50 0 2 1;
#X connect 50 0 25 0;
147 changes: 67 additions & 80 deletions sensors2quat.pd
Original file line number Diff line number Diff line change
@@ -1,8 +1,4 @@
#N canvas 76 178 799 789 10;
#X msg 56 603 quat w \$1;
#X msg 113 624 quat x \$1;
#X msg 227 666 quat z \$1;
#X msg 170 645 quat y \$1;
#X text 80 165 gyro;
#X text 382 165 accel;
#X msg 94 266 1;
Expand Down Expand Up @@ -50,9 +46,6 @@
#X connect 4 0 2 0;
#X connect 4 1 1 0;
#X restore 218 215 pd stop_drift;
#X obj 267 294 * 0.067;
#X obj 199 294 * -0.067;
#X obj 131 294 * -0.067;
#X obj 283 442 * 0.9982;
#X obj 215 442 * 0.9982;
#X obj 153 442 * 0.9982;
Expand Down Expand Up @@ -88,7 +81,7 @@
#X connect 12 0 8 6;
#X connect 13 0 8 7;
#X restore 100 405 pd quaternion_mul;
#N canvas 880 305 506 495 add_acceleration_quaternion 1;
#N canvas 880 305 506 495 add_acceleration_quaternion 0;
#X obj 77 59 inlet;
#X obj 127 59 inlet;
#X obj 177 59 inlet;
Expand All @@ -110,83 +103,77 @@
#X restore 330 289 pd add_acceleration_quaternion;
#X text 40 364 feedback;
#X obj 77 51 inlet;
#X obj 65 728 outlet;
#X obj 372 673 outlet;
#X obj 372 642 pack f f f f;
#X obj 73 674 outlet;
#X obj 71 592 pack f f f f;
#X text 572 350 * 0.0018;
#X obj 422 469 > 0;
#X obj 376 495 > 0;
#X obj 330 399 * 1;
#X obj 422 490 * 2;
#X obj 422 511 - 1;
#X obj 376 516 * 2;
#X obj 376 537 - 1;
#X obj 97 462 +;
#X obj 506 350 * 0.0018;
#X obj 389 350 * 0.0018;
#X obj 330 350 * 0.0018;
#X text 449 489 w correction depending on closest identity (-1/1);
#X text 403 515 w correction depending on closest identity (-1/1);
#X obj 75 183 unpack f f f;
#X obj 375 183 unpack f f f;
#X obj 375 204 print;
#X obj 227 687 print;
#X connect 0 0 29 0;
#X connect 1 0 29 0;
#X connect 2 0 29 0;
#X connect 2 0 45 0;
#X connect 3 0 29 0;
#X connect 6 0 25 4;
#X connect 7 0 9 1;
#X connect 8 0 9 3;
#X connect 9 0 22 1;
#X connect 9 0 0 0;
#X connect 9 0 31 0;
#X connect 9 0 33 0;
#X connect 9 1 1 0;
#X connect 9 1 25 1;
#X connect 9 1 31 1;
#X connect 9 2 3 0;
#X connect 9 2 25 2;
#X connect 9 2 31 2;
#X connect 9 3 2 0;
#X connect 9 3 25 3;
#X connect 9 3 31 3;
#X connect 10 0 22 0;
#X connect 10 1 6 0;
#X connect 10 2 12 0;
#X connect 12 0 17 0;
#X connect 13 0 16 0;
#X connect 14 0 15 0;
#X connect 15 0 25 7;
#X connect 16 0 25 6;
#X connect 17 0 25 5;
#X connect 18 0 8 0;
#X connect 19 0 9 2;
#X connect 20 0 7 0;
#X connect 21 0 37 0;
#X connect 22 0 25 0;
#X connect 23 0 25 0;
#X connect 24 0 42 0;
#X connect 24 1 43 0;
#X connect 24 2 23 0;
#X connect 25 0 21 0;
#X connect 25 1 20 0;
#X connect 25 2 19 0;
#X connect 25 3 18 0;
#X connect 26 0 40 0;
#X connect 26 1 39 0;
#X connect 26 3 38 0;
#X connect 28 0 24 0;
#X connect 31 0 30 0;
#X connect 33 0 35 0;
#X connect 34 0 37 1;
#X connect 35 0 36 0;
#X connect 36 0 34 1;
#X connect 37 0 9 0;
#X connect 38 0 8 1;
#X connect 39 0 7 1;
#X connect 40 0 34 0;
#X connect 42 0 10 0;
#X connect 42 1 13 0;
#X connect 42 2 14 0;
#X connect 43 0 26 0;
#X connect 43 0 44 0;
#X connect 43 1 26 1;
#X connect 43 2 26 2;
#X obj 72 623 list prepend quat;
#X obj 72 644 list trim;
#X obj 131 294 * -0.05;
#X obj 199 294 * -0.05;
#X obj 267 294 * 0.05;
#X connect 2 0 18 4;
#X connect 3 0 5 1;
#X connect 4 0 5 3;
#X connect 5 0 15 1;
#X connect 5 0 23 0;
#X connect 5 0 25 0;
#X connect 5 1 18 1;
#X connect 5 1 23 1;
#X connect 5 2 18 2;
#X connect 5 2 23 2;
#X connect 5 3 18 3;
#X connect 5 3 23 3;
#X connect 6 0 15 0;
#X connect 6 1 2 0;
#X connect 6 2 8 0;
#X connect 8 0 38 0;
#X connect 9 0 39 0;
#X connect 10 0 40 0;
#X connect 11 0 4 0;
#X connect 12 0 5 2;
#X connect 13 0 3 0;
#X connect 14 0 29 0;
#X connect 15 0 18 0;
#X connect 16 0 18 0;
#X connect 17 0 34 0;
#X connect 17 1 35 0;
#X connect 17 2 16 0;
#X connect 18 0 14 0;
#X connect 18 1 13 0;
#X connect 18 2 12 0;
#X connect 18 3 11 0;
#X connect 19 0 32 0;
#X connect 19 1 31 0;
#X connect 19 3 30 0;
#X connect 21 0 17 0;
#X connect 23 0 36 0;
#X connect 25 0 27 0;
#X connect 26 0 29 1;
#X connect 27 0 28 0;
#X connect 28 0 26 1;
#X connect 29 0 5 0;
#X connect 30 0 4 1;
#X connect 31 0 3 1;
#X connect 32 0 26 0;
#X connect 34 0 6 0;
#X connect 34 1 9 0;
#X connect 34 2 10 0;
#X connect 35 0 19 0;
#X connect 35 1 19 1;
#X connect 35 2 19 2;
#X connect 36 0 37 0;
#X connect 37 0 22 0;
#X connect 38 0 18 5;
#X connect 39 0 18 6;
#X connect 40 0 18 7;

0 comments on commit af9f7b5

Please sign in to comment.