(这是我的第一支队伍) 在尝试编译我的代码并将结果放在Driver Station上时,在点击Play按钮后会出现一个" Module Not Specified"错误和结果代码未编译,操作模式随后不在驱动程序站上。我们现在使用Android Studio 3.0版(之前的版本已过时)。在以前的时间里,我们没有模块的这个错误。是否有人能够解释模块的概念以及如何添加模块以使此错误停止?我自己对使用Android Studio进行软件开发很新。虽然我不相信代码是错误,但我会为了上下文而提供它。任何帮助表示赞赏:D
package org.firstinspires.ftc.teamcode;
import com.qualcomm.robotcore.eventloop.opmode.OpMode;
import com.qualcomm.robotcore.eventloop.opmode.TeleOp;
import com.qualcomm.robotcore.hardware.DcMotor;
import org.firstinspires.ftc.robotcore.external.Telemetry;
@TeleOp(name="AutoDrive", group="TankDrive")
public class AutoDrive extends OpMode
{
private DcMotor leftFrontMotor = null;
private DcMotor leftBackMotor = null;
private DcMotor rightFrontMotor = null;
private DcMotor rightBackMotor = null;
boolean sent;
private int driveTime;
public void init()
{
leftFrontMotor = hardwareMap.dcMotor.get("leftFront"); //Get motor objects, store them in corresponding reference variables
rightFrontMotor = hardwareMap.dcMotor.get("rightFront");
leftFrontMotor.setPower(0);
rightFrontMotor.setPower(0);
driveTime = 3000 // Robot will take 3 seconds with current weight to drive to safe zone
Telemetry.addLine("Hardware variables successfully instantiated");
sent = Telemetry.update();
}
public void start()
{
long limit = System.currentTimeMillis() + driveTime;
while(System.currentTimeMillis() < limit) //drive in straight line for limit seconds
drive();
Telemetry.addLine("Stopping..");
sent = Telemetry.update();
}
public void loop() {}
public void stop()
{
leftFrontMotor.setPower(0);
rightFrontMotor.setPower(0);
Telemetry.addLine("Robot successfully stopped.");
sent = Telemetry.update();
}
private void drive()
{
leftFrontMotor.setPower(1);
rightFrontMotor.setPower(1);
}
}
答案 0 :(得分:0)
Telemetry.addLine("Hardware variables successfully instantiated");
sent = Telemetry.update();
应该是
telemetry.addLine("Hardware variables successfully instantiated");
sent = telemetry.update();
小写时,您将在OpMode中引用遥测对象(这是您想要的)。 addLine和update方法不是静态的,因此您无法通过Telemetry类调用它们。
答案 1 :(得分:0)
leftFrontMotor = hardwareMap.dcMotor.get("leftFront"); //Get motor objects, store them in corresponding reference variables
rightFrontMotor = hardwareMap.dcMotor.get("rightFront");
应该是
leftFrontMotor = hardwareMap.DcMotor.get("leftFront"); //Get motor objects, store them in corresponding reference variables
rightFrontMotor = hardwareMap.DcMotor.get("rightFront");