java - 如何使用 Simbad 3d 机器人模拟器实现/执行新代码,错误 : Could not find or load main class Example1

标签 java eclipse robotics

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

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 IDE 启动模拟器。但是,当我尝试运行代码时,Simbad 打开演示模型而不是我的示例 1 教程代码。 如果我使用命令提示符来编译并运行程序:

 javac Example1.java
 java Example1

我收到错误:

Error: Could not find or load main class Example1

最佳答案

您的Example1位于examples包中。

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

javac 示例/Example1.java

java 示例/示例 1

关于java - 如何使用 Simbad 3d 机器人模拟器实现/执行新代码,错误 : Could not find or load main class Example1,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/44146026/

相关文章:

java - DTO 的更好方法?

java - Spring +Ehcache : How to cache find all result

java - 命名异常 : Cannot create resource instance with Jackrabbit in Tomcat

mysql - 有没有可用的插件可以让我用 eclipse 自动生成实体关系图

java - Eclipse IDE 安装失败,因为它找不到 mars 存储库

.net - 是否可以在 C++ .NET 中使用匿名函数?

java - 基于 Swing 的应用程序的最佳测试工具是什么?

eclipse - 如何将 Apache Axis2 Web 服务运行时添加到 Eclipse

c - 移动机器人(e-puck)编程(c语言)

robotics - 四轴飞行器距离 PID Controller