From 3863abacafff1cf4e89e53a65426523870a7ca74 Mon Sep 17 00:00:00 2001 From: grog Date: Thu, 12 Oct 2023 08:37:43 -0700 Subject: [PATCH] non breaking methods plus deprecation notice --- .../org/myrobotlab/service/InMoov2Arm.java | 5 +++ .../org/myrobotlab/service/InMoov2Hand.java | 6 +++ .../org/myrobotlab/service/InMoov2Head.java | 41 +++++++++++++++---- .../org/myrobotlab/service/InMoov2Torso.java | 6 +++ 4 files changed, 50 insertions(+), 8 deletions(-) diff --git a/src/main/java/org/myrobotlab/service/InMoov2Arm.java b/src/main/java/org/myrobotlab/service/InMoov2Arm.java index a73f5527b5..d190af46e8 100644 --- a/src/main/java/org/myrobotlab/service/InMoov2Arm.java +++ b/src/main/java/org/myrobotlab/service/InMoov2Arm.java @@ -89,7 +89,12 @@ public static DHRobotArm getDHRobotArm(String name, String side) { return arm; } + @Deprecated /* use onMove */ public void onMoveArm(HashMap map) { + onMove(map); + } + + public void onMove(Map map) { moveTo(map.get("bicep"), map.get("rotate"), map.get("shoulder"), map.get("omoplate")); } diff --git a/src/main/java/org/myrobotlab/service/InMoov2Hand.java b/src/main/java/org/myrobotlab/service/InMoov2Hand.java index b1744ad03e..9bf4cf923b 100644 --- a/src/main/java/org/myrobotlab/service/InMoov2Hand.java +++ b/src/main/java/org/myrobotlab/service/InMoov2Hand.java @@ -5,6 +5,7 @@ import java.util.HashMap; import java.util.HashSet; import java.util.List; +import java.util.Map; import java.util.Set; import org.myrobotlab.framework.Registration; @@ -489,7 +490,12 @@ public LeapData onLeapData(LeapData data) { return data; } + @Deprecated /* use onMove */ public void onMoveHand(HashMap map) { + onMove(map); + } + + public void onMove(Map map) { moveTo(map.get("thumb"), map.get("index"), map.get("majeure"), map.get("majeure"), map.get("pinky"), map.get("wrist")); } diff --git a/src/main/java/org/myrobotlab/service/InMoov2Head.java b/src/main/java/org/myrobotlab/service/InMoov2Head.java index 11d71fba7c..0df855a1ab 100644 --- a/src/main/java/org/myrobotlab/service/InMoov2Head.java +++ b/src/main/java/org/myrobotlab/service/InMoov2Head.java @@ -3,6 +3,7 @@ import java.io.File; import java.io.IOException; import java.util.HashMap; +import java.util.Map; import java.util.concurrent.ThreadLocalRandom; import org.myrobotlab.framework.Service; @@ -142,15 +143,34 @@ public void disable() { eyelidRight.disable(); } - public long getLastActivityTime() { + public Long getLastActivityTime() { - long lastActivityTime = Math.max(rothead.getLastActivityTime(), neck.getLastActivityTime()); - lastActivityTime = Math.max(lastActivityTime, eyeX.getLastActivityTime()); - lastActivityTime = Math.max(lastActivityTime, eyeY.getLastActivityTime()); - lastActivityTime = Math.max(lastActivityTime, jaw.getLastActivityTime()); - lastActivityTime = Math.max(lastActivityTime, rollNeck.getLastActivityTime()); - lastActivityTime = Math.max(lastActivityTime, eyelidLeft.getLastActivityTime()); - lastActivityTime = Math.max(lastActivityTime, eyelidRight.getLastActivityTime()); + Long lastActivityTime = Math.max(rothead.getLastActivityTime(), neck.getLastActivityTime()); + if (getPeer("eyeX") != null) { + lastActivityTime = Math.max(lastActivityTime, eyeX.getLastActivityTime()); + } + if (getPeer("eyeY") != null) { + lastActivityTime = Math.max(lastActivityTime, eyeY.getLastActivityTime()); + } + if (getPeer("jaw") != null) { + lastActivityTime = Math.max(lastActivityTime, jaw.getLastActivityTime()); + } + if (getPeer("rollNeck") != null) { + lastActivityTime = Math.max(lastActivityTime, rollNeck.getLastActivityTime()); + } + if (getPeer("rollNeck") != null) { + lastActivityTime = Math.max(lastActivityTime, rothead.getLastActivityTime()); + } + if (getPeer("rollNeck") != null) { + lastActivityTime = Math.max(lastActivityTime, neck.getLastActivityTime()); + } + + if (getPeer("eyelidLeft") != null) { + lastActivityTime = Math.max(lastActivityTime, eyelidLeft.getLastActivityTime()); + } + if (getPeer("eyelidRight") != null) { + lastActivityTime = Math.max(lastActivityTime, eyelidRight.getLastActivityTime()); + } return lastActivityTime; } @@ -199,7 +219,12 @@ public void lookAt(Double x, Double y, Double z) { log.info("object distance is {},rothead servo {},neck servo {} ", distance, rotation, colatitude); } + @Deprecated /* use onMoov */ public void onMoveHead(HashMap map) { + onMove(map); + } + + public void onMove(Map map) { moveTo(map.get("neck"), map.get("rothead"), map.get("eyeX"), map.get("eyeY"), map.get("jaw"), map.get("rollNeck")); } diff --git a/src/main/java/org/myrobotlab/service/InMoov2Torso.java b/src/main/java/org/myrobotlab/service/InMoov2Torso.java index d2607a1033..f3953699c5 100644 --- a/src/main/java/org/myrobotlab/service/InMoov2Torso.java +++ b/src/main/java/org/myrobotlab/service/InMoov2Torso.java @@ -3,6 +3,7 @@ import java.io.File; import java.io.IOException; import java.util.HashMap; +import java.util.Map; import org.myrobotlab.framework.Service; import org.myrobotlab.io.FileIO; @@ -93,7 +94,12 @@ public void disable() { lowStom.disable(); } + @Deprecated /* use onMove */ public void onMoveTorso(HashMap map) { + onMove(map); + } + + public void onMove(Map map) { moveTo(map.get("topStom"), map.get("midStom"), map.get("lowStom")); }