Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Lots of minor API Updates/cleanup #35

Closed
wants to merge 34 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
34 commits
Select commit Hold shift + click to select a range
0728f56
Cleaning up logging so things function with the dashboard
kevinfrei Nov 19, 2023
6a7b365
Ripped out the NumberBar and NumberSlider lines. Colors are next.
kevinfrei Nov 19, 2023
9bba9bc
Removed the color support from the logging stuff
kevinfrei Nov 19, 2023
7d9b05e
Minor cleaning up
kevinfrei Nov 19, 2023
57ae0d7
Updated the docs link. I should also update github.io...
kevinfrei Nov 19, 2023
5d778db
Updated prettier, formatted stuff
kevinfrei Nov 19, 2023
060c148
Undeprecated some stuff (for now) added Motor.setDir/setFwd/setBack, …
kevinfrei Oct 5, 2023
bf14740
Removed some deprecated stuff
kevinfrei Oct 5, 2023
aa5a228
Steps toward a simplified vision pipeline
kevinfrei Oct 6, 2023
7986261
Finished spelling fix for propogate->propagate
kevinfrei Oct 14, 2023
75466e9
Not yet used, but the PowerPlay branch is building with everything else
kevinfrei Oct 14, 2023
7d16862
Okay, more than just Vision improvements. [move to new branch]
kevinfrei Oct 14, 2023
b38a93e
Added consumer/biconsumer versions of CommandSchedule.schedule* funct…
kevinfrei Oct 14, 2023
90c051e
Updated tests
kevinfrei Oct 14, 2023
20af31d
Added some comments and examples, plus non-controlling commands
kevinfrei Oct 14, 2023
0430a59
Added method-ref based command stuff for controls
kevinfrei Oct 14, 2023
2f016de
Syntactic helpers for auto paths
kevinfrei Oct 15, 2023
0634a1c
Source Formatting
kevinfrei Oct 15, 2023
5a50d0e
Added a little bit to the Vision stuff as I'm porting PowerPlay
kevinfrei Oct 15, 2023
4181cc7
Moved detectionStart before numRectangles
kevinfrei Oct 15, 2023
3bb5a9b
Some doc updates. I should go dig up how to deploy stuff to github.io…
kevinfrei Oct 16, 2023
848fe6a
Added some @Deprecated tags in the IMU class, formatted code
kevinfrei Oct 17, 2023
09b6e30
Wrote up a little bit about simulation, to get it written down somewhere
kevinfrei Oct 19, 2023
d528e61
Removed a bunch of overloads to simplify the API's
kevinfrei Oct 20, 2023
fe0a89b
Added an extra constructor for SimpleCommand
kevinfrei Oct 20, 2023
c4edc95
Removed a bunch of overloads to simplify the CommandScheduler API, too
kevinfrei Oct 20, 2023
4d09f6d
Deprecated the Paramater*Command classes, and made SimpleRequiredComm…
kevinfrei Oct 20, 2023
745313e
Added comments
kevinfrei Oct 21, 2023
cf64d26
Deprecated the {Device}Subsystem classes, added TwoDeadWheelLocalizer
kevinfrei Oct 22, 2023
8ffdfa6
Finished cleaning up the *Group types
kevinfrei Oct 22, 2023
f2bb589
Modified propagate to take (effectively) a method ref to run
kevinfrei Oct 22, 2023
e0314bd
Added some stuff to readme
kevinfrei Nov 3, 2023
d28c873
Added (NYI) CRServo and MotorAsServo hardware devices
kevinfrei Nov 26, 2023
99b2b55
A few more updates, cleaned up getting the motor
kevinfrei Nov 26, 2023
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -123,10 +123,10 @@ public PathingMecanumDrivebaseSubsystem(
c.getDouble(WheelBase.class),
c.getDouble(LateralMult.class)
);
leftFront = fl.getDevice();
leftRear = rl.getDevice();
rightRear = rr.getDevice();
rightFront = fr.getDevice();
leftFront = fl.getRawMotor(DcMotorEx.class);
leftRear = rl.getRawMotor(DcMotorEx.class);
rightRear = rr.getRawMotor(DcMotorEx.class);
rightFront = fr.getRawMotor(DcMotorEx.class);

motors = Arrays.asList(leftFront, leftRear, rightRear, rightFront);

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,104 @@
package com.technototes.path.subsystem;

import static com.technototes.path.subsystem.DeadWheelConstants.EncoderOverflow;
import static com.technototes.path.subsystem.DeadWheelConstants.ForwardOffset;
import static com.technototes.path.subsystem.DeadWheelConstants.GearRatio;
import static com.technototes.path.subsystem.DeadWheelConstants.LateralDistance;
import static com.technototes.path.subsystem.DeadWheelConstants.TicksPerRev;
import static com.technototes.path.subsystem.DeadWheelConstants.WheelRadius;

