首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >如何使用Simbad 3d机器人模拟器实现/执行新代码,错误:无法找到或加载主类Example1

如何使用Simbad 3d机器人模拟器实现/执行新代码,错误:无法找到或加载主类Example1
EN

Stack Overflow用户
提问于 2017-05-23 22:26:01
回答 1查看 219关注 0票数 1

我正在尝试执行http://simbad.sourceforge.net/code/Example1.java,即:

代码语言:javascript
复制
package examples;


import simbad.gui.Simbad;
import simbad.sim.*;
import javax.vecmath.Vector3d;
import javax.vecmath.Vector3f;

public class Example1 {

    /** Describe the robot */
    static public class Robot extends Agent {

        RangeSensorBelt sonars;
        CameraSensor camera;

        public Robot(Vector3d position, String name) {
            super(position, name);
            // Add camera
            camera = RobotFactory.addCameraSensor(this);
            // Add sonars
            sonars = RobotFactory.addSonarBeltSensor(this);
        }

        /** This method is called by the simulator engine on reset. */
        public void initBehavior() {
            // nothing particular in this case
        }

        /** This method is call cyclically (20 times per second)  by the simulator engine. */
        public void performBehavior() {

            // progress at 0.5 m/s
            setTranslationalVelocity(0.5);
            // frequently change orientation
            if ((getCounter() % 100) == 0)
                setRotationalVelocity(Math.PI / 2 * (0.5 - Math.random()));

            // print front sonar every 100 frames
            if (getCounter() % 100 == 0)
                System.out
                        .println("Sonar num 0  = " + sonars.getMeasurement(0));

        }
    }

    /** Describe the environement */
    static public class MyEnv extends EnvironmentDescription {
        public MyEnv() {
            light1IsOn = true;
            light2IsOn = false;
            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);
            Box b1 = new Box(new Vector3d(-3, 0, -3), new Vector3f(1, 1, 1),
                    this);
            add(b1);
            add(new Arch(new Vector3d(3, 0, -3), this));
            add(new Robot(new Vector3d(0, 0, 0), "robot 1"));

        }
    }

    public static void main(String[] args) {
        // request antialising
        System.setProperty("j3d.implicitAntialiasing", "true");
        // create Simbad instance with given environment
        Simbad frame = new Simbad(new MyEnv(), false);
    }

}

我使用https://stackoverflow.com/a/20863447/8045544技术启动Simbad 1.4。我还成功地使用Eclipse启动了模拟器。但是当我试图运行代码时,Simbad会打开演示模型,而不是我的Example1教程代码。如果我使用命令提示符编译和运行程序:

代码语言:javascript
复制
 javac Example1.java
 java Example1

我得到了错误:

代码语言:javascript
复制
Error: Could not find or load main class Example1
EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2017-05-23 23:04:43

您的Example1examples包中。

您需要将您的Examples1.java放在examples文件夹中,然后从上面的一个文件夹中执行:

javac examples/Example1.java

java examples/Example1

票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/44146026

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档