Search in sources :

Example 1 with RoboReference

use of com.robo4j.core.RoboReference in project robo4j by Robo4J.

the class AccelerometerExample method main.

public static void main(String[] args) throws RoboBuilderException, IOException {
    RoboBuilder builder = new RoboBuilder();
    InputStream settings = RoboClassLoader.getInstance().getResource("accelerometerexample.xml");
    if (settings == null) {
        System.out.println("Could not find the settings for the GyroExample!");
        System.exit(2);
    }
    builder.add(settings);
    builder.add(AccelerometerProcessor.class, ID_PROCESSOR);
    RoboContext ctx = builder.build();
    System.out.println("State before start:");
    System.out.println(SystemUtil.printStateReport(ctx));
    ctx.start();
    System.out.println("State after start:");
    System.out.println(SystemUtil.printStateReport(ctx));
    RoboReference<AccelerometerRequest> accelerometer = ctx.getReference("accelerometer");
    RoboReference<AccelerometerEvent> processor = ctx.getReference(ID_PROCESSOR);
    System.out.println("Press enter to start!");
    System.in.read();
    accelerometer.sendMessage(new AccelerometerRequest(processor, true, (Float3D) -> true));
    System.out.println("Will report angular changes indefinitely.\nPress enter to quit!");
    System.in.read();
}
Also used : SystemUtil(com.robo4j.core.util.SystemUtil) RoboClassLoader(com.robo4j.core.client.util.RoboClassLoader) RoboReference(com.robo4j.core.RoboReference) RoboBuilder(com.robo4j.core.RoboBuilder) IOException(java.io.IOException) RoboContext(com.robo4j.core.RoboContext) RoboBuilderException(com.robo4j.core.RoboBuilderException) InputStream(java.io.InputStream) InputStream(java.io.InputStream) RoboBuilder(com.robo4j.core.RoboBuilder) RoboContext(com.robo4j.core.RoboContext)

Aggregations

RoboBuilder (com.robo4j.core.RoboBuilder)1 RoboBuilderException (com.robo4j.core.RoboBuilderException)1 RoboContext (com.robo4j.core.RoboContext)1 RoboReference (com.robo4j.core.RoboReference)1 RoboClassLoader (com.robo4j.core.client.util.RoboClassLoader)1 SystemUtil (com.robo4j.core.util.SystemUtil)1 IOException (java.io.IOException)1 InputStream (java.io.InputStream)1