Glove + Exo composite solution
Android Java SDK: Glove + Exo composite solution
Glove + Exo composite solution
Use the Maven directory from the complete Glove offline archive as the QnBot Maven repository, then use the Gradle dependencies below.
Install both components from the matching offline delivery. Pass the authorized shared serial port once in the outer configuration. Create one Sdk with this configuration, call sdk.start() to start all three members, then select data channels through sdk.glove() and sdk.exo().
Configuration approach
CompositeExoGloveConfig.builder().name(...) sets the composite outer name, independent of member names. The outer connection is the shared serial port; devices contains two gloves and one Exo. Members still use ordinary GloveConfig and ExoConfig.
The examples below are the shared Exo+Glove sources from examples-public/examples/composite-exo-glove/java. Each one creates a single root Sdk and selects member domains with sdk.glove() and sdk.exo().
Quick start
The public QuickStart example connects the composite device, subscribes both glove poses before start, and prints each glove's sequence, thumb and index positions.
import android.content.Context;
import com.qnbot.sdk.Sdk;
import com.qnbot.sdk.SdkConfig;
import com.qnbot.sdk.android.SerialTransport;
import com.qnbot.sdk.config.CompositeExoGloveConfig;
import com.qnbot.sdk.config.Side;
import com.qnbot.sdk.exo.ExoConfig;
import com.qnbot.sdk.glove.Glove;
import com.qnbot.sdk.glove.GloveConfig;
import com.qnbot.sdk.glove.GloveDevice;
import com.qnbot.sdk.glove.GloveFinger;
/**
* Connects one composite Exo+Glove device and prints the pose of both gloves.
*
* <p>Supply an Android {@link Context} and an authorized {@link SerialTransport}; the SDK
* auto-discovers the shared endpoint. One root Sdk owns the whole composite link.
*/
public final class QuickStart {
private QuickStart() {}
public static void run(Context context, SerialTransport transport) {
SdkConfig config = SdkConfig.builder()
.device(CompositeExoGloveConfig.builder()
.devices(GloveConfig.builder().side(Side.LEFT).build(),
GloveConfig.builder().side(Side.RIGHT).build(),
ExoConfig.builder().build())
.build())
.build();
try (Sdk sdk = new Sdk(config, context, transport)) {
Glove glove = sdk.glove();
GloveDevice left = glove.device(Side.LEFT);
GloveDevice right = glove.device(Side.RIGHT);
// Subscribe before start so the first samples of both gloves are observed.
left.pose().subscribe(sample -> System.out.println("left sequence=" + sample.sequence
+ " thumb=" + sample.value.payload.fingertipLocal.get(GloveFinger.THUMB).position
+ " index=" + sample.value.payload.fingertipLocal.get(GloveFinger.INDEX).position));
right.pose().subscribe(sample -> System.out.println("right sequence=" + sample.sequence
+ " thumb=" + sample.value.payload.fingertipLocal.get(GloveFinger.THUMB).position
+ " index=" + sample.value.payload.fingertipLocal.get(GloveFinger.INDEX).position));
// The root Sdk starts both glove members and the Exo over their shared serial link.
sdk.start();
sdk.runForever();
}
}
}QuickStart.run(context, transport) uses automatic discovery for the shared endpoint. sdk.runForever() blocks the worker; close the root Sdk from another worker to stop. Do not call it on the UI thread.
Device information
import android.content.Context;
import com.qnbot.sdk.Sdk;
import com.qnbot.sdk.SdkConfig;
import com.qnbot.sdk.android.SerialTransport;
import com.qnbot.sdk.config.CompositeExoGloveConfig;
import com.qnbot.sdk.config.SerialConnection;
import com.qnbot.sdk.config.Side;
import com.qnbot.sdk.exo.Exo;
import com.qnbot.sdk.exo.ExoConfig;
import com.qnbot.sdk.exo.ExoDevice;
import com.qnbot.sdk.exo.ExoDeviceInfo;
import com.qnbot.sdk.glove.Glove;
import com.qnbot.sdk.glove.GloveConfig;
import com.qnbot.sdk.glove.GloveDevice;
/**
* Shows the members of one composite Exo+Glove device: the two glove source IDs plus the Exo
* product, firmware, protocol and capability details. Callers supply an authorized transport and
* the shared port; the single Sdk is closed after the read.
*/
public final class DeviceInfo {
private DeviceInfo() {}
public static void run(Context context, SerialTransport transport, String port) {
SdkConfig config = SdkConfig.builder()
.device(CompositeExoGloveConfig.builder()
.connection(SerialConnection.port(port))
.devices(GloveConfig.builder().side(Side.LEFT).build(),
GloveConfig.builder().side(Side.RIGHT).build(), ExoConfig.builder().build())
.build())
.build();
try (Sdk sdk = new Sdk(config, context, transport)) {
// One root Sdk exposes both member domains for the shared link.
Glove glove = sdk.glove();
Exo exo = sdk.exo();
GloveDevice left = glove.device(Side.LEFT);
GloveDevice right = glove.device(Side.RIGHT);
ExoDevice exoDevice = exo.device();
System.out.println("left source=" + left.sourceId());
System.out.println("right source=" + right.sourceId());
ExoDeviceInfo info = exoDevice.getDeviceInfo();
System.out.println("product=" + info.product + " serial=" + info.serialNumber + " firmware="
+ info.firmware.platform + "." + info.firmware.revision + "." + info.firmware.feature
+ "." + info.firmware.build + " protocol=" + info.protocolVersion.major + "."
+ info.protocolVersion.minor + " encoders=" + info.components.encoders.available + "/"
+ info.components.encoders.totalSlots + " handsets=" + info.capabilities.handsets
+ " imus=" + info.capabilities.imus + " haptics=" + info.capabilities.haptics
+ " wireless=" + info.capabilities.wireless);
}
}
}DeviceInfo.run(context, transport, port) prints each glove's sourceId() and the Exo product, serial, firmware, protocol, encoder counts and capability flags. The single Sdk closes after the read.
Discovery
import android.content.Context;
import com.qnbot.sdk.Sdk;
import com.qnbot.sdk.SdkConfig;
import com.qnbot.sdk.android.SerialTransport;
import com.qnbot.sdk.config.CompositeExoGloveConfig;
import com.qnbot.sdk.config.SerialConnection;
import com.qnbot.sdk.config.Side;
import com.qnbot.sdk.exo.Exo;
import com.qnbot.sdk.exo.ExoConfig;
import com.qnbot.sdk.exo.ExoDeviceInfo;
import com.qnbot.sdk.glove.Glove;
import com.qnbot.sdk.glove.GloveConfig;
/**
* Discovers a composite Exo+Glove device and prints the two glove sources and the Exo identity.
* Callers supply the authorized transport; pass a shared port, or null to discover the only
* authorized one. The transport inventory is listed before the Sdk is created.
*/
public final class DiscoverExoGlove {
private DiscoverExoGlove() {}
public static void run(Context context, SerialTransport transport, String port) throws Exception {
// Android needs the authorized endpoint list before the SDK takes ownership of the transport.
System.out.println("USB candidates=" + transport.inventory());
SerialConnection connection = port == null
? SerialConnection.autoDiscover()
: SerialConnection.port(port);
SdkConfig config = SdkConfig.builder()
.device(CompositeExoGloveConfig.builder()
.connection(connection)
.devices(GloveConfig.builder().side(Side.LEFT).build(),
GloveConfig.builder().side(Side.RIGHT).build(), ExoConfig.builder().build())
.build())
.build();
try (Sdk sdk = new Sdk(config, context, transport)) {
// One root Sdk exposes both member domains for the shared link.
Glove glove = sdk.glove();
Exo exo = sdk.exo();
System.out.println("left source=" + glove.device(Side.LEFT).sourceId());
System.out.println("right source=" + glove.device(Side.RIGHT).sourceId());
ExoDeviceInfo info = exo.device().getDeviceInfo();
System.out.println("Exo product=" + info.product + " serial=" + info.serialNumber
+ " hardware=" + info.hardwareName);
}
}
}DiscoverExoGlove.run lists transport.inventory() before the SDK takes ownership, then uses SerialConnection.autoDiscover() for a null port or the explicit shared port. It prints both glove sources and the Exo identity.
Telemetry
import android.content.Context;
import com.qnbot.sdk.Sdk;
import com.qnbot.sdk.SdkConfig;
import com.qnbot.sdk.android.SerialTransport;
import com.qnbot.sdk.config.CompositeExoGloveConfig;
import com.qnbot.sdk.config.SerialConnection;
import com.qnbot.sdk.config.Side;
import com.qnbot.sdk.exo.Exo;
import com.qnbot.sdk.exo.ExoConfig;
import com.qnbot.sdk.exo.ExoDevice;
import com.qnbot.sdk.glove.Glove;
import com.qnbot.sdk.glove.GloveConfig;
import com.qnbot.sdk.glove.GloveDevice;
import com.qnbot.sdk.glove.GloveFinger;
/**
* Reads combined telemetry from one composite Exo+Glove link: both glove poses, both glove status
* streams, Exo telemetry and Exo status.
*
* <p>Callers supply the authorized transport and the shared port. The root Sdk drives all three
* members.
*/
public final class Telemetry {
private Telemetry() {}
public static void run(Context context, SerialTransport transport, String port) {
SdkConfig config = SdkConfig.builder()
.device(CompositeExoGloveConfig.builder()
.connection(SerialConnection.port(port))
.devices(GloveConfig.builder().side(Side.LEFT).build(),
GloveConfig.builder().side(Side.RIGHT).build(),
ExoConfig.builder().build())
.build())
.build();
try (Sdk sdk = new Sdk(config, context, transport)) {
// One root Sdk exposes both member domains for the same composite link.
Glove glove = sdk.glove();
Exo exo = sdk.exo();
GloveDevice left = glove.device(Side.LEFT);
GloveDevice right = glove.device(Side.RIGHT);
ExoDevice exoDevice = exo.device();
left.pose().subscribe(sample
-> System.out.println("left sequence=" + sample.sequence
+ " thumb=" + sample.value.payload.fingertipLocal.get(GloveFinger.THUMB).position
+ " index=" + sample.value.payload.fingertipLocal.get(GloveFinger.INDEX).position));
right.pose().subscribe(sample
-> System.out.println("right sequence=" + sample.sequence
+ " thumb=" + sample.value.payload.fingertipLocal.get(GloveFinger.THUMB).position
+ " index=" + sample.value.payload.fingertipLocal.get(GloveFinger.INDEX).position));
exoDevice.telemetry().subscribe(sample
-> System.out.println("telemetry sequence=" + sample.sequence
+ " leftEncoders=" + sample.value.payload.leftArm.encoderCounts
+ " rightEncoders=" + sample.value.payload.rightArm.encoderCounts
+ " leftRadians=" + sample.value.payload.leftArm.jointPositionsRad
+ " rightRadians=" + sample.value.payload.rightArm.jointPositionsRad));
left.status().subscribe(sample
-> System.out.println(
"left connected=" + sample.value.connected + " stale=" + sample.value.stale));
right.status().subscribe(sample
-> System.out.println(
"right connected=" + sample.value.connected + " stale=" + sample.value.stale));
exoDevice.status().subscribe(sample
-> System.out.println(
"exo connected=" + sample.value.connected + " stale=" + sample.value.stale));
// Start after subscribing, then let the root runner drive every scheduled task.
sdk.start();
sdk.runForever();
}
}
}Telemetry subscribes both glove poses, both glove status channels, Exo telemetry and Exo status before sdk.start(). The root runner drives all three members.
Glove retargeting
import android.content.Context;
import com.qnbot.sdk.Sdk;
import com.qnbot.sdk.SdkConfig;
import com.qnbot.sdk.android.SerialTransport;
import com.qnbot.sdk.config.CompositeExoGloveConfig;
import com.qnbot.sdk.config.DeviceSelector;
import com.qnbot.sdk.config.SerialConnection;
import com.qnbot.sdk.config.Side;
import com.qnbot.sdk.config.TargetAlgorithm;
import com.qnbot.sdk.config.TargetConfig;
import com.qnbot.sdk.exo.ExoConfig;
import com.qnbot.sdk.glove.Glove;
import com.qnbot.sdk.glove.GloveConfig;
import com.qnbot.sdk.glove.GloveDevice;
/**
* Subscribes to both retargeted hand outputs of one composite Exo+Glove device.
*
* <p>Callers supply an authorized transport, the shared port and a target-hand algorithm package
* prepared for this app. The root Sdk drives both targets.
*/
public final class GloveRetargeting {
private GloveRetargeting() {}
public static void run(Context context, SerialTransport transport, String port,
String packageId) {
SdkConfig config = SdkConfig.builder()
.device(CompositeExoGloveConfig.builder()
.connection(SerialConnection.port(port))
.devices(GloveConfig.builder().side(Side.LEFT).build(),
GloveConfig.builder().side(Side.RIGHT).build(),
ExoConfig.builder().build())
.build())
.target(TargetConfig.builder()
.name("left-hand")
.side(Side.LEFT)
.source(new DeviceSelector("glove", null, Side.LEFT))
.algorithm(new TargetAlgorithm(packageId))
.build())
.target(TargetConfig.builder()
.name("right-hand")
.side(Side.RIGHT)
.source(new DeviceSelector("glove", null, Side.RIGHT))
.algorithm(new TargetAlgorithm(packageId))
.build())
.build();
try (Sdk sdk = new Sdk(config, context, transport)) {
Glove glove = sdk.glove();
GloveDevice left = glove.device(Side.LEFT);
GloveDevice right = glove.device(Side.RIGHT);
// Subscribe both target outputs before start; the SDK keeps its default Capture interaction.
left.output("left-hand").subscribe(sample
-> System.out.println("left retargeting sequence=" + sample.sequence
+ " target=" + sample.value.target + " joints=" + sample.value.joints));
right.output("right-hand").subscribe(sample
-> System.out.println("right retargeting sequence=" + sample.sequence
+ " target=" + sample.value.target + " joints=" + sample.value.joints));
sdk.start();
sdk.runForever();
}
}
}GloveRetargeting.run configures one TargetConfig per hand with a prepared packageId, then subscribes both output channels before start. Keep the SDK's default capture interaction unless your app provides the corresponding input flow.
Glove haptics
import android.content.Context;
import com.qnbot.sdk.Sdk;
import com.qnbot.sdk.SdkConfig;
import com.qnbot.sdk.android.SerialTransport;
import com.qnbot.sdk.config.CompositeExoGloveConfig;
import com.qnbot.sdk.config.SerialConnection;
import com.qnbot.sdk.config.Side;
import com.qnbot.sdk.exo.ExoConfig;
import com.qnbot.sdk.glove.Glove;
import com.qnbot.sdk.glove.GloveConfig;
import com.qnbot.sdk.glove.GloveDevice;
import com.qnbot.sdk.glove.GloveFinger;
import com.qnbot.sdk.glove.Haptics;
/**
* Submits haptics requests to both gloves of a composite Exo+Glove device and holds them for the
* caller's duration. Composite devices accept but ignore glove haptics, so this example shows the
* request path only. Callers supply the authorized transport, the shared port and hold seconds.
*/
public final class GloveHaptics {
private GloveHaptics() {}
public static void run(Context context, SerialTransport transport, String port,
double holdSeconds) throws InterruptedException {
if (!Double.isFinite(holdSeconds) || holdSeconds < 0)
throw new IllegalArgumentException("holdSeconds must be finite and nonnegative");
SdkConfig config = SdkConfig.builder()
.device(CompositeExoGloveConfig.builder()
.connection(SerialConnection.port(port))
.devices(GloveConfig.builder().side(Side.LEFT).build(),
GloveConfig.builder().side(Side.RIGHT).build(), ExoConfig.builder().build())
.build())
.build();
try (Sdk sdk = new Sdk(config, context, transport)) {
// One root Sdk owns the shared link; the glove domain selects both hands.
Glove glove = sdk.glove();
GloveDevice left = glove.device(Side.LEFT);
GloveDevice right = glove.device(Side.RIGHT);
sdk.start();
Haptics request =
Haptics.builder().set(GloveFinger.THUMB, 80).set(GloveFinger.INDEX, 40).build();
try {
left.haptics().set(request);
right.haptics().set(request);
System.out.println("Composite Glove haptics requests are ignored; no physical output");
Thread.sleep((long) (holdSeconds * 1000));
} finally {
left.haptics().clear();
right.haptics().clear();
}
}
}
}GloveHaptics submits the same request to both gloves, holds it for holdSeconds, and clears both in a finally block. Composite devices accept but ignore glove haptics, so this request path produces no physical vibration.
Exo IMU
import android.content.Context;
import com.qnbot.sdk.Sdk;
import com.qnbot.sdk.SdkConfig;
import com.qnbot.sdk.android.SerialTransport;
import com.qnbot.sdk.config.CompositeExoGloveConfig;
import com.qnbot.sdk.config.SerialConnection;
import com.qnbot.sdk.config.Side;
import com.qnbot.sdk.exo.Exo;
import com.qnbot.sdk.exo.ExoConfig;
import com.qnbot.sdk.exo.ExoDevice;
import com.qnbot.sdk.exo.ExoImuState;
import com.qnbot.sdk.glove.GloveConfig;
/**
* Reads the Exo IMUs reported by a composite Exo+Glove device. The shared link does not expose raw
* glove IMU, so this example checks the Exo capability and subscribes to Exo telemetry only.
*/
public final class Imu {
private Imu() {}
public static void run(Context context, SerialTransport transport, String port) {
SdkConfig config = SdkConfig.builder()
.device(CompositeExoGloveConfig.builder()
.connection(SerialConnection.port(port))
.devices(GloveConfig.builder().side(Side.LEFT).build(),
GloveConfig.builder().side(Side.RIGHT).build(),
ExoConfig.builder().build())
.build())
.build();
try (Sdk sdk = new Sdk(config, context, transport)) {
Exo exo = sdk.exo();
ExoDevice exoDevice = exo.device();
if (!exoDevice.getDeviceInfo().capabilities.imus) {
System.out.println("Exo has no IMU capability; composite Glove raw IMU is unavailable");
return;
}
exoDevice.telemetry().subscribe(sample -> {
for (ExoImuState imu :
new ExoImuState[] {sample.value.payload.torsoImu, sample.value.payload.extraImu}) {
if (imu != null)
System.out.println("IMU sequence=" + sample.sequence + " acceleration="
+ imu.accelerationMps2 + " angularVelocity=" + imu.angularVelocityRadS
+ " quaternion=" + imu.orientationXyzw);
}
});
sdk.start();
sdk.runForever();
}
}
}Imu checks the Exo IMU capability and reads the Exo telemetry payload. The shared link does not expose raw glove IMU, so the example reports that case and prints only available Exo states.
Lifecycle
import android.content.Context;
import com.qnbot.sdk.Sdk;
import com.qnbot.sdk.SdkConfig;
import com.qnbot.sdk.android.SerialTransport;
import com.qnbot.sdk.config.CompositeExoGloveConfig;
import com.qnbot.sdk.config.SerialConnection;
import com.qnbot.sdk.config.Side;
import com.qnbot.sdk.exo.Exo;
import com.qnbot.sdk.exo.ExoConfig;
import com.qnbot.sdk.exo.ExoDevice;
import com.qnbot.sdk.glove.Glove;
import com.qnbot.sdk.glove.GloveConfig;
import com.qnbot.sdk.glove.GloveDevice;
/**
* Runs one bounded composite lifecycle: start the root Sdk, advance one update, print the member
* sources and the latest glove pose and Exo telemetry samples, then stop and close. Callers supply
* an authorized transport and the shared port; the method returns after cleanup.
*/
public final class Lifecycle {
private Lifecycle() {}
public static void run(Context context, SerialTransport transport, String port) {
SdkConfig config = SdkConfig.builder()
.device(CompositeExoGloveConfig.builder()
.connection(SerialConnection.port(port))
.devices(GloveConfig.builder().side(Side.LEFT).build(),
GloveConfig.builder().side(Side.RIGHT).build(), ExoConfig.builder().build())
.build())
.build();
try (Sdk sdk = new Sdk(config, context, transport)) {
// One root Sdk owns the shared link and both member domains.
Glove glove = sdk.glove();
Exo exo = sdk.exo();
GloveDevice left = glove.device(Side.LEFT);
GloveDevice right = glove.device(Side.RIGHT);
ExoDevice exoDevice = exo.device();
sdk.start();
sdk.update();
System.out.println("started Left Glove=" + left.sourceId()
+ " Right Glove=" + right.sourceId() + " Exo=" + exoDevice.sourceId());
left.pose().latest().ifPresent(
sample -> System.out.println("left sequence=" + sample.sequence));
right.pose().latest().ifPresent(
sample -> System.out.println("right sequence=" + sample.sequence));
exoDevice.telemetry().latest().ifPresent(
sample -> System.out.println("Exo sequence=" + sample.sequence));
sdk.stop();
System.out.println("stopped");
}
System.out.println("closed");
}
}Lifecycle starts the root Sdk, advances one update, prints the member sources and the latest glove and Exo samples, then stops and closes. The method returns after cleanup.