

With the separate overloads, you’d always have to check the function definition to see what you’re passing or memorize the argument order (intellisense addresses that problem, but history has shown I can’t trust VS Code’s intellisense).
#Wpilib screensteps autonomous chooser code#
It’s cleaner from a library development point of view because we don’t have to specify a bunch of different overloads, and it’s more readable from a user point of view because you can clearly see which options you’re setting in code (each option has a setter). The second design option is the config object: Neither C++ nor Java support that though. With the optional arguments specified in any order. So the user can do, for example: generate_trajectory(, 2, 1, start_velocity=1) def generate_trajectory(waypoints: List, max_velocity: float, max_acceleration: float, **kwargs): In Python, you could solve this combinatorial issue with positional arguments and keyword arguments. When the arguments aren’t specified, the start and end velocities are zero, the trajectory isn’t reversed, and the list of constraints is empty by default.

Units::meters_per_second_t startVelocity, Units::meters_per_second_squared_t maxAcceleration, Units::meters_per_second_squared_t maxAcceleration) The first design option was to list all the arguments in overloads of GenerateTrajectory(), which looks like: Trajectory GenerateTrajectory( It had an arbitrary list of constraints.It had three optional parameters: start velocity, end velocity, and reversed.These are used to generate a spline, and generate a trapezoid profile for the velocity along that spline. It had three required parameters: waypoints, max velocity, and max acceleration.The trajectory generation API had the following requirements: I’m not a fan of it either, but it was the best option at the time to manage a large amount of optional arguments.
