Open laurensvalk opened 1 year ago
"Short" conclusions about controller rumble actions.
To diminish typing I use this variables to indicate the actuators:
# Left handle, right handle, left trigger, right trigger
ACT0 = [100, 0, 0, 0] # Left handle
ACT1 = [0, 100, 0, 0] # right handle
ACT2 = [0, 0, 100, 0] # left trigger
ACT3 = [0, 0, 0, 100] # right trigger
If there are more than one xbox.rumble(blabla) commands: the actator(s) start turning after the last rumble command.
Rumble commands update the settings if the list of actuator percentages are equal. Example: This will make left trigger actuator turn 3 times for 50ms with delay 50ms
controller.rumble(ACT2, 10, 100, 5)
controller.rumble(ACT2, 50, 50, 3)
controller.rumble(ACT0, 80, 100, 10000)
controller.rumble(ACT1, 90, 100, 1000)
controller.rumble(ACT2, 90, 100, 100)
controller.rumble(ACT3, 50, 100, 10)
Did not (yet) look into how the power settings of an actuator work.
"RuntimeError: Unknown error": I realized that if I stop the program and restart it and turn on the controller then this can happen
Happens here from time to time.
See https://github.com/pybricks/support/issues/1509
If you find a way to consistently reproduce it, that would be very helpful.
The controls do appear to be additive:
>>> controller.rumble(power=[100, 00, 0, 0], duration=250, delay=00, count=100)
>>> wait(2000)
>>> controller.rumble(power=[0, 00, 100,0 ], duration=250, delay=00, count=100)
Now both the left + left trigger are active.
If you give a new command for an actuator that is already active, the latest command "wins". So if you used count=100
and then count=1
, it will stop soon.
I propose these defaults:
def rumble(power=100, duration=200, delay=100, count=1)
...
So you can just do:
controller.rumble()
controller.rumble(count=3)
And so on.
The controls do appear to be additive:
That sounds like a useful thing, as different parts may be triggered by different events, and adding them up this way can make it easy.
But sometimes we just want sequential execution of multiple rumble commands, so what do you think @laurensvalk about that wait
parameter to make that use case easy as well?
I propose these defaults:
It makes sense to have everything defaulted like that, and then it's easy to use and parameterize only what you want. I'll test with that timing later to see how it feels, yesterday I tested with duration=250, delay=150
, that was also fine.
Upcoming rumble blocks!
Looks good! I guess the optional parameters unfold by the arrow on the right and it is possible to add any combination.
This is a spot for discussing gamepad connections, split off from https://github.com/pybricks/support/issues/262