Skip to content

Commit

Permalink
Merge branch 'develop' of https://github.com/MyRobotLab/myrobotlab in…
Browse files Browse the repository at this point in the history
…to inmoov2-heart-2
  • Loading branch information
supertick committed Apr 30, 2024
2 parents e0dc67b + d7a0f22 commit d0b492b
Show file tree
Hide file tree
Showing 7 changed files with 35 additions and 19 deletions.
6 changes: 6 additions & 0 deletions src/main/java/org/myrobotlab/service/AudioFile.java
Original file line number Diff line number Diff line change
Expand Up @@ -123,6 +123,11 @@ public class AudioFile extends Service<AudioFileConfig> implements AudioPublishe
transient Map<String, AudioProcessor> processors = new HashMap<String, AudioProcessor>();

final private transient PlaylistPlayer playlistPlayer = new PlaylistPlayer(this);

/**
* last file played
*/
protected String lastPlayed;

public void attach(Attachable attachable) {
if (attachable instanceof AudioListener) {
Expand Down Expand Up @@ -418,6 +423,7 @@ public AudioData publishAudioStart(AudioData data) {
@Override
public AudioData publishAudioEnd(AudioData data) {
log.debug("Audio File publishAudioEnd");
lastPlayed = data.getFileName();
return data;
}

Expand Down
6 changes: 3 additions & 3 deletions src/main/java/org/myrobotlab/service/InMoov2.java
Original file line number Diff line number Diff line change
Expand Up @@ -1557,7 +1557,7 @@ public void searchPlay(String requestedSong) {
*/
public void processMessage(String method, Object... data) {
// User processing should not occur until after boot has completed
if (!state.equals("boot")) {
if (!state.equals("boot") && config.execScript) {
// FIXME - this needs to be in config
// FIXME - change peer name to "processor"
// String processor = getPeerName("py4j");
Expand Down Expand Up @@ -1948,7 +1948,7 @@ public boolean setAllVirtual(boolean virtual) {
public void setArmSpeed(String which, Double bicep, Double rotate, Double shoulder, Double omoplate) {
InMoov2Arm arm = getArm(which);
if (arm == null) {
warn("%s arm not started", which);
info("%s arm not started", which);
return;
}
arm.setSpeed(bicep, rotate, shoulder, omoplate);
Expand Down Expand Up @@ -1982,7 +1982,7 @@ public void setHandSpeed(String which, Double thumb, Double index, Double majeur
public void setHandSpeed(String which, Double thumb, Double index, Double majeure, Double ringFinger, Double pinky, Double wrist) {
InMoov2Hand hand = getHand(which);
if (hand == null) {
warn("%s hand not started", which);
info("%s hand not started", which);
return;
}
hand.setSpeed(thumb, index, majeure, ringFinger, pinky, wrist);
Expand Down
5 changes: 2 additions & 3 deletions src/main/java/org/myrobotlab/service/ProgramAB.java
Original file line number Diff line number Diff line change
Expand Up @@ -813,8 +813,6 @@ public String addBotPath(String path) {

bots.put(botInfo.name, botInfo);
botInfo.img = getBotImage(botInfo.name);

broadcastState();
} else {
error("invalid bot path %s - a bot must be a directory with a subdirectory named \"aiml\"", path);
return null;
Expand Down Expand Up @@ -1115,10 +1113,11 @@ public ProgramABConfig getConfig() {
public ProgramABConfig apply(ProgramABConfig c) {
super.apply(c);
if (c.bots != null && c.bots.size() > 0) {
// bots.clear();
bots.clear();
for (String botPath : c.bots) {
addBotPath(botPath);
}
broadcastState();
}

if (c.currentUserName != null) {
Expand Down
20 changes: 13 additions & 7 deletions src/main/java/org/myrobotlab/service/config/InMoov2Config.java
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,10 @@ public class InMoov2Config extends ServiceConfig {
*/
public boolean reportOnBoot = true;

public boolean robotCanMoveHeadWhileSpeaking = true;
/**
* script related config - idea is good, but shouldn't be implemented with global scripts
*/
public boolean robotCanMoveHeadWhileSpeaking = false;

/**
* startup and shutdown will pause inmoov - set the speed to this value then
Expand Down Expand Up @@ -527,9 +530,6 @@ public Plan getDefault(Plan plan, String name) {
log.listeners.add(new Listener("publishErrors", name));
// service --to--> InMoov2

// mouth_audioFile.listeners.add(new Listener("publishAudioEnd", name));
// mouth_audioFile.listeners.add(new Listener("publishAudioStart", name));

// InMoov2 --to--> service
listeners.add(new Listener("publishEvent", getPeerName("chatBot"), "getResponse"));
listeners.add(new Listener("publishFlash", getPeerName("neoPixel")));
Expand All @@ -554,9 +554,6 @@ public Plan getDefault(Plan plan, String name) {
audioPlayer.listeners.add(new Listener("publishAudioStart", name));
audioPlayer.listeners.add(new Listener("publishAudioEnd", name));

AudioFileConfig mouth_audioFile = (AudioFileConfig) plan.get(getPeerName("mouth.audioFile"));
mouth_audioFile.listeners.add(new Listener("publishPeak", name));

htmlFilter.listeners.add(new Listener("publishText", name));

OakDConfig oakd = (OakDConfig) plan.get(getPeerName("oakd"));
Expand All @@ -565,6 +562,15 @@ public Plan getDefault(Plan plan, String name) {

webxr.listeners.add(new Listener("publishJointAngles", name));

// service --to--> service
AudioFileConfig mouth_audioFile = (AudioFileConfig) plan.get(getPeerName("mouth.audioFile"));
mouth_audioFile.listeners.add(new Listener("publishPeak", name));
mouth_audioFile.listeners.add(new Listener("publishPeak", name + ".head.jaw", "moveTo"));
mouth_audioFile.peakDelayMs = 150L;
mouth_audioFile.peakMultiplier = 200.0;
mouth_audioFile.peakSampleInterval = 2.0;
mouth_audioFile.publishPeakResetDelayMs = 100L;

// mouth_audioFile.listeners.add(new Listener("publishAudioEnd", name));
// mouth_audioFile.listeners.add(new Listener("publishAudioStart", name));

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@ angular.module('mrlapp.service.AudioFileGui', []).controller('AudioFileGuiCtrl',

if (firstUpdate){
$scope.selectedPlaylist = $scope.service.config.currentPlaylist

firstUpdate = false
}

Expand All @@ -65,9 +66,8 @@ angular.module('mrlapp.service.AudioFileGui', []).controller('AudioFileGuiCtrl',
$scope.activity = 'playing'
}

if (!$scope.inputSelectedFile){
$scope.inputSelectedFile = $scope.selectedFile
}
$scope.selectedFile = service.lastPlayed.filename;


}

Expand All @@ -81,13 +81,18 @@ angular.module('mrlapp.service.AudioFileGui', []).controller('AudioFileGuiCtrl',
case 'onAudioStart':
$scope.playing = data.filename
$scope.activity = 'playing'
if (!$scope.selectedFile || $scope.selectedFile == ""){
$scope.selectedFile = data.filename
}
$scope.$apply()
break
case 'onAudioEnd':
$scope.playing = data.filename
$scope.activity = 'stopped'
if (!$scope.selectedFile || $scope.selectedFile == ""){
$scope.selectedFile = data.filename
}
$scope.$apply()
$scope.service.lastPlayed = data.filename
break
case 'onPeak':
$scope.peak = Math.round(data/* * 100 */)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
<table border="1" class="table table-hover table-condensed table-striped table-bordered">
<tr>
<td>
<input class="form-control" ng-change="setSelectedFileFromTrack(inputSelectedFile)" type="text" ng-model="inputSelectedFile" name="selectedFile" id="selectedFile" ng-init="" placeholder="file"/>
<input class="form-control" ng-change="setSelectedFileFromTrack(selectedFile)" type="text" ng-model="selectedFile" name="selectedFile" id="selectedFile" ng-init="" placeholder="file"/>
</td>
</tr>
<tr>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ <h3> {{service.platform.arch}}.{{service.platform.jvmBitness}}.{{service.platfor
</ui-select>
</td>
<td>&nbsp;
<button class="btn btn-default" ng-show="!service.isVirtual" title="This will auto start config on next start"
<button class="btn btn-default" ng-show="!service.isVirtual" title="This will virtualize hardware"
ng-click="msg.setVirtual(true)">virtualization off</button>
<button class="btn btn-info" ng-show="service.isVirtual" title="This will auto start config on next start"
ng-click="msg.setVirtual(false)">virtualization on</button>
Expand Down

0 comments on commit d0b492b

Please sign in to comment.