Skip to content

Commit

Permalink
merged master
Browse files Browse the repository at this point in the history
  • Loading branch information
supertick committed Oct 25, 2023
1 parent 7756069 commit 8149ae6
Show file tree
Hide file tree
Showing 6 changed files with 62 additions and 15 deletions.
6 changes: 6 additions & 0 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -198,6 +198,12 @@
</dependency>
<!-- CsvConnector end -->

<dependency>
<groupId>org.nanohttpd</groupId> <!-- <groupId>com.nanohttpd</groupId> for 2.1.0 and earlier -->
<artifactId>nanohttpd</artifactId>
<version>2.2.0</version>
</dependency>

<!-- Deeplearning4j begin -->
<dependency>
<groupId>org.bytedeco</groupId>
Expand Down
19 changes: 10 additions & 9 deletions src/main/java/org/myrobotlab/framework/Service.java
Original file line number Diff line number Diff line change
Expand Up @@ -1416,7 +1416,8 @@ public <P extends ServiceConfig> P getPeerConfig(String peerKey, StaticType<P> t
}

// Java generics don't let us create a new StaticType using
// P here because the type variable is erased, so we have to cast anyway for now
// P here because the type variable is erased, so we have to cast anyway for
// now
ConfigurableService<P> si = (ConfigurableService<P>) Runtime.getService(peerName);
if (si != null) {
// peer is currently running - get its config
Expand Down Expand Up @@ -1447,7 +1448,8 @@ public void setPeerConfigValue(String peerKey, String fieldname, Object value) t
field.set(sc, value);
savePeerConfig(peerKey, sc);
String peerName = getPeerName(peerKey);
var cs = Runtime.getConfigurableService(peerName, new StaticType<Service<ServiceConfig>>() {});
var cs = Runtime.getConfigurableService(peerName, new StaticType<Service<ServiceConfig>>() {
});
if (cs != null) {
cs.apply(sc); // TODO - look for applies if its read from the file system
// it needs to update Runtime.plan
Expand Down Expand Up @@ -2163,7 +2165,7 @@ public Status error(Exception e) {
invoke("publishStatus", status);
return status;
}

@Override
public Status error(String format, Object... args) {
Status ret;
Expand Down Expand Up @@ -2194,10 +2196,8 @@ public Status warn(String msg) {

@Override
public Status warn(String format, Object... args) {
String msg = String.format(
Objects.requireNonNullElse(format, ""),
args);

String msg = String.format(Objects.requireNonNullElse(format, ""), args);

return warn(msg);
}

Expand Down Expand Up @@ -2235,7 +2235,7 @@ public Status info(String format, Object... args) {
public Status publishError(Status status) {
return status;
}

public Status publishWarn(Status status) {
return status;
}
Expand Down Expand Up @@ -2857,7 +2857,8 @@ public void apply() {
}

public void applyPeerConfig(String peerKey, ServiceConfig config) {
applyPeerConfig(peerKey, config, new StaticType<>() {});
applyPeerConfig(peerKey, config, new StaticType<>() {
});
}

/**
Expand Down
2 changes: 1 addition & 1 deletion src/main/java/org/myrobotlab/service/WebGui.java
Original file line number Diff line number Diff line change
Expand Up @@ -1179,7 +1179,7 @@ public static void main(String[] args) {

// Platform.setVirtual(true);

Runtime.startConfig("default");
Runtime.startConfig("dev");

boolean done = true;
if (done) {
Expand Down
10 changes: 9 additions & 1 deletion src/main/java/org/myrobotlab/service/WebXR.java
Original file line number Diff line number Diff line change
Expand Up @@ -129,7 +129,15 @@ public static void main(String[] args) {

// identical to command line start
// Runtime.startConfig("inmoov2");
Runtime.main(new String[] { "--log-level", "info", "-s", "webgui", "WebGui", "intro", "Intro", "python", "Python" });


// normal non-config launch
// Runtime.main(new String[] { "--log-level", "info", "-s", "webgui", "WebGui", "intro", "Intro", "python", "Python" });


// config launch
Runtime.startConfig("webxr");

boolean done = true;
if (done)
return;
Expand Down
28 changes: 27 additions & 1 deletion src/main/java/org/myrobotlab/service/config/InMoov2Config.java
Original file line number Diff line number Diff line change
@@ -1,10 +1,13 @@
package org.myrobotlab.service.config;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.Map;

import org.myrobotlab.framework.Plan;
import org.myrobotlab.jme3.UserDataConfig;
import org.myrobotlab.math.MapperLinear;
import org.myrobotlab.math.MapperSimple;
import org.myrobotlab.service.Pid.PidData;
import org.myrobotlab.service.Runtime;
import org.myrobotlab.service.config.FiniteStateMachineConfig.Transition;
Expand Down Expand Up @@ -198,7 +201,26 @@ public Plan getDefault(Plan plan, String name) {
addDefaultPeerConfig(plan, name, "torso", "InMoov2Torso", false);
addDefaultPeerConfig(plan, name, "ultrasonicRight", "UltrasonicSensor", false);
addDefaultPeerConfig(plan, name, "ultrasonicLeft", "UltrasonicSensor", false);

addDefaultPeerConfig(plan, name, "vertx", "Vertx", false);
addDefaultPeerConfig(plan, name, "webxr", "WebXR", false);

WebXRConfig webxr = (WebXRConfig)plan.get(getPeerName("webxr"));

Map<String, MapperSimple> map = new HashMap<>();
MapperSimple mapper = new MapperSimple(-0.5, 0.5, 0, 180);
map.put("i01.head.neck", mapper);
webxr.controllerMappings.put("head.orientation.pitch", map);

map = new HashMap<>();
mapper = new MapperSimple(-0.5, 0.5, 0, 180);
map.put("i01.head.rothead", mapper);
webxr.controllerMappings.put("head.orientation.yaw", map);

map = new HashMap<>();
mapper = new MapperSimple(-0.5, 0.5, 0, 180);
map.put("i01.head.roll", mapper);
webxr.controllerMappings.put("head.orientation.roll", map);

MouthControlConfig mouthControl = (MouthControlConfig) plan.get(getPeerName("mouthControl"));

// setup name references to different services FIXME getPeerName("head").getPeerName("jaw")
Expand Down Expand Up @@ -525,6 +547,10 @@ public Plan getDefault(Plan plan, String name) {
mouth_audioFile.listeners = new ArrayList<>();
mouth_audioFile.listeners.add(new Listener("publishPeak", name));
fsm.listeners.add(new Listener("publishStateChange", name, "publishStateChange"));

webxr.listeners = new ArrayList<>();
webxr.listeners.add(new Listener("publishJointAngles", name));

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

Expand Down
12 changes: 9 additions & 3 deletions src/main/java/org/myrobotlab/vertx/ApiVerticle.java
Original file line number Diff line number Diff line change
Expand Up @@ -47,14 +47,20 @@ public void start() throws Exception {
// static file routing - this is from a npm "build" ... but durin gdevelop its far
// easier to use setupProxy.js from a npm start .. but deployment would be easier with a "build"

//StaticHandler root = StaticHandler.create("src/main/resources/resource/Vertx/app");
// StaticHandler root = StaticHandler.create("src/main/resources/resource/Vertx/app");
StaticHandler root = StaticHandler.create("../robotlab-x-app/build/");
// new UI
// StaticHandler root = StaticHandler.create("../robotlab-x-app/build/");

// old UI (runtime vs dev time...)
StaticHandler root = StaticHandler.create("src/main/resources/resource/WebGui/app/");
root.setCachingEnabled(false);
root.setDirectoryListing(true);
root.setIndexPage("index.html");
// root.setAllowRootFileSystemAccess(true);
// root.setWebRoot(null);

VideoStreamHandler video = new VideoStreamHandler(service);

router.route("/video/*").handler(video);
router.route("/*").handler(root);


Expand Down

0 comments on commit 8149ae6

Please sign in to comment.