Push
This commit is contained in:
parent
ae5e442336
commit
450acf62c6
|
@ -1,8 +1,9 @@
|
||||||
<?xml version="1.0" encoding="UTF-8"?>
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
<project version="4">
|
<project version="4">
|
||||||
<component name="EntryPointsManager">
|
<component name="EntryPointsManager">
|
||||||
<list size="1">
|
<list size="2">
|
||||||
<item index="0" class="java.lang.String" itemvalue="com.qualcomm.robotcore.eventloop.opmode.TeleOp" />
|
<item index="0" class="java.lang.String" itemvalue="com.qualcomm.robotcore.eventloop.opmode.Autonomous" />
|
||||||
|
<item index="1" class="java.lang.String" itemvalue="com.qualcomm.robotcore.eventloop.opmode.TeleOp" />
|
||||||
</list>
|
</list>
|
||||||
</component>
|
</component>
|
||||||
<component name="ExternalStorageConfigurationManager" enabled="true" />
|
<component name="ExternalStorageConfigurationManager" enabled="true" />
|
||||||
|
|
|
@ -99,7 +99,7 @@ import java.util.Locale;
|
||||||
* @see <a href="https://ae-bst.resource.bosch.com/media/_tech/media/datasheets/BST_BNO055_DS000_14.pdf">BNO055 specification</a>
|
* @see <a href="https://ae-bst.resource.bosch.com/media/_tech/media/datasheets/BST_BNO055_DS000_14.pdf">BNO055 specification</a>
|
||||||
*/
|
*/
|
||||||
@TeleOp(name = "Sensor: BNO055 IMU Calibration", group = "Sensor")
|
@TeleOp(name = "Sensor: BNO055 IMU Calibration", group = "Sensor")
|
||||||
@Disabled // Uncomment this to add to the opmode list
|
// @Disabled // Uncomment this to add to the opmode list
|
||||||
public class SensorBNO055IMUCalibration extends LinearOpMode
|
public class SensorBNO055IMUCalibration extends LinearOpMode
|
||||||
{
|
{
|
||||||
//----------------------------------------------------------------------------------------------
|
//----------------------------------------------------------------------------------------------
|
||||||
|
|
|
@ -122,7 +122,7 @@ public class API {
|
||||||
}
|
}
|
||||||
|
|
||||||
public static class HubIMU {
|
public static class HubIMU {
|
||||||
private final BNO055IMU imu;
|
public final BNO055IMU imu;
|
||||||
private final String name;
|
private final String name;
|
||||||
private double zeroPos;
|
private double zeroPos;
|
||||||
|
|
||||||
|
@ -139,6 +139,7 @@ public class API {
|
||||||
parameters.pitchMode = BNO055IMU.PitchMode.WINDOWS;
|
parameters.pitchMode = BNO055IMU.PitchMode.WINDOWS;
|
||||||
parameters.loggingEnabled = true;
|
parameters.loggingEnabled = true;
|
||||||
parameters.loggingTag = "IMU";
|
parameters.loggingTag = "IMU";
|
||||||
|
parameters.calibrationDataFile = "AdafruitIMUCalibration.json";
|
||||||
imu.initialize(parameters);
|
imu.initialize(parameters);
|
||||||
}
|
}
|
||||||
private double[] getAngles() {
|
private double[] getAngles() {
|
||||||
|
|
|
@ -14,7 +14,7 @@ public class Gamepad extends OpMode {
|
||||||
API.print("Status", "Initializing, please wait");
|
API.print("Status", "Initializing, please wait");
|
||||||
API.pause(1);
|
API.pause(1);
|
||||||
|
|
||||||
MovementAPI.init(API.Motor.M0, API.Motor.M1, API.Motor.M3, API.Motor.M2);
|
MovementAPI.init(API.Motor.M0, API.Motor.M1, API.Motor.M2, API.Motor.M3);
|
||||||
|
|
||||||
API.clear();
|
API.clear();
|
||||||
API.print("Press play to start");
|
API.print("Press play to start");
|
||||||
|
|
|
@ -0,0 +1,62 @@
|
||||||
|
package org.firstinspires.ftc.teamcode;
|
||||||
|
|
||||||
|
import com.qualcomm.hardware.bosch.BNO055IMU;
|
||||||
|
import com.qualcomm.robotcore.eventloop.opmode.Autonomous;
|
||||||
|
import com.qualcomm.robotcore.eventloop.opmode.OpMode;
|
||||||
|
import com.qualcomm.robotcore.hardware.DcMotor;
|
||||||
|
|
||||||
|
import org.firstinspires.ftc.robotcore.external.navigation.Acceleration;
|
||||||
|
import org.firstinspires.ftc.robotcore.external.navigation.DistanceUnit;
|
||||||
|
import org.firstinspires.ftc.robotcore.external.navigation.Position;
|
||||||
|
import org.firstinspires.ftc.robotcore.external.navigation.Velocity;
|
||||||
|
|
||||||
|
@Autonomous(name="IMU Code Reborn")
|
||||||
|
public class IMUOpMode extends OpMode {
|
||||||
|
DcMotor frontLeft, frontRight, backLeft, backRight;
|
||||||
|
BNO055IMU imu;
|
||||||
|
long loop = Long.MAX_VALUE;
|
||||||
|
int ms = 100;
|
||||||
|
@Override
|
||||||
|
public void init() {
|
||||||
|
API.init(this);
|
||||||
|
frontLeft = hardwareMap.get(DcMotor.class, "m0");
|
||||||
|
frontRight = hardwareMap.get(DcMotor.class, "m1");
|
||||||
|
backLeft = hardwareMap.get(DcMotor.class, "m2");
|
||||||
|
backRight = hardwareMap.get(DcMotor.class, "m3");
|
||||||
|
imu = API.imu.imu;
|
||||||
|
//imu = hardwareMap.get(BNO055IMU.class, "imu");
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void start() {
|
||||||
|
imu.startAccelerationIntegration(new Position(DistanceUnit.METER, 1, 2, 0, 0), new Velocity(DistanceUnit.METER, 0, 0, 0, 0), ms);
|
||||||
|
loop = System.currentTimeMillis()+ms;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void loop() {
|
||||||
|
while (System.currentTimeMillis()<loop);
|
||||||
|
Position currentPosition = imu.getPosition().toUnit(DistanceUnit.METER);
|
||||||
|
Velocity currentVelocity = imu.getVelocity().toUnit(DistanceUnit.METER);
|
||||||
|
Acceleration currentAcceleration = imu.getAcceleration().toUnit(DistanceUnit.METER);
|
||||||
|
API.print(
|
||||||
|
currentPosition.y + " " + currentPosition.x + "\n" +
|
||||||
|
currentVelocity.yVeloc + " " + currentVelocity.xVeloc + "\n" +
|
||||||
|
currentAcceleration.yAccel + " " + currentAcceleration.xAccel
|
||||||
|
);
|
||||||
|
/*double x2 = x+currentPosition.y;
|
||||||
|
double y2 = y-currentPosition.x;
|
||||||
|
API.print("X, Y", x2 +", " + y2);
|
||||||
|
double flbr = y2+x2;
|
||||||
|
double frbl = y2-x2;
|
||||||
|
double max = 2.5*Math.max(Math.abs(flbr),Math.abs(frbl));
|
||||||
|
flbr/=max;
|
||||||
|
frbl/=max;
|
||||||
|
frontLeft.setPower(flbr);
|
||||||
|
frontRight.setPower(frbl);
|
||||||
|
backLeft.setPower(-frbl);
|
||||||
|
backRight.setPower(-flbr);*/
|
||||||
|
loop+=ms;
|
||||||
|
}
|
||||||
|
}
|
|
@ -15,7 +15,7 @@ buildscript {
|
||||||
jcenter()
|
jcenter()
|
||||||
}
|
}
|
||||||
dependencies {
|
dependencies {
|
||||||
classpath 'com.android.tools.build:gradle:4.0.1'
|
classpath 'com.android.tools.build:gradle:7.0.3'
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
2
gradle/wrapper/gradle-wrapper.properties
vendored
2
gradle/wrapper/gradle-wrapper.properties
vendored
|
@ -3,4 +3,4 @@ distributionBase=GRADLE_USER_HOME
|
||||||
distributionPath=wrapper/dists
|
distributionPath=wrapper/dists
|
||||||
zipStoreBase=GRADLE_USER_HOME
|
zipStoreBase=GRADLE_USER_HOME
|
||||||
zipStorePath=wrapper/dists
|
zipStorePath=wrapper/dists
|
||||||
distributionUrl=https\://services.gradle.org/distributions/gradle-6.1.1-all.zip
|
distributionUrl=https\://services.gradle.org/distributions/gradle-7.0.2-all.zip
|
||||||
|
|
Loading…
Reference in a new issue