Skip to content

Commit daa455a

Browse files
author
Amadeus Stevenson
committed
Update with persistent left/right orientation for x
1 parent df32d23 commit daa455a

File tree

1 file changed

+17
-7
lines changed

1 file changed

+17
-7
lines changed

six-servos.js

Lines changed: 17 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -4,14 +4,14 @@
44

55
leap_ranges = Array(
66
Array(
7-
Array(-250,100),
8-
Array(70,550),
9-
Array(-100,250)
7+
Array(-250,-70),
8+
Array(50,500),
9+
Array(-100,200)
1010
),
1111
Array(
12-
Array(-350,270),
13-
Array(40,550),
14-
Array(-80,250)
12+
Array(40,300),
13+
Array(50,500),
14+
Array(-100,200)
1515
)
1616
);
1717

@@ -64,9 +64,19 @@ board.on('ready', function() {
6464
// extract centre palm position in mm [x,y,z]
6565
palm[0] = frame.hands[0].palmPosition;
6666
palm[1] = frame.hands[1].palmPosition;
67+
68+
// make sure the 0th palm is always the left one
69+
if (palm[1][0] < (palm[0][0])) {
70+
var newpalm = Array();
71+
newpalm[1]=palm[0];
72+
newpalm[0]=palm[1];
73+
palm=newpalm;
74+
}
6775
// map x,y,z positions of leap to servos
68-
//console.log("input",palm[0]);
6976
//console.log("output", palm[0].map(1,2))
77+
//console.log("left:", palm[0][2]);
78+
//console.log("right:", palm[1][2]);
79+
7080
for (hand=0; hand<2; hand++) {
7181
for (axis=0; axis<3; axis++) {
7282
servos[hand][axis].to(palm[hand][axis].map(hand,axis));

0 commit comments

Comments
 (0)