-
-
Notifications
You must be signed in to change notification settings - Fork 7
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
[Feature] Improve drive base ability to make turns - drive_base.curve(), drive_base.drive() #1414
Comments
Thanks for the suggestions! Meanwhile one quick input:
See https://github.com/orgs/pybricks/discussions/1399 for a technique that lets you do this. You could essentially limit the |
Thank you, this is genius! Additionally this would add also a great end option for the drive_base: run/drive/curve until stalled.
As an example: |
Not sure I follow this, or why there would currently be a need to repeat the axle track at all? A curve with a 0 radius is the same as an in-place turn, no matter the axle track value. As a curiosity, if you occasionally want to drive with one wheel, how about
This one has always bothered me a bit 😄 We have it because people seem to expect it and for backwards compatibility, but it was intentionally not added to Drive Base. It also hasn't been added to the block language so far for the same reason. With time-based functions, some users intuitively assume that time x speed = distance. This isn't true since acceleration takes time. Looking at it the other way, Perhaps there is also a drive base method that does what people actually want. Something like |
When working with kids 10-13 it is a great simplification if we can address all aspects of the robot with a single object and can forget motor_left and motor_right once we abstracted and defined the drive_base. (moving into object oriented approach for them -- when the robot of two motors needs to perform a navigation action - it is always your robot_base object and nothing else)
I made a mistake to use axle_track/4 for this. Corrected that in the FR.
run_until_stalled is rather a safety fuse in several cases and at best is only an addition to another target such as time/distance/target angle -- see the updated FR above.
Yes, the point of gyro usage in that case is a very good point. I am not sure what makes the more sense though. |
Is your feature request related to a problem? Please describe.
Based on this year's FLL season experiences my team would suggest a few improvements on how the drivebase handles robot turns. This affects
drive()
andcurve()
methods.Describe the solution you'd like
Merging radius and turn_rate
I would suggest an few optional (or mutually exclusive) parameter to add a radius to the drive method.
Target condition angle, distance, time, stalled and reporting end criteria
Additionally would suggest extending / maybe even merging the functions with an optional distance #1157 parameter.
Probably for backwards compatibility it would be best to keep both functions with a same signature.
Additionally would suggest extending functions with an optional time parameter, to make drive_base similar to motor handling with
motor.run_time()
function. This is quite good in making an alignment to a model. (e.g. this FLL year we solve M07 Hologram Performer by curving and aligning to the model. Here we cannot use curve as the robot might get stuck and wait forever.)Additionally would suggest extending a stall detection parameter.
The end condition parameters should either be mutually exclusive or even better allow specifying multiple conditions that would each end/break the action.
This could extend the
.done()
to an enum returning how the movement ended instead of a boolean (function return value is MaybeAwaitable, therefore is not an option to use)Default axle_track
Additionally would default the radius (when used) to a measure that is connected with axle_track. Here I do not have a suggestion for a right signature, yet leave this here for commenting.
The current mm is not obvious for kids.
The current behavior is like:
turn()
)radius = 0
radius = drivebase_axle_track/2
Would suggest an alternative where these two options are easily accessible without the need of an external variable of repeating the axle_track value many times in the code. (DRY)
Possible solution would be an additional enum and loading radius with a composition of Number this enum types.
Room for a good discussion.
Merged signature, naming
This would leave both functions with the same signature.
Additionally to ease comprehension I would name the parameter groups accordingly.
drivebase.drive(speed: Number, turn_radius: Union[Number, Turn]=0, turn_rate: Number=0, to_angle: Number=0, to_distance: Number=0, to_time: Number=0, to_stalled: bool=False, then: Stop=Stop.HOLD, wait: bool=True)
Default zero results in moving straight.
Defaults mean no end condition.
Otherwise could yield to an error or be ignored
The above signature is a bit flawed as it includes many optional/and group set parameters and thus several aspects are not accessible with only positional arguments. Tuples would be an option, yet it is too complicated for kids. Room for a good discussion.
Describe alternatives you've considered
I have checked pervious FRs and currently we are using
robot_base.drive(); wait(); robot_base.stop()
for emulating therun_time()
behavior (e.g. #1191, #1157).My team currently does not use the
.drive(turn_rate)
as we cannot really translate theturn_rate
to any metrics on the mat.I would assume that stall detection would be an alternative option for the time parameter in alignments - team has not explored it yet.
Additional context
N/A
The text was updated successfully, but these errors were encountered: