-
Notifications
You must be signed in to change notification settings - Fork 4.3k
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
Electric motor in a vehicle has much less power when the vehicle is going backwards #38165
Comments
It took a few tries, but I was able to reproduce the problem with an electric car, after replacing the regular electric motor with a "small electric motor", and adding a bunch of heavy frames and armor until the vehicle weighed over 5300 lbs. (Thanks to the Debug Hammer-space mutation!) Now, I can accelerate forward (very slowly), but cannot move at all in reverse. Glancing at the code, I see these lines in Cataclysm-DDA/src/vehicle_move.cpp Lines 247 to 248 in 05940bf
Whether a vehicle uses a gearbox or not, I should think if forward movement is possible, then reverse movement should also be possible, even if it's slower. I will try a fix and submit a PR. The corresponding math when you have cruise control turned off is a little different: Cataclysm-DDA/src/vehicle_move.cpp Lines 151 to 152 in 05940bf
Here it's at least using floating-point math, but in my testing I found that weight was even more of a problem with cruise control off. For example:
Edit Now I'm not sure I can trust these numbers, because I just loaded up the same car past 4500 lbs, and it can still drive with the small electric motor. Until I parked it on pavement and tried to drive it again - then I got "The Electric Car is too heavy for its engine(s)!" - I wonder if there's a similar vehicle weight calculation bug to what I observed in #38177 , where a STR 5 character was able to pull 200 kg of bricks in an unwheeled shopping cart. |
That is not correct, if reverse has less torque than 1st gear, it can absolutely stall the vehicle. I agree it should not be applied for electric motors. |
In almost all real gearboxes 1st gear and reverse are made almost equal, as far as i know. |
This is kind of what I was assuming too, at least from a gameplay perspective. It looks like gearboxes are not modeled at all in the current vehicle system; electric-power, pedal-power, animal-power, and diesel-power all have their reverse acceleration nerfed by the same amount. This crudely simulates the fact that real-world gearboxes only have a single reverse gear, while typically having multiple forward gears. I guess it would be harder to pedal a bicycle in reverse without a lot of practice, but I don't see any mechanical reason pedals should be slower or have less torque in reverse. I've never ridden a unicycle, but they would seem ideally symmetrical, the seat being directly over the pedals. Horses, I would have to do some more research but it's probably safe to assume they won't win any races running backwards. My thinking for now is to simply check whether the vehicle has any battery-powered engines active, and avoid the power-reduction if so. Full gearbox implementation I think will have to wait. |
As a side note, i wonder if modern car gasoline engines could actually rotate in reverse if the firmware understood such a mode of operation, or the valves are still operated mechanically by the engine shaft? |
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 CleverRaven#38165
* 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.
Describe the bug
Steps To Reproduce
Install an electric motor on a heavy vehicle and find out it is not powerful enough to move backwards at all.
Expected behavior
It should be the same, since electric motors don't care about the direction of the rotation.
Screenshots
Versions and configuration
Dark Days Ahead [dda],
Disable NPC Needs [no_npc_food],
Alternative Map Key [alt_map_key],
Modular Turrets [modular_turrets],
Salvaged Robots [Salvaged_Robots]
]
Additional context
The text was updated successfully, but these errors were encountered: