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

More Motor Commands #203

Open
wants to merge 15 commits into
base: main
Choose a base branch
from
Open

More Motor Commands #203

wants to merge 15 commits into from

Conversation

carturn
Copy link
Contributor

@carturn carturn commented Apr 21, 2017

Adding some more motor commands after seeing some potential use cases.
Also trying to move to better constructors and double suppliers where possible (for more options in the future), thus adding the controller to double supplier adapter.

@carturn carturn requested a review from ajnadel April 21, 2017 19:58
@carturn carturn self-assigned this Apr 21, 2017
Copy link
Member

@billwpierce billwpierce left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is really cool. I'd like to test it on pinky or a robot beforehand, though for 2018-Code/ this seems helpful.

public MotorControl(Motor motor, Controller controller, int axis, double scale) {
super("MotorControl");
public MotorControl(String name, Motor motor, Supplier<Double> speedSupplier, double scale, double offset) {
super(name);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is pretty cool, however, we may run into compatibility problems with older versions. 10/10 would recommend for 2018-code, and maybe for 2017 if we take the time to do some refactoring.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Compatibility is something we rarely consider as we are not supporting a huge number of people on historical versions. If older software relies on something, a branch can be created to support it, or the older software can adapt.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ok my B.

* @param axis
* @param scale
*/
public MotorControl(Motor motor, Supplier<Double> speedSupplier, double scale) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What is the point of this? Where does the scale get factored in/used?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah -- it looks like scale is just stored on the instance, and then never used. IMO scale is irrelevant when using speedSupplier; it was used when reading directly from the joystick, but with DoubleSupplier the user could just add the scale factor in the supplier itself.

Nice catch.

@ajnadel
Copy link
Member

ajnadel commented Oct 21, 2017

This goes for the whole PR (and it's not critical), but there's a preexisting specialization of Supplier<Double>: DoubleSupplier. One subtle difference is that Supplier<Double> provides a Double whereas DoubleSupplier also has a method to return a double.

Copy link
Member

@ajnadel ajnadel left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can we remove scale from MotorControl?


@Override
protected void initialize() {
speed = speedSupply.get() * scale + offset;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

As @ajnadel mentioned, the scale is unnecessary if we can just adjust this in the supplier, no?

@billwpierce
Copy link
Member

@ajnadel Can we remove scale from MotorControl?
@ajnadel I did, although before we merge I have two ideas/questions:

  1. Should we use DoubleSupplier's instead? I'm happy to implement them, although I'd like to have a better understanding personally before we do.
  2. Should we include the offset into the ControllerDoubleSupplier?

@billwpierce
Copy link
Member

Also, like someone should make sure I didn't mess anything up.

@billwpierce billwpierce self-assigned this Oct 22, 2017
@billwpierce
Copy link
Member

I moved all of the scalings and offset into the supplier of the double, as that intuitively makes sense... we want the speed to be set in one location, not partially set in one location then finished being set and setting the motor to that speed in the other. That said if anyone knows of any places where this might cause compatibility issues, please double check before merging.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants