-
Notifications
You must be signed in to change notification settings - Fork 4.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Make electric motors go in reverse better (#38212)
* Make electric motors go in reverse better Due to the downscaling of reverse power/speed for vehicle engines, it can happen that a vehicle is so heavy, it can move forward but not backward. Because battery-powered electric motors can turn in either direction with equal speed and torque, vehicles with electric motors should be exempt from the power-reduction for reverse speeds. This commit adds a new `vehicle::max_reverse_velocity` function as the counterpart to `vehicle::max_velocity`, where an exception is made for battery-powered motors. Here I suppose is where the maximum reverse speed multiplier for horses, bicycles, and jet turbines would eventually be made; for now it just checks for battery-powered motors. Note, how *much* the motor is contributing to overall torque is not calculated; the simple presence of any electric motor in the drivetrain (no matter how small) ought to negate the reverse-power penalty. Fixed #38165 * Refactor vehicle_power_test.cpp for readability This is mainly preliminary work for adding new test cases to cover the changes I have made to maximum reverse speed; this vehicle power test seemed like a suitable place to put them. I had trouble understanding what this test was doing; refactoring it into BDD-style expressions helped me grok it while making it a whole lot easier for others to read in the future. * Add vehicle reverse velocity tests To minimally test the new `max_reverse_velocity` function, this commit adds two test vehicles (scooter and electric scooter), and checks that: - Combustion engine reverse velocity is 1/4 of forward - Electric engine reverse velocity is equivalent to forward Some additional refactoring of the helper functions is also done.
- Loading branch information
Showing
5 changed files
with
223 additions
and
64 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters