Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Automatic transmission
11-05-2006, 10:58 AM,
#1
Automatic transmission
I've tried to implement automatic transmission. Nothing fancy, just by checking the engine speed, and shift up when greater than peak engine speed, shift down when less than a fixed value (using 200 rad/s now).

I'd like to add an option for user to select whether to use manual or automatic transmission. My question is, should we use a combined setting for autoclutch/auto transmission, or do you prefer to separate these 2 settings?
Reply
11-05-2006, 02:20 PM,
#2
 
Please separate these options. Autoclutch is meant to drop the clutch in whenever the RPMs start getting too low and the engine may stall. Many people will still want to use this option, I think, with a manual transmission.
Reply
11-05-2006, 06:51 PM,
#3
 
Yep. I certainly like the auto-clutch, since sometimes I have a hard time hearing the revs when I'm playing.
Reply
11-05-2006, 06:51 PM,
#4
 
I agree, make the two option separate. Auto-clutch and Auto-gearbox, or something like that.
Reply
11-05-2006, 07:19 PM,
#5
 
x2 on keeping auto-clutch and auto-trans separate.
Reply
11-05-2006, 08:50 PM,
#6
 
Ok. I'll create a new option for auto transmission. Will submit a patch once I'm done.
Reply
11-05-2006, 09:19 PM,
#7
 
Sounds great. If you need some help drop by IRC.
Reply
11-05-2006, 11:03 PM,
#8
 
What is the procedure for submitting patch? I don't have a website to upload. Do you mind if I include the patch in this post directly? Thought I'd better ask first. Smile
Reply
11-05-2006, 11:27 PM,
#9
 
No problem, just use the [code] tags to preserve your formatting, and you might also want to disable smilies and html just in case.
Reply
11-06-2006, 12:17 AM,
#10
 
Here is the patch

Code:
Index: include/vamosworld.h
===================================================================
--- include/vamosworld.h    (revision 1323)
+++ include/vamosworld.h    (working copy)
@@ -109,6 +109,7 @@
    bool camneedupdate;
    bool MPH;
    bool auto_clutch;
+    bool auto_trans;
    bool display_hud;
    bool input_graph_enabled;
    bool car_shadows_enabled;
Index: src/vamosworld.cc
===================================================================
--- src/vamosworld.cc    (revision 1323)
+++ src/vamosworld.cc    (working copy)
@@ -1432,6 +1432,36 @@
            DoOp(GetCar(CONT_PLAYERLOCAL), "clutch", autoclutch, 0.0, true, timefactor, fps);
        }
    }
+
+    // Automatic Transmission
+    if (auto_trans)
+    {
+        // only autoshift when no shift pending and we are not in neutral or reverse gear
+        if (!GetCar(CONT_PLAYERLOCAL)->car->ShiftPending() &&
+            GetCar(CONT_PLAYERLOCAL)->car->gear() > 0)
+        {
+            // shift up when engine speed exceeds peak speed
+            if (GetCar(CONT_PLAYERLOCAL)->car->engine()->rotational_speed() >
+                GetCar(CONT_PLAYERLOCAL)->car->engine()->peak_engine_speed()
+                           &&
+                GetCar(CONT_PLAYERLOCAL)->car->engine()->last_rotational_speed() <GetCar>car->engine()->peak_engine_speed())
+            {
+                GetCar(CONT_PLAYERLOCAL)->car->shift_up();
+            }
+
+            // shift down when engine speed below fixed value
+            // however, we do not auto shift down from 1st gear to neutral
+            if (GetCar(CONT_PLAYERLOCAL)->car->gear() > 1
+               &&
+                GetCar(CONT_PLAYERLOCAL)->car->engine()->rotational_speed() <200>car->engine()->last_rotational_speed() > 200.0)
+            {
+                GetCar(CONT_PLAYERLOCAL)->car->shift_down();
+            }
+        }
+    }
}

void VAMOSWORLD::DoOp(Vamos_World::Car_Information * c, string dofunction, float dovalue, float dotime, bool held, float timefactor, float fps)
@@ -2096,6 +2126,7 @@
    settings.Get( "display.show_hud", display_hud );
    settings.Get( "display.mph", MPH );
    settings.Get( "control.autoclutch", auto_clutch );
