Help with tracking and moving at the same time

We currently have a button that lets the robot track the cargo. however, while it’s tracking you cannot drive the robot. Is there a way for the robot to still drive while it’s tracking? We are in time base Java programing. Also, we are using a limelight.

OK, define “Track”. If by track you mean follow or chase down the cargo, no. If you mean keep tabs on its position, why not? It sounds like you need to factor your “visual tracking” away from your “drive tracking” so you can keep one going without affecting the other.
According to motors.vex.com, you can get up to 4.69 Nm, until you trip a breaker or melt something, which won’t take long. More reasonably, you can get about 1Nm by setting a current limit of 60A. Expect thermal shutdown in about 60 seconds.

Our likely solution is to let the rotation of the robot track cargo and the driver control motion forward/backward.

This is all setup so that when the driver holds a button they have tracking on and when released it is manual driving.

5 Likes

Our idea is pretty much this, it takes control of the swervedrive rotation but leaves translation to drivers.

4 Likes
    private double getRotationSpeed() {
    if (MathUtil.isWithinTolerance(Gyro.getInstance().getRotation2d().getDegrees(), driveTrain.getTargetRotationAngle(), 2.5)) {
        return 0.0;
    }
    double vel = (0.025 * (driveTrain.getTargetRotationAngle() - Gyro.getInstance().getRotation2d().getDegrees()));
    if (Math.abs(vel) < MIN_VEL) {
        vel = Math.signum(vel) * MIN_VEL;
    }
    return Math.signum(vel) * Math.min(Math.abs(vel), MAX_TURN_SPEED);
}

We’ve used this code with our swerve controls with a lot of success. We just keep a target rotation in drivetrain and any command can kinda just set it at will and our DT will angle towards wherever. This has the benefits that the driver can still drive and rotate the robot like they normally would

         var leftJoystick = ControlMap.DRIVER_LEFT;
    var rightJoystick = ControlMap.DRIVER_RIGHT;
    var xSpeed = MathUtil.fitDeadband(-leftJoystick.getY()) * DriveTrain.MAX_SPEED;
    var ySpeed = MathUtil.fitDeadband(-leftJoystick.getX()) * DriveTrain.MAX_SPEED;

    var rot = MathUtil.fitDeadband(rightJoystick.getX()) * DriveTrain.MAX_ANGULAR_SPEED;

    if (rot == 0) {
        driveTrain.drive(xSpeed, ySpeed, getRotationSpeed(), driveTrain.getFieldCentric());
    } else {
        driveTrain.setTargetRotationAngle(Gyro.getInstance().getRotation2d().getDegrees());
        driveTrain.drive(xSpeed, ySpeed, rot, driveTrain.getFieldCentric());
    }

When you are pressing the button that aligns your rotation, override rot with the output of a tuned PID which uses pixel x coordinate from your video system as input.

We tried a PID but it wasn’t working well so we just switched to this method of control. The reason we don’t override rot is because we prefer the driver keep their ability to turn if we are pinned or something. Our velocity controls on the robot do a good enough job at making this turning smooth

This topic was automatically closed 365 days after the last reply. New replies are no longer allowed.