testsimbatch.java

来自「一款机器人仿真软件,功能上与microsoft robotics studio有」· Java 代码 · 共 64 行

JAVA
64
字号
/* author: Louis Hugues - created on 12 f巚r. 2005  */package simbad.gui;import javax.vecmath.Vector3d;import simbad.sim.*;/** * Test of the batch mode - test Simbatch class.   */public class TestSimbatch extends EnvironmentDescription {    public TestSimbatch() {        Wall w1 = new Wall(new Vector3d(9, 0, 0), 19, 1, this);        w1.rotate90(1);        add(w1);        Wall w2 = new Wall(new Vector3d(-9, 0, 0), 19, 2, this);        w2.rotate90(1);        add(w2);        Wall w3 = new Wall(new Vector3d(0, 0, 9), 19, 1, this);        add(w3);        Wall w4 = new Wall(new Vector3d(0, 0, -9), 19, 2, this);        add(w4);        add(new MyRobot(new Vector3d(-4, 0, -3.5f), "robot"));    }    public class MyRobot extends Agent {        public MyRobot(Vector3d position, String name) {            super(position, name);        }        /** Initialize Agent's Behavior */        public void initBehavior() {        // nothing particular in this case        }        /** Perform one step of Agent's Behavior */        public void performBehavior() {                        if (collisionDetected()) {                moveToStartPosition();            } else {                // progress at 0.5 m/s                setTranslationalVelocity(0.1);                setRotationalVelocity(0);            }           if (getCounter()% 100000 ==0)                System.out.println("Counter "+ getCounter());        }    }    public static void main(String[] args) {        Simbatch sim = new Simbatch(new TestSimbatch(),true);        sim.reset();        for (int i = 0 ; i < 10000000;i++) {            sim.step();        }        System.out.println("Done...");        sim.dispose();        System.exit(0);    }}

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?