+    settings.Get( "control.autotrans", auto_trans );
    settings.Get( "display.input_graph", input_graph_enabled );
    settings.Get( "display.car_shadows", car_shadows_enabled );
    settings.Get( "control.button_ramp", button_ramp );
Index: data/settings/options.config
===================================================================
--- data/settings/options.config    (revision 1323)
+++ data/settings/options.config    (working copy)
@@ -1,4 +1,4 @@
-num_options = 41
+num_options = 42

[ option-00 ]
cat = game
@@ -520,3 +520,14 @@
default = 1
values = replays

+[ option-41 ]
+cat = control
+name = autotrans
+title = AutoTransmission
+desc = Enable/disable automatic transmission
+type = bool
+default = true
+values = bool
+true = On
+false = Off
+
Index: data/skins/simple/menus/ControlsOptions
===================================================================
--- data/skins/simple/menus/ControlsOptions    (revision 1323)
+++ data/skins/simple/menus/ControlsOptions    (working copy)
@@ -1,5 +1,5 @@
name = ControlsOptions
-widgets = 11
+widgets = 12
background = box.png
dialog = false

@@ -21,7 +21,7 @@
name = TouchCompWheel
setting = joystick.touchcomp
values = options
-center = 0.5, 0.29
+center = 0.5, 0.25
width = auto
height = auto
fontsize = 6
@@ -32,6 +32,20 @@

[ widget-02 ]
type = toggle
+name = AutoTransToggle
+setting = control.autotrans
+values = options
+center = 0.5, 0.29
+width = auto
+height = auto
+fontsize = 6
+enabled = 1
+selected = 0
+default = 0
+cancel = 0
+
+[ widget-03 ]
+type = toggle
name = AutoClutchToggle
setting = control.autoclutch
values = options
@@ -44,7 +58,7 @@
default = 0
cancel = 0

-[ widget-03 ]
+[ widget-04 ]
type = toggle
name = ABSToggle
setting = game.antilock
@@ -58,7 +72,7 @@
default = 0
cancel = 0

-[ widget-04 ]
+[ widget-05 ]
type = toggle
name = TCSToggle
setting = game.traction_control
@@ -72,7 +86,7 @@
default = 0
cancel = 0

-[ widget-05 ]
+[ widget-06 ]
type = floatwheel
name = ButtonRampWheel
setting = control.button_ramp
@@ -86,7 +100,7 @@
default = 0
cancel = 0

-[ widget-06 ]
+[ widget-07 ]
type = button
name = ActionControlMapButton
text = Assign Controls
@@ -102,7 +116,7 @@
default = 0
cancel = 0

-[ widget-07 ]
+[ widget-08 ]
type = button
name = JoystickOptionsButton
text = Joystick Options
@@ -118,7 +132,7 @@
default = 0
cancel = 0

-[ widget-08 ]
+[ widget-09 ]
type = button
name = MouseOptionsButton
text = Mouse Options
@@ -134,7 +148,7 @@
default = 0
cancel = 0

-[ widget-09 ]
+[ widget-10 ]
type = button
name = ControlsOptionsOKButton
text = OK
@@ -150,7 +164,7 @@
default = 1
cancel = 0

-[ widget-10 ]
+[ widget-11 ]
type = button
name = ControlsOptionsCancelButton
text = Cancel
Index: data/skins/simple/menus/InGameControlsOptions
===================================================================
--- data/skins/simple/menus/InGameControlsOptions    (revision 1323)
+++ data/skins/simple/menus/InGameControlsOptions    (working copy)
@@ -1,5 +1,5 @@
name = InGameControlsOptions
-widgets = 11
+widgets = 12
background = box.png
dialog = false

@@ -21,7 +21,7 @@
name = InGameTouchCompWheel
setting = joystick.touchcomp
values = options
-center = 0.5, 0.29
+center = 0.5, 0.25
width = auto
height = auto
fontsize = 6
@@ -32,6 +32,20 @@

