Skip to content
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

Servo Easing #9

Open
DanZ3r0 opened this issue Aug 22, 2023 · 0 comments
Open

Servo Easing #9

DanZ3r0 opened this issue Aug 22, 2023 · 0 comments

Comments

@DanZ3r0
Copy link

DanZ3r0 commented Aug 22, 2023

Is it possible to implement some sort of easing algorithm in python?

Example:
The following will full speed move servo_x to 1125 at full speed and then back to starting position @ 2500...

servo_x=0

servo_x=(1,125.693)
ServoBlaster.write('P1-11=' + str(servo_x) + 'us' + '\n')
ServoBlaster.flush()
time.sleep(5)

servo_x=(2500)
ServoBlaster.write('P1-11=' + str(servo_x) + 'us' + '\n')
ServoBlaster.flush()
time.sleep(5)

Is there an equivalent to this arduino example?

https://www.youtube.com/watch?v=jsXolwJskKM&ab_channel=JamesBruton

https://hackaday.com/2021/09/03/smooth-servo-motion-for-lifelike-animatronics/

Here he says: "To do this in Arduino/C code, a new intermediate position for the servo is specified for each main loop until it reaches the final position. The intermediate value is the sum of 95% of the current position, and 5% of the target position. This gives the effect of the natural motion described above. The ratios can be changed to suit the desired speed."

@5:16 in the video he adds a few variables into a loop:

void loop () {

switch1=digitalread(12)

switch1smoothed (switch1 * .05) + (switch1previous * .95)

switch1previous = switch1smoothed
}

I feel like the equivalent in the previous terms would be something like:

servo_x=0
servo_x2=0
servo_x3=0

servo_x=(1,125.693)
servo_x2=(servo_x*.05) + (servo_x3*.95)
servo_x3=(servo_x2)
ServoBlaster.write('P1-11=' + str(servo_3) + 'us' + '\n')
ServoBlaster.flush()
time.sleep(5)

but this does not work...
I just end up sending one signal and would like to send a signal that trails off at the end smoothly.
Is servoblaster capable of doing this or is this not possible?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant