Skip to content

Commit f5e23a8

Browse files
authored
Merge pull request #2 from CapitalRobotics/drive_base
Initial structure and implementation of Mecanum drive base
2 parents 8840924 + 436efdd commit f5e23a8

9 files changed

Lines changed: 141 additions & 1 deletion

File tree

TeamCode/build.gradle

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ apply from: '../build.common.gradle'
1616
apply from: '../build.dependencies.gradle'
1717

1818
android {
19-
namespace = 'org.firstinspires.ftc.teamcode'
19+
namespace = 'org.mrpsvt.capital_robotics'
2020

2121
packagingOptions {
2222
jniLibs.useLegacyPackaging true
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
package org.mrpsvt.capital_robotics;
2+
3+
public class ArtifactIntake {
4+
}
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
package org.mrpsvt.capital_robotics;
2+
3+
public class ArtifactLauncher {
4+
}
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
package org.mrpsvt.capital_robotics.control;
2+
3+
import com.qualcomm.robotcore.hardware.HardwareMap;
4+
5+
public class ControlConstants {
6+
}
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
package org.mrpsvt.capital_robotics.control;
2+
3+
import com.seattlesolvers.solverslib.gamepad.GamepadEx;
4+
5+
public class ControlMap {
6+
7+
public GamepadEx driver1;
8+
public GamepadEx driver2;
9+
}
Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
package org.mrpsvt.capital_robotics.robot_core;
2+
import org.mrpsvt.capital_robotics.robot_core.DriveConstants;
3+
4+
import com.qualcomm.robotcore.hardware.DcMotor;
5+
import com.qualcomm.robotcore.hardware.HardwareMap;
6+
import com.qualcomm.robotcore.hardware.IMU;
7+
import com.seattlesolvers.solverslib.drivebase.MecanumDrive;
8+
import com.seattlesolvers.solverslib.hardware.RevIMU;
9+
import com.seattlesolvers.solverslib.hardware.motors.Motor;
10+
11+
12+
public class DriveBase {
13+
HardwareMap hardwareMap;
14+
Motor frontLeft;
15+
Motor frontRight;
16+
Motor backLeft;
17+
Motor backRight;
18+
19+
public MecanumDrive mecanum;
20+
public RevIMU imu;
21+
22+
public DriveBase(HardwareMap hardwareMap) {
23+
this.hardwareMap = hardwareMap;
24+
this.mecanum = initDriveBase();
25+
this.imu = initIMU();
26+
}
27+
28+
public MecanumDrive initDriveBase() {
29+
DriveConstants constants = new DriveConstants();
30+
frontLeft = new Motor(hardwareMap, constants.frontLeftMotorName);
31+
frontRight = new Motor(hardwareMap, constants.frontRightMotorName);
32+
backLeft = new Motor(hardwareMap, constants.backLeftMotorName);
33+
backRight = new Motor(hardwareMap, constants.backRightMotorName);
34+
35+
mecanum = new MecanumDrive(frontLeft, frontRight, backLeft, backRight);
36+
return mecanum;
37+
}
38+
39+
public RevIMU initIMU() {
40+
RevIMU imu = new RevIMU(hardwareMap);
41+
imu.init();
42+
return imu;
43+
}
44+
}
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
package org.mrpsvt.capital_robotics.robot_core;
2+
import com.acmerobotics.dashboard.config.Config;
3+
4+
@Config
5+
public class DriveConstants {
6+
public static String ROBOT_CENTRIC = "robot_centric";
7+
public static String FIELD_CENTRIC = "field_centric";
8+
9+
public float strafeSpeed = 1.0f;
10+
public float forwardSpeed = 1.0f;
11+
public float turnSpeed = 1.0f;
12+
13+
public final String frontLeftMotorName = "fl";
14+
public final String frontRightMotorName = "fr";
15+
public final String backLeftMotorName = "bl";
16+
public final String backRightMotorName = "br";
17+
18+
public final String robotDriveMode = ROBOT_CENTRIC;
19+
}
Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
package org.mrpsvt.capital_robotics.teleop;
2+
3+
import com.qualcomm.robotcore.eventloop.opmode.OpMode;
4+
import com.qualcomm.robotcore.eventloop.opmode.TeleOp;
5+
import com.qualcomm.robotcore.hardware.IMU;
6+
import com.seattlesolvers.solverslib.drivebase.MecanumDrive;
7+
import com.seattlesolvers.solverslib.hardware.RevIMU;
8+
9+
import org.mrpsvt.capital_robotics.control.ControlMap;
10+
import org.mrpsvt.capital_robotics.robot_core.DriveBase;
11+
import org.mrpsvt.capital_robotics.robot_core.DriveConstants;
12+
13+
import java.util.Objects;
14+
15+
@TeleOp(name = "Default Opmode", group = "TeleOp")
16+
public class DefaultOpmode extends OpMode {
17+
private ControlMap controls;
18+
private MecanumDrive drive;
19+
private DriveConstants driveConstants;
20+
private RevIMU imu; // Assuming you have an IMU class for field-centric driving
21+
22+
@Override
23+
public void init() {
24+
DriveBase driveBase = new DriveBase(hardwareMap);
25+
controls = new ControlMap();
26+
drive = driveBase.mecanum;
27+
imu = driveBase.imu;
28+
driveConstants = new DriveConstants();
29+
}
30+
31+
@Override
32+
public void loop() {
33+
if (Objects.equals(driveConstants.robotDriveMode, DriveConstants.ROBOT_CENTRIC)) {
34+
drive.driveRobotCentric(
35+
controls.driver1.getLeftY() * driveConstants.forwardSpeed,
36+
controls.driver1.getLeftX() * driveConstants.strafeSpeed,
37+
controls.driver1.getRightX() * driveConstants.turnSpeed
38+
);
39+
} else if (Objects.equals(driveConstants.robotDriveMode, DriveConstants.FIELD_CENTRIC)) {
40+
drive.driveFieldCentric(
41+
controls.driver1.getLeftY() * driveConstants.forwardSpeed,
42+
controls.driver1.getLeftX() * driveConstants.strafeSpeed,
43+
controls.driver1.getRightX() * driveConstants.turnSpeed,
44+
imu.getRotation2d().getDegrees() // IMU heading would go here
45+
);
46+
}
47+
}
48+
}

renovate.json

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
{
2+
"$schema": "https://docs.renovatebot.com/renovate-schema.json",
3+
"extends": [
4+
"config:recommended"
5+
]
6+
}

0 commit comments

Comments
 (0)