[ widget-02 ]
type = toggle
+name = InGameAutoTransToggle
+setting = control.autotrans
+values = options
+center = 0.5, 0.29
+width = auto
+height = auto
+fontsize = 6
+enabled = 1
+selected = 0
+default = 0
+cancel = 0
+
+[ widget-03 ]
+type = toggle
name = InGameAutoClutchToggle
setting = control.autoclutch
values = options
@@ -44,7 +58,7 @@
default = 0
cancel = 0

-[ widget-03 ]
+[ widget-04 ]
type = toggle
name = InGameABSToggle
setting = game.antilock
@@ -58,7 +72,7 @@
default = 0
cancel = 0

-[ widget-04 ]
+[ widget-05 ]
type = toggle
name = InGameTCSToggle
setting = game.traction_control
@@ -72,7 +86,7 @@
default = 0
cancel = 0

-[ widget-05 ]
+[ widget-06 ]
type = floatwheel
name = InGameButtonRampWheel
setting = control.button_ramp
@@ -86,7 +100,7 @@
default = 0
cancel = 0

-[ widget-06 ]
+[ widget-07 ]
type = button
name = InGameActionControlMapButton
text = Assign Controls
@@ -102,7 +116,7 @@
default = 0
cancel = 0

-[ widget-07 ]
+[ widget-08 ]
type = button
name = InGameJoystickOptionsButton
text = Joystick Options
@@ -118,7 +132,7 @@
default = 0
cancel = 0

-[ widget-08 ]
+[ widget-09 ]
type = button
name = InGameMouseOptionsButton
text = Mouse Options
@@ -134,7 +148,7 @@
default = 0
cancel = 0

-[ widget-09 ]
+[ widget-10 ]
type = button
name = InGameControlsOptionsOKButton
text = OK
@@ -150,7 +164,7 @@
default = 1
cancel = 0

-[ widget-10 ]
+[ widget-11 ]
type = button
name = InGameControlsOptionsCancelButton
text = Cancel
Reply
11-06-2006, 12:54 AM,
#11
 
Your patch is pretty good, you did a good job of adding the menu entry and that kind of thing. However after applying your patch I have turned on this feature and tried it with a few cars, but it doesn't seem to do anything for me. Which cars are you testing with? I see that your shift is based on peak engine rpm, are you sure all cars have a proper peak engine rpm set?
Reply
11-06-2006, 01:03 AM,
#12
 
That's strange. I've tested using 3S, CS, XS. And it's working fine.

Do you expect an autoshift from neutral to 1st gear? Base on real world car, I've decided that shifting from neutral to 1st gear should be manual. So you have to manually shift to 1st gear before auto shifting will kick in.
Reply
11-06-2006, 01:29 AM,
#13
 
OK, I see the problem. The patch was a little mangled, in fact it looks like "svn diff" is not the best thing to run through patch...so I applied this patch manually and forgot a section. I fixed it and it seems to work now. A few things:
  • It doesn't do any clutching when shifting gears. Notice how the RPM jumps when shifting is done. This immediate shift is unrealistic so when auto shifting, it should do some clutching sort of like the autoclutch to simulate a more realistic shift.
  • Shifting is still allowed with the manual shift buttons, maybe they should be disallowed over 1st gear.
  • When slowing down (braking) the car doesn't shift down when it should. It should shift down when RPM reaches maybe 2/3 of the peak engine RPM? Just a guess...might be something worth playing with, as the right value will be different for different cars.
For now I'm going to check this in and let others see and comment on it. Thanks for the patch! Smile
Reply
11-06-2006, 02:07 AM,
#14
 
Looking forward to other's comments. Smile

Regarding your observation on shift down, it's because i just hardcoded 200 rad/s (around 2000RPM) as the shift down threshold. We certainly need a better algorithm for this.

On the patching probelm, what is the issue that you have to do it manually? I've done a 'patch -p0 < vdrift.diff' against a prestine svn copy. The patch applied cleanly.
Reply
11-06-2006, 02:27 AM,
#15
 
I'm not sure what the deal with the patch is, I copied it out exactly as it was, and every single part of it failed, even though I tried to apply it with the same command you did. It worked in the end, so oh well...

It goes without saying that if you keep sending many patches I will just give you SVN access Smile
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)