Cataclysm-dda: Electric motor in a vehicle has much less power when the vehicle is going backwards

Created on 19 Feb 2020  路  5Comments  路  Source: CleverRaven/Cataclysm-DDA

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

  • OS: Linux

    • OS Version:

  • Game Version: 0.D-12404-g1d23fcce1e-dirty [64-bit]
  • Graphics Version: Curses
  • Mods loaded: [
    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

<Bug> Vehicles

Most helpful comment

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.

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.

All 5 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.

image

Glancing at the code, I see these lines in src/vehicle_move.cpp that appear to calculate the maximum reverse velocity as 1/4 of the forward velocity when cruise control is on. And, because it's doing integer division, I guess if forward velocity is any less than 3, reverse will bottom out to 0.

https://github.com/CleverRaven/Cataclysm-DDA/blob/05940bfe3aa1c95c10dc2df49bb2b7a88f23b039/src/vehicle_move.cpp#L247-L248

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:

https://github.com/CleverRaven/Cataclysm-DDA/blob/05940bfe3aa1c95c10dc2df49bb2b7a88f23b039/src/vehicle_move.cpp#L151-L152

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:

  • 4224 lbs, cruise control on: can go forward, not reverse
  • 4224 lbs, cruise control off: cannot move
  • 3800 lbs, cruise control off: can go forward, not reverse
  • 3700 lbs, cruise control off: can go forward and reverse

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.

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.

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.

if reverse has less torque than 1st gear, it can absolutely stall the vehicle.

In almost all real gearboxes 1st gear and reverse are made almost equal, as far as i know.

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?

Was this page helpful?
0 / 5 - 0 ratings