-2

I am using servoblaster from https://github.com/srcshelton/servoblaster

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?

DanZ3r0
  • 1
  • 1

0 Answers0