import androidx.annotation.NonNull;
import com.acmerobotics.roadrunner.geometry.Pose2d;
import com.acmerobotics.roadrunner.localization.ThreeTrackingWheelLocalizer;
import com.acmerobotics.roadrunner.localization.TwoTrackingWheelLocalizer;
import com.technototes.library.hardware.sensor.IMU;
import com.technototes.library.hardware.sensor.encoder.MotorEncoder;
import com.technototes.library.subsystem.Subsystem;
import java.util.Arrays;
import java.util.List;
import java.util.function.DoubleSupplier;

/*
* Sample tracking wheel localizer implementation assuming a standard configuration:
*
* /---------------\
* | ____ |
* | ---- |
* | || ^ |
* | ||<- lr | |
* | fb |
* | |
* \---------------/
*
* COMPLETELY UNTESTED!!
*/
public class TwoDeadWheelLocalizer extends TwoTrackingWheelLocalizer implements Subsystem {

protected MotorEncoder leftrightEncoder, frontbackEncoder;
protected DoubleSupplier headingSupplier;
protected double lateralDistance, forwardOffset, gearRatio, wheelRadius, ticksPerRev;

protected boolean encoderOverflow;

public TwoDeadWheelLocalizer(IMU imu, MotorEncoder lr, MotorEncoder fb, DeadWheelConstants constants) {
super(
Arrays.asList(
new Pose2d(0, constants.getDouble(LateralDistance.class), 0), // left
new Pose2d(constants.getDouble(ForwardOffset.class), 0, Math.toRadians(90)) // front
)
);
leftrightEncoder = lr;
frontbackEncoder = fb;
headingSupplier = () -> imu.gyroHeading();

lateralDistance = constants.getDouble(LateralDistance.class);
forwardOffset = constants.getDouble(ForwardOffset.class);
encoderOverflow = constants.getBoolean(EncoderOverflow.class);
gearRatio = constants.getDouble(GearRatio.class);
ticksPerRev = constants.getDouble(TicksPerRev.class);
wheelRadius = constants.getDouble(WheelRadius.class);
}

public double encoderTicksToInches(double ticks) {
return ((getWheelRadius() * 2 * Math.PI * getGearRatio() * ticks) / getTicksPerRev());
}

@NonNull
@Override
public List<Double> getWheelPositions() {
return Arrays.asList(
encoderTicksToInches(leftrightEncoder.getCurrentPosition()),
encoderTicksToInches(frontbackEncoder.getCurrentPosition())
);
}

@NonNull
@Override
public List<Double> getWheelVelocities() {
// TODO: If your encoder velocity can exceed 32767 counts / second (such as the REV Through Bore and other
// competing magnetic encoders), change Encoder.getRawVelocity() to Encoder.getCorrectedVelocity() to enable a
// compensation method

return Arrays.asList(
encoderTicksToInches(leftrightEncoder.getCorrectedVelocity()),
encoderTicksToInches(frontbackEncoder.getCorrectedVelocity())
);
}

public double getTicksPerRev() {
return ticksPerRev;
}

public double getWheelRadius() {
return wheelRadius;
}

public double getGearRatio() {
return gearRatio;
}

@Override
public double getHeading() {
return headingSupplier.getAsDouble();
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,176 @@
package com.technototes.path.trajectorysequence;

import com.acmerobotics.roadrunner.geometry.Pose2d;
import com.technototes.path.geometry.ConfigurablePose;
import com.technototes.path.geometry.ConfigurablePoseD;
import java.util.function.Function;

public interface TrajectoryPath extends Function<Function<Pose2d, TrajectorySequenceBuilder>, TrajectorySequence> {
/**
* Create a spline between two poses
*
* @param start The beginning of a spline
* @param end The end of a spline
* @return A function that takes a 'start' location and returns a TrajectorySequenceBuilder
*/
static TrajectoryPath splineTo(ConfigurablePose start, ConfigurablePose end) {
return b -> b.apply(start.toPose()).splineTo(end.toVec(), end.getHeading()).build();
}

/**
* Create a spline between two poses
*
* @param start The beginning of a spline
* @param end The end of a spline
* @return A function that takes a 'start' location and returns a TrajectorySequenceBuilder
*/
static TrajectoryPath splineTo(ConfigurablePoseD start, ConfigurablePoseD end) {
return b -> b.apply(start.toPose()).splineTo(end.toVec(), end.getHeading()).build();
}

/**
* Create a spline between a list of poses
*
* @param start The beginning of a spline
* @param points The remaing points of the spline
* @return A function that takes a 'start' location and returns a TrajectorySequenceBuilder
*/
static TrajectoryPath splinesTo(ConfigurablePoseD start, ConfigurablePoseD... points) {
return b -> {
TrajectorySequenceBuilder bld = b.apply(start.toPose());
for (ConfigurablePoseD d : points) {
bld = bld.splineTo(d.toVec(), d.getHeading());
}
return bld.build();
};
}

/**
* Create a spline between a list of poses
*
* @param start The beginning of a spline
* @param points The remaing points of the spline
* @return A function that takes a 'start' location and returns a TrajectorySequenceBuilder
*/
static TrajectoryPath splinesTo(ConfigurablePose start, ConfigurablePose... points) {
return b -> {
TrajectorySequenceBuilder bld = b.apply(start.toPose());
for (ConfigurablePose d : points) {
bld = bld.splineTo(d.toVec(), d.getHeading());
}
return bld.build();
};
}

/**
* Create a line between two poses
*
* @param start The beginning of the line
* @param end The end of the line
* @return A function that takes a 'start' location and returns a TrajectorySequenceBuilder
*/
static TrajectoryPath lineTo(ConfigurablePose start, ConfigurablePose end) {
return b -> b.apply(start.toPose()).lineTo(end.toPose().vec()).build();
}

/**
* Create a line between two poses
*
* @param start The beginning of the line
* @param end The end of the line
* @return A function that takes a 'start' location and returns a TrajectorySequenceBuilder
*/
static TrajectoryPath lineTo(ConfigurablePoseD start, ConfigurablePoseD end) {
return b -> b.apply(start.toPose()).lineTo(end.toPose().vec()).build();
}

/**
* Create a line between a list of poses
*
* @param start The beginning of the line
* @param points The points of the line
* @return A function that takes a 'start' location and returns a TrajectorySequenceBuilder
*/
static TrajectoryPath linesTo(ConfigurablePoseD start, ConfigurablePoseD... points) {
return b -> {
TrajectorySequenceBuilder bld = b.apply(start.toPose());
for (ConfigurablePoseD d : points) {
bld = bld.lineTo(d.toPose().vec());
}
return bld.build();
};
}

/**
* Create a line between a list of poses
*
* @param start The beginning of the line
* @param points The points of the line
* @return A function that takes a 'start' location and returns a TrajectorySequenceBuilder
*/
static TrajectoryPath linesTo(ConfigurablePose start, ConfigurablePose... points) {
return b -> {
TrajectorySequenceBuilder bld = b.apply(start.toPose());
for (ConfigurablePose d : points) {
bld = bld.lineTo(d.toPose().vec());
}
return bld.build();
};
}

/**
* Create a line between two poses on a specific linear heading
*
* @param start The beginning of the line
* @param end The end of the line
* @return A function that takes a 'start' location and returns a TrajectorySequenceBuilder
*/
static TrajectoryPath lineToLinearHeading(ConfigurablePose start, ConfigurablePose end) {
return b -> b.apply(start.toPose()).lineToLinearHeading(end.toPose()).build();
}

/**
* Create a line between two poses on a specific linear heading
*
* @param start The beginning of the line
* @param end The end of the line
* @return A function that takes a 'start' location and returns a TrajectorySequenceBuilder
*/
static TrajectoryPath lineToLinearHeading(ConfigurablePoseD start, ConfigurablePoseD end) {
return b -> b.apply(start.toPose()).lineToLinearHeading(end.toPose()).build();
}

/**
* Create a set of lines between a list of poses on a specific linear heading
*
* @param start The beginning of the line
* @param points The list of points in the line
* @return A function that takes a 'start' location and returns a TrajectorySequenceBuilder
*/
static TrajectoryPath linesToLinearHeadings(ConfigurablePoseD start, ConfigurablePoseD... points) {
return b -> {
TrajectorySequenceBuilder bld = b.apply(start.toPose());
for (ConfigurablePoseD d : points) {
bld = bld.lineToLinearHeading(d.toPose());
}
return bld.build();
};
}

/**
* Create a set of lines between a list of poses on a specific linear heading
*
* @param start The beginning of the line
* @param points The list of points in the line
* @return A function that takes a 'start' location and returns a TrajectorySequenceBuilder
*/
static TrajectoryPath linesToLinearHeadings(ConfigurablePose start, ConfigurablePose... points) {
return b -> {
TrajectorySequenceBuilder bld = b.apply(start.toPose());
for (ConfigurablePose d : points) {
bld = bld.lineToLinearHeading(d.toPose());
}
return bld.build();
};
}
}

This file was deleted.

Loading
Loading