Slowing Down MonsterJoy.py

Hi;

I need to try and slow down the motors on the MonsterBorg e.g. when running MonsterJoy.py unless you remember to press L2 the initial take off torque and speed is way too much. This makes tricky manoeuvring a nightmare.
In MonsterAuto there is a separate setting script that allows changing the speed setting.

Is there a way to:

1. Slow down either the overall speed / the initial take off speed with having to remember to press a button?

2. Incorporate a speed % enabling testing to get the speed / take just right?

Thanks

piborg's picture

There are a few ways to slow the speed down in the monsterJoy.py script, below are probably the easiest to do.

Option 1: Reduce the motor power

You can reduce the maximum power to the motors for the entire script by adjusting this line:

voltageOut = 12.0 * 0.95        # Maximum motor voltage, we limit it to 95%...

As standard the code limits the motors to 95% to prevent the Pi from resetting under large speed changes. You can reduce the 0.95 to a smaller value to drop the speed further. For example this will run at 50% speed:

voltageOut = 12.0 * 0.50        # Maximum motor voltage, limited to 50%

When done this way the L2 button will still work, enabling an even slower speed control when held, but if it is too low the MonsterBorg might not move :)

The downside is that the script is now limited to moving slowly under all circumstances.

Option 2: Change L2 to speed up instead of slow down

We can swap the functionality of the L2 button so that it slows the MonsterBorg when released instead of when held. This has the advantage that it will default to moving slowly, but holding L2 will allow you to drive at full speed when you need it.

The change is actually quite simple, only one line needs to be changed. Start by looking for this part of the script:

                # Check for button presses
                if joystick.get_button(buttonSlow):
                    driveLeft *= slowFactor
                    driveRight *= slowFactor

All we need to do is add a not to the button check to make it work when not held instead:

                # check for button presses
                if not joystick.get_button(buttonslow):
                    driveleft *= slowfactor
                    driveright *= slowfactor
Subscribe to Comments for "Slowing Down MonsterJoy.py"