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

Add the array overload to PROS 3 #450

Closed
Richard-Stump opened this issue Oct 20, 2022 · 1 comment
Closed

Add the array overload to PROS 3 #450

Richard-Stump opened this issue Oct 20, 2022 · 1 comment
Assignees

Comments

@Richard-Stump
Copy link
Contributor

Richard-Stump commented Oct 20, 2022

This is a feature we would like to implement in PROS4; however, MotorGroups have yet to be added to Pros 4, so they cannot be implemented to Pros 4. Since this feature is a small one that could be very useful for MotorGroups, it can be implemented into Pros 3 and easily ported into Pros 4. This would be fine to do since it is a small quality of life improvement, and we have #449 to push out when we get that fixed.

The gist of this feature is that if the user has a MotorGroup, they should be able to treat it like an array of motors:

pros::MotorGroup group({12, 13, -2, 3});

pros::Motor& motorA = group[3]; // motorA now references the last motor in the group.
pros::Motor& motorB = group[0]; // motorB mow references the first motor in the group.

The index passed should simply index into the list of motors that the motor groups.

Additionally, MotorGroups should have a method, size() which returns the number of motors in the group.

These features would allow for easy iteration over a motor group with a standard for loop, and without having to use many vectors for each of the properties needed.

for(int i = 0; i < group.size(); i++) {
      group[i].set_reversed(true);
      group[i].set_velocity(12);
}

This is redundant to be used like this, but this could maybe be used in more useful ways.

@noam987 noam987 changed the title PROS 4: Add the array overload to PROS 3 Add the array overload to PROS 3 Jan 16, 2023
@noam987
Copy link
Contributor

noam987 commented Jan 16, 2023

closed in #463

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

No branches or pull requests

3 participants