RLPark 1.0.0
Reinforcement Learning Framework in Java

CreateIntroSession.java

Go to the documentation of this file.
00001 package rlpark.example.irobot.examples;
00002 
00003 import rlpark.plugin.irobot.data.CreateAction;
00004 import rlpark.plugin.irobot.data.IRobotLabels;
00005 import rlpark.plugin.irobot.robots.CreateRobot;
00006 import zephyr.plugin.core.api.Zephyr;
00007 import zephyr.plugin.core.api.synchronization.Clock;
00008 
00009 public class CreateIntroSession {
00010   public static void main(String[] args) {
00011     Clock clock = new Clock("Create");
00012     CreateRobot robot = new CreateRobot("/dev/cu.ElementSerial-ElementSe");
00013     Zephyr.advertise(clock, robot);
00014     int bumpRightObsIndex = robot.legend().indexOf(IRobotLabels.BumpRight);
00015     int bumpLeftObsIndex = robot.legend().indexOf(IRobotLabels.BumpLeft);
00016     robot.safeMode();
00017     while (!robot.isClosed() && clock.tick()) {
00018       double obs[] = robot.waitNewObs();
00019       double wheelLeft = obs[bumpRightObsIndex] == 0 ? 150 : -150;
00020       double wheelRight = obs[bumpLeftObsIndex] == 0 ? 150 : -70;
00021       robot.sendAction(new CreateAction(wheelLeft, wheelRight));
00022     }
00023   }
00024 }
 All Classes Namespaces Files Functions Variables Enumerations
Zephyr
RLPark