@@planetdesign4681 well after a mature age if you didnt get, smoothness in action becomes "divine" secret.you watch and see the speed and perfectness in productivity at the same time.
We do have some excellent universities in Britain:Cambridge, Oxford, Hull,…. But this hands on stuff wouldn’t be acquired there, this is pure passion and practical graft
@@BlondieHappyGuy Hey, thanks - it’s kind of out of left-field, but your description of the echo problem may have solved a weird problem my plant has been having with an identical pair of Endress-Houser level sensors being used to measure water levels in two identical stainless-steel mix tanks. Visually, the water exhibits no turbulence as the tank is filled, then emptied, yet the graphs from both instruments show regular “steps” as the water level is slowly drawn down. I’m willing to bet we have a resonance issue in the cavity formed by the stainless tanks, and the interactions with the sonar! Further backing this possibility is that another identical E.H. level does not produce “stepped” graphs at all; just a smooth, linear “sawtooth” as the hopper empties between refills. But this isn’t water, it’s soda-ash, which I’ll bet dampens the hell out of echoes compared to water. Thanks for possibly solving a real head-scratcher!
Nice one. Be careful not to add too much smoothing to the eyes though. A lot of 3d artists get this wrong when animating. Human eyes look very creepy when they move too smoothly.
Its difficult to move your eyes slowly without tracking a moving object, but you can do it if you force your eyes to defocus or otherwise not lock on to any targets. I like doing strange things that somewhat give people the heebie-jeebies, like moving my scalp without touching it, or making my eyes roam about, or moving in a robotic fashion, or changing my gait to a different one a dozen times in as many minutes, or speaking like a DECTalk machine although that last one is more funny instead XD
@@ИльяПростаков-м1с Yep! I believe we can also say its why most people have trouble when it comes to _not looking_ at things that happen around them, or things that move, its because the eyes move so fast and naturally the brain wants to snap focus on objects. Like men looking at _dat bounce,_ be it an old pristine Cadillac or something _finer and fairer_ XD
Here's something to try, though it will take a small bit of computation. Have the eyes snap left or right quickly, and then have the neck turn more slowly in that direction, but counter-rotate the eyes as this happens so they appear to have locked onto looking at something, and the head then turns to consider it...
Fun fact: human eyes won't move smoothly unless they are focused on a moving object (or what brain thinks is a moving object). At any other time eyes just snap to a new position very quickly.
It's 12:52 am, i've never in my life have made a robot, hell i've never even seen a 3d printer in person, yet i'm still going to watch this as if it's on an exam.
For anyone wondering how to smooth the launch of the curve as well, just check out different interpolation functions. Trigonometric or cosine interpolation is a really common one for essentially making this curve from the video smooth on both launch and landing. They are also going to be just one line in your code!
Very good point. A programmer friend of mine went and did his high school maths again to remember how to use Sin wave. He uses it to start and stop motion smoothly.
I think the loss of jitter improves effect vastly as well. You could read the speed of joystick movement as well, that would allow variable speed smooth movements. In operation sounds may elicit faster movement than vision. Cheers
Fun fact: a similar method can also be used to fuse two sensors' data giving out the same information to smooth out the output data, for example: If we have an a gyroscope and an accelerometer sensing the same angle, we can set a new variable fused_angle = 0.95*gyro_angle + 0.05*accel_angle. Cool thing about this is that the gyroscope captures changes in the angle faster but it has what is called "drift" (the value it senses slowly deviates from the actual angle), while the accelerometer is not nearly as fast at detecting such angle changes but it does not drift. Fusing them together gives you an angle reading which is responsive thanks to the gyro contribution, but does not drift thanks to the accelerometer cobtribution. This is a good alternative to using more complicated (and computationally expensive) methods such as a kalman filter while still giving very good results in most cases (at least when talking about arduino projects).
Of course, I read this now, months after giving up on trying to work this out on my own on 6050s, and instead just (through sheer luck) used someone else's head tracker XD All jokes aside, this is fantastic to read and I might give it another go. While the tracker I found works, it'd be nice to do some customising!
Wow... This is the kind of thing you don't know how to find when you need it, you don't learn in a class because you were distracted for the 2 minutes it was mentioned, and no one talks about. It's so obvious but so passable. Great tip!
@@fiveoneecho i've been like, toe deep or ankle deep in this stuff for a couple days, and while complementary filters are cool, kalman filters, madgwick filters, and others are even cooler. (EDIT: wow i missed that kalman filters were already mentioned as more expensive, reading comprehension fail. >_>) I'm currently using a library called dcmimu (which is the rust port of a c library with an associated paper called dcm-imu) and, frankly, i'm just treating it like a black box. probably shouldn't be, but i haven't had the bandwidth to try to properly evaluate all the options i have, when i'm still trying to figure out what the best method for calibration is. (after all, garbage in, garbage out)
In case anyone is wondering how that code works; its increasing or decreasing the servo position by 5% every X of a second to keep giving the servo a new position slowly until it gets to the desired position but neatly factors in larger movement to start off because 5% of the difference is largest at the start. You might have thought you could do it in a loop and a counter, which you can but it would be more of a linear sweep with no deceleration. Its good thoughtful coding.
Hi James, thank you for sharing my project! I am not using arduino this time, but your suggestion to move it smoothly is great! I will adapt it in future movement sequences. Right now I am focused on the hardware. Files are being shared, so anyone can build it 😊
In animation everything should have an ease in when it starts moving and an ease out when it stops moving. The easing should depend on the total movement, the speed, the elasticity, the mass, and things like that. Something with little mass can accelerate quick and it can also decelerate quickly. So the eyelids don't need as much smoothing as the eyes, and the eyes don't need as much as the head. I think the way you did it is a huge improvement on the default binary speed. It's also nice that it is very easy on resources and it's easy to understand and implement. So I think this solution is a very good compromise between realistic movement and complexity. This also makes it great for beginners. That said, as I mentioned in the beginning of my comment it should look even more realistic if it also included an ease in. It should also look more realistic if all servos get their own smoothing parameters. Choosing the wrong smoothing can make it look worse though, so it requires a bit of tweaking
A little ease in is achieved naturally by the limited force the servo has to move the mass. It would be cool to wire the feedback potentiometer of the servo to the arduino to see the real position. We only saw the desired position on that plot
Its great to see you using my 5% 95% smoothing algo. You have done really well with this project. Don't under estimate the value of some animated eyebrows. They are really easy to make.
this was really very helpful. please please please bring in more tutorials like these about minor things which go unnoticed in a larger project but are key to its success. thank you!!!
this video just in my recommended just brought me back to one of my favorite channels from a while ago, used to binge watch your hulkbuster build series trying to figure out what anything you were saying meant
Thank you so much! I’m working on a 6 DOF robotic arm and want to use various accelerometers spaced over the arm to work out the position of the head in relation to the base of the arm. This smoothing will be key to make the movement of the arm easier to control with less jerking.
If you are working on creating a robotic arm, you should try to work towards programming a PID controller. It will give you much more control over how the arm moves.
This is cool. It's also another chance to let everyone know that Disney has a lot of research on this. Their robots are a lot heavier, and if you just target a location, the whole robot can rattle around. IIRC, they used some kind of overshoot method, which allows them to move fast, yet keep the robot from shaking from the move. I think lol.
Congrats on 1mil subs! idk how long its been since u got to it but congrats anyways! Idk when I followed because I made this channel more recently, but I remember back when you made the xenomorph, this channel is what got me interested in engineering, arduino, and 3d printing.
These are called "easing transitions" and there are many different ones for different types of animations. I'd definitely recommend looking up some of the theory on these to help fine tune formulas for different uses.
You should: A- Not make the eyes change position smoothly, human and animal eyes do move very suddenly, except for when point B: B- when the head moves you should make the eyes counteract the head movements so they keep aiming at one position until you make them change target.
I hadn't watched a Bruton video in 4 years and it's quite striking how the narration has changed. It's almost like there is smoothing on the end of sentences. :)
I think I figured it out, it's a conscious effort to talk more slowly, probably as the result of feedback. My solution. Watch the video at 1.5 X and I get the faster talking Bruton back. ;-)
You can re-arrange your smoothing formula a bit. newpos = oldpos + k*(target-oldpos) where 'k' is typically 0.05 to 0.03. This is a tiny bit faster (only one multiplication vs two). But more importantly, needs only one constant. Your original formula (@ 6:11) you have to always make sure that the two constants (0.95 and 0.05 for example) add up to exactly 1.000. This can be easily missed when tuning the values. Also, you can get a bit more precise by using the delta-time step in the formula (but takes another mulitplication) newpos = oldpos + k2*time-step*(target-oldpos). (where k2 is a new constant tuned for) So long as the delta-time isn't very long, this can give very precise movement that accounts for just how often the loop runs. For an animation it's probably not worth it, but if you're doing precise positioning of an item, it can be useful.
Congrats on reaching 1m subs. I’ve only just noticed. 🏆 Thoroughly well deserved. Been watching you for years. You’ve taught me a lot. Even though I’ve been programming since 89 and the programming isn’t too advanced for me, it’s a brilliant intro for my daughter and others. Thanks 🙏
You don't need `switch1Prev` because it always has the same value as `switch1Smoothed. Just `smoothed = smoothed * 0.95 + input * 0.05` is enough. It's also worth noting that eyeballs are the fastest-moving part of the human body and naturally have motion very similar to servos. I would not smooth them, or only very slightly, but have them target something in global space with inverse kinematics, and have the head follow the direction of the eyes slowly and smoothly.
Another way is the single pole digital filer. Vnew=(Vin-Vold)*delT/tau+Vold Vold=Vnew Tau is the time constant (small is fast) and delT is the step size (in your case 10ms). Vin is the signal from the switch. Vnew goes to your servo. Good video as usual!
It would be interesting to see how the eyes moved if you opted to remove the black eyes, put cameras in their place and tried 3D plans & AI projects with the eyes.
I think this code will really help my skeleton animatronic. It's a modification of a leering skeleton on a grave, powered by an Arduino, with PIR sensors for eyes. It wakes up when it sees motion, with red glowing eyes, and pivots it's head and body to look in the direction of the movement. I'm currently using delays to get attenuated movement, but this will look ten times better with smoothing. Thanks for sharing!
beautiful! I'd love to build this for my kids but currently do not have solidworks, fusion or any other decent CAD software, actually. could you possibly share discrete stl files rather then unified STEP, for ease of printing?
You could scale the smoothing time as an input to characterize different "emotions" in your animatronic. Energetic states would have sharper smoothing and more lethargic states would smooth more slowly.
I live outside Chicago and i love the creators from other parts of the world! It's 1am and this pops up. So awesome lol Also your background music is pretty great
Great work, it really proves that every thing in nature behaves like a logarithmic curve, what you explain here is warping the pulse within a logarithmic curve that shapes the on and off transition instead of having sharp sudden changes. As per comments below yes, this can also be applied to turning LED on or off to make them glow up or glow down (emulate a candle light for example) or to shape sounds to create smooth transitions for amplitude or frequency allowing different sound effects . As someone said below think of all the applications that use pulse width modulation.
That smoothing algorithm you used was as elegant as it was ingenious. And the way you demonstrated this in the visual graphing really made this apparent you went from those choppy square waves to those poetic looking curves. You should consider making a full-sized animatronic running 6 - 8 arudinos to show how life like this can be in terms of arm/hand movement, treadle turning, and of course facial movements including your pair of amazing eyes.
Excellent tutorial! My own experience with smoothing motion comes from the control used in the Canadarm/Canadarm2 robots. In those, the operator puts in a desired motion vector, and the joint servos are commanded simultaneously to give a blended (resolved) motion along the desired vector, which changes every 80 milliseconds. The operator's command is with two joysticks that give 6 axis control. It looks very smooth and natural (but of course costs multizillion dollars).
Hey James, It's always interesting to see you make these simple hinging parts. I'm wondering why you used a normal bolt at 1:15, while for the next one (1:32) you seemed to have used a self-tapping screw. Also, how do you like to make the thread in your 3d printed parts? threaded inserts or just threading the 3d-printed hole?
Super useful video, thank you for that! The robot projects on this channel combined with some animatronics like these could become terrifyingly characteristic
The fact that the uncanny valley exists means that at some point in evolutionary history it was advantageous for humans to be able to detect (and be afraid of) something that looked like a human but wasn't.
What James has created here is a low pass filter (fast input changes are reduced). This can also be used to reduce 'blips' in analogue values such as reading a light sensor etc. I hope you don't mind but I've pasted a function to do this. Call it with input=the analogue value read (converted to double), and f as the cutoff frequency in Hz (try 0.3). Call it from a timed loop (e.g. reading a value and having a delay (e.g.100ms) double filter(double input, double f) { static bool initialise = true; static double prev_x = 0, prev_y = 0; double y; double T; static unsigned long lastmillis; T = (millis() - lastmillis) / 1000.00; //f = 0.2; //Cutoff frequency in Hz, small value makes a slow response f = f * 2 * PI; //if (initialise) y = input; else y = f * T * prev_x + prev_y - f * T * prev_y; initialise = false; prev_x = input; prev_y = y; lastmillis = millis(); return y; }
A NN is overkill. The only reason to use it would be to simplify the control system. Train a network to match video frames of a face to keyframes of servo positions. That would be a lot of work. A GAN is 100% unneeded.
Nice video! Pretty much showing how easy it is to do essentially just a kalman filter. Changing the percentage you rely on the previous and the next value would be the Q and R in the filter
9:35 Running all events in an infinite loop is not energy efficient nor is using delay functions, the best approach I found when i was working with PIC micro controllers is to use an internal timer TMRO to generate an interrupt at fix intervals and then run all events within such interrupt, the lapsed time within interrupts the micro controller can be in sleep mode until next interrupt saving big time on battery life. Now I use ESP32 with RTOS and internally has the same principle with the added feature that each interrupt checks for task priorities on the queue and that's how multitask operating systems work. The ATMEL 328 used by arduino uno has 2 internal timers that can allow even more options. I think the loop approach used by Arduino is good for beginners but create really bad habits for embedded programming. The way to go is to get familiar with interrupts, service interrupts and priorities.
You should make the eyes unsmoothed as they were as real eyes dont have any smoothing when they look around, and for the rest, near the end of the deceleration make the value go straight to zero, so it decelerates then stops suddenly when its almost done decelerating. This will replicate human movement quite a bit better. Great Video!
Very nice project. A little tip ;) You could implement the setSequencer (10:05) using a switch / case to avoid if/else statements and in future projects with more steps, use a Design pattern like state machine. Using switch/case could be something like this: void stepSequencer() { int ellapsedTime = currentMillis - previousMillis; bool changeStep = false;
I use this same trick programming games and smooth UI code. the best thing I learned in college haha. maybe the only thing. I love this video thanks for sharing with everyone!
A good eye rotation calculation has each eye looking at the same point. Then you get a bit of toe in. Then you can move the virtual look at position with your controller ( could be on an arc) This looks more realistic than both eyes in parallel turning at the same speed. Nice work. Good building and showing how to use a simple low pass filter.
I loved that video! Well done! My suggestion for a future video would be a beginner’s guide tu Fusion electronics. Design a simple PCB and and have it made by JLC PCB! Fusion electronics really opened up so many possibilities for me.
ohh, I was having trouble controlling two axes on one of my projects because the delay was messing things up, using the clock instead is such a great tip
I know this is old, but I'm in progress of making this. My version will have face tracking via depthai. And powered by openai API. Love this version of animatronic eyes. thanks for such a great design. And thanks for posting the CAD!
Similar technique can be used to smooth analog signals, a FIFO buffer of 10 or so values, added together then divided by 10. When a new value enters put the old one out and reaverage. Easiest is to keep an array and cntr. Put the value in at the cntr, increment by on. If the cntr >9 reset to zero. You just overright the last item in.
it's important to note that this method of smoothing always adds a bit of delay into the system, so for things that you want to be smooth but still snappy, you'd be better off using a proper easing method which allows you to specify exactly what time it should take to get to its final position, and whether it should ease in or just start immediately like your system does
I really like your little eyeballs and eyelids a LOT more than that first human head you showed!!! I would love to see some of these kinds of things integrated into open dog where the visual sensor for depth would be able to pan and tilt in the same way but in a sort of mechanized organic kinda way like this!
Another way to do this is to have a second variable called "speed" (or acceleration). Which you adjust positive or negative based on how far the new value is away from the previous and you can then also make the speed value smoothed. Which will make a smooth start + end possible. Now the start is still 'sudden'.
Wow you are awsome 😍 i always wanted to become a person like you and today, Finally youtube algorithm recommended you. Keep building stuff you are awsome 😉
this guy makes a whole ass senior engineering project every week
That’s dedication
How did this british accented guy educate hımself? That s What i really Wonder.
Amazing result this week.
@@caner8688 I’m sensing some sort of antagonistic energy here, just wondering
@@planetdesign4681 well after a mature age if you didnt get, smoothness in action becomes "divine" secret.you watch and see the speed and perfectness in productivity at the same time.
We do have some excellent universities in Britain:Cambridge, Oxford, Hull,…. But this hands on stuff wouldn’t be acquired there, this is pure passion and practical graft
This method also works well for making LED animation look smoother.
Example?
This is Mike, you don't ask him for example. His channel is example
I can’t imagine this. Any examples?
It also works for making smoother music synthesizer sounds
@@BlondieHappyGuy Hey, thanks - it’s kind of out of left-field, but your description of the echo problem may have solved a weird problem my plant has been having with an identical pair of Endress-Houser level sensors being used to measure water levels in two identical stainless-steel mix tanks. Visually, the water exhibits no turbulence as the tank is filled, then emptied, yet the graphs from both instruments show regular “steps” as the water level is slowly drawn down. I’m willing to bet we have a resonance issue in the cavity formed by the stainless tanks, and the interactions with the sonar!
Further backing this possibility is that another identical E.H. level does not produce “stepped” graphs at all; just a smooth, linear “sawtooth” as the hopper empties between refills. But this isn’t water, it’s soda-ash, which I’ll bet dampens the hell out of echoes compared to water. Thanks for possibly solving a real head-scratcher!
Nice one. Be careful not to add too much smoothing to the eyes though. A lot of 3d artists get this wrong when animating. Human eyes look very creepy when they move too smoothly.
Its difficult to move your eyes slowly without tracking a moving object, but you can do it if you force your eyes to defocus or otherwise not lock on to any targets. I like doing strange things that somewhat give people the heebie-jeebies, like moving my scalp without touching it, or making my eyes roam about, or moving in a robotic fashion, or changing my gait to a different one a dozen times in as many minutes, or speaking like a DECTalk machine although that last one is more funny instead XD
Yeah I was thinking this too, eyes and eyelids are probably the worst candidates to show off this smoothing
Agree, totally. Eyeballs move almost discretly in real life
@@ИльяПростаков-м1с Yep! I believe we can also say its why most people have trouble when it comes to _not looking_ at things that happen around them, or things that move, its because the eyes move so fast and naturally the brain wants to snap focus on objects. Like men looking at _dat bounce,_ be it an old pristine Cadillac or something _finer and fairer_ XD
See also: Sauron’s eye in LOTR movies ;-)
Here's something to try, though it will take a small bit of computation. Have the eyes snap left or right quickly, and then have the neck turn more slowly in that direction, but counter-rotate the eyes as this happens so they appear to have locked onto looking at something, and the head then turns to consider it...
Fun fact: human eyes won't move smoothly unless they are focused on a moving object (or what brain thinks is a moving object). At any other time eyes just snap to a new position very quickly.
@@JTCF Not a fact and why would it be fun for everyone if it was true.
@@maxxsteele9396 it's absolutely true
@@JTCF Yes, but they will also move smoothly when you focus on a stationery object and then move your head.
@@maxxsteele9396 how about you cite a source supporting your claim and refuting theirs, rather than resort to baseless insults?
It's 12:52 am, i've never in my life have made a robot, hell i've never even seen a 3d printer in person, yet i'm still going to watch this as if it's on an exam.
For anyone wondering how to smooth the launch of the curve as well, just check out different interpolation functions. Trigonometric or cosine interpolation is a really common one for essentially making this curve from the video smooth on both launch and landing. They are also going to be just one line in your code!
Very good point. A programmer friend of mine went and did his high school maths again to remember how to use Sin wave. He uses it to start and stop motion smoothly.
I think the loss of jitter improves effect vastly as well. You could read the speed of joystick movement as well, that would allow variable speed smooth movements. In operation sounds may elicit faster movement than vision. Cheers
I could just watch it move around for a long time. I didn't expect it to work that well!
Fun fact: a similar method can also be used to fuse two sensors' data giving out the same information to smooth out the output data, for example:
If we have an a gyroscope and an accelerometer sensing the same angle, we can set a new variable fused_angle = 0.95*gyro_angle + 0.05*accel_angle.
Cool thing about this is that the gyroscope captures changes in the angle faster but it has what is called "drift" (the value it senses slowly deviates from the actual angle), while the accelerometer is not nearly as fast at detecting such angle changes but it does not drift. Fusing them together gives you an angle reading which is responsive thanks to the gyro contribution, but does not drift thanks to the accelerometer cobtribution.
This is a good alternative to using more complicated (and computationally expensive) methods such as a kalman filter while still giving very good results in most cases (at least when talking about arduino projects).
Of course, I read this now, months after giving up on trying to work this out on my own on 6050s, and instead just (through sheer luck) used someone else's head tracker XD
All jokes aside, this is fantastic to read and I might give it another go. While the tracker I found works, it'd be nice to do some customising!
Yes. This is a good option. For anyone who wants to learn more, the sensor fusion version described here is known as a Complementary Filter.
@@martinmckee5333 thanks, completely forgot about the name!
Wow... This is the kind of thing you don't know how to find when you need it, you don't learn in a class because you were distracted for the 2 minutes it was mentioned, and no one talks about. It's so obvious but so passable. Great tip!
@@fiveoneecho i've been like, toe deep or ankle deep in this stuff for a couple days, and while complementary filters are cool, kalman filters, madgwick filters, and others are even cooler.
(EDIT: wow i missed that kalman filters were already mentioned as more expensive, reading comprehension fail. >_>)
I'm currently using a library called dcmimu (which is the rust port of a c library with an associated paper called dcm-imu) and, frankly, i'm just treating it like a black box. probably shouldn't be, but i haven't had the bandwidth to try to properly evaluate all the options i have, when i'm still trying to figure out what the best method for calibration is. (after all, garbage in, garbage out)
In case anyone is wondering how that code works; its increasing or decreasing the servo position by 5% every X of a second to keep giving the servo a new position slowly until it gets to the desired position but neatly factors in larger movement to start off because 5% of the difference is largest at the start. You might have thought you could do it in a loop and a counter, which you can but it would be more of a linear sweep with no deceleration. Its good thoughtful coding.
Hi James, thank you for sharing my project! I am not using arduino this time, but your suggestion to move it smoothly is great! I will adapt it in future movement sequences. Right now I am focused on the hardware. Files are being shared, so anyone can build it 😊
Love your hard work on all your projects !
In animation everything should have an ease in when it starts moving and an ease out when it stops moving. The easing should depend on the total movement, the speed, the elasticity, the mass, and things like that. Something with little mass can accelerate quick and it can also decelerate quickly. So the eyelids don't need as much smoothing as the eyes, and the eyes don't need as much as the head.
I think the way you did it is a huge improvement on the default binary speed. It's also nice that it is very easy on resources and it's easy to understand and implement. So I think this solution is a very good compromise between realistic movement and complexity. This also makes it great for beginners.
That said, as I mentioned in the beginning of my comment it should look even more realistic if it also included an ease in. It should also look more realistic if all servos get their own smoothing parameters. Choosing the wrong smoothing can make it look worse though, so it requires a bit of tweaking
A little ease in is achieved naturally by the limited force the servo has to move the mass. It would be cool to wire the feedback potentiometer of the servo to the arduino to see the real position. We only saw the desired position on that plot
@@viniciusfriasaleite8016 also the fact that he's converting rotational motion to linear theres some sinusoidal ease-in and out
Fantastic video! Thanks for doing simpler videos covering the "basics" once in awhile - it inspires newbies like myself to give it a try with my kids!
Its great to see you using my 5% 95% smoothing algo. You have done really well with this project. Don't under estimate the value of some animated eyebrows. They are really easy to make.
I want to see this guy build an animatronic like the one at pandora. He’s got the skills to make it really realistic
this was really very helpful. please please please bring in more tutorials like these about minor things which go unnoticed in a larger project but are key to its success. thank you!!!
this video just in my recommended just brought me back to one of my favorite channels from a while ago, used to binge watch your hulkbuster build series trying to figure out what anything you were saying meant
That is beautiful in its simplicity, execution and aesthetic. Well done, sir!
holy cow when you connected the joysticks it really brought him to life with smooth motion. thanks for such a cool video!
Thank you so much! I’m working on a 6 DOF robotic arm and want to use various accelerometers spaced over the arm to work out the position of the head in relation to the base of the arm. This smoothing will be key to make the movement of the arm easier to control with less jerking.
If you are working on creating a robotic arm, you should try to work towards programming a PID controller. It will give you much more control over how the arm moves.
@@blackbomb64 PID is so next level. Thank you for the advice. Will give it a go :)
It's crazy how big of a difference such a small chunk of code makes! Very lifelike. Thanks for sharing!
This is cool. It's also another chance to let everyone know that Disney has a lot of research on this. Their robots are a lot heavier, and if you just target a location, the whole robot can rattle around. IIRC, they used some kind of overshoot method, which allows them to move fast, yet keep the robot from shaking from the move. I think lol.
Congrats on 1mil subs! idk how long its been since u got to it but congrats anyways! Idk when I followed because I made this channel more recently, but I remember back when you made the xenomorph, this channel is what got me interested in engineering, arduino, and 3d printing.
These are called "easing transitions" and there are many different ones for different types of animations. I'd definitely recommend looking up some of the theory on these to help fine tune formulas for different uses.
Thank you so much. I kinda gave up on a project because I couldn’t figure out servo smoothing. Now I can get back into it
You should:
A- Not make the eyes change position smoothly, human and animal eyes do move very suddenly, except for when point B:
B- when the head moves you should make the eyes counteract the head movements so they keep aiming at one position until you make them change target.
its possible to move your eyes continuously by defocusing altogether
@@Blox117 Ok.
I hadn't watched a Bruton video in 4 years and it's quite striking how the narration has changed. It's almost like there is smoothing on the end of sentences. :)
I think I figured it out, it's a conscious effort to talk more slowly, probably as the result of feedback. My solution. Watch the video at 1.5 X and I get the faster talking Bruton back. ;-)
It'd be interesting to see if you could set a "per servo" smoothing, since some things like eye have a lot snappier motion.
They have I suppose? The values set for the smoothing is same for all section. Just guessing here don't be mad
I usually dont really comment on a yt video. But this one just blows my mind.
how simple yet elegant...really amazing. keep going 😊❤️🔥
That smoothing looks like a RC (resistor condensator) discharge, you could make it delay independant using an exponential
That's because it is a discrete first order transfer function just like RC
Out of all the animatronic tutorials, this one manages to make arduino coding sensible... what? Awesome 👌
You can re-arrange your smoothing formula a bit. newpos = oldpos + k*(target-oldpos) where 'k' is typically 0.05 to 0.03. This is a tiny bit faster (only one multiplication vs two). But more importantly, needs only one constant. Your original formula (@ 6:11) you have to always make sure that the two constants (0.95 and 0.05 for example) add up to exactly 1.000. This can be easily missed when tuning the values.
Also, you can get a bit more precise by using the delta-time step in the formula (but takes another mulitplication) newpos = oldpos + k2*time-step*(target-oldpos). (where k2 is a new constant tuned for) So long as the delta-time isn't very long, this can give very precise movement that accounts for just how often the loop runs. For an animation it's probably not worth it, but if you're doing precise positioning of an item, it can be useful.
Congrats on reaching 1m subs. I’ve only just noticed. 🏆
Thoroughly well deserved. Been watching you for years. You’ve taught me a lot. Even though I’ve been programming since 89 and the programming isn’t too advanced for me, it’s a brilliant intro for my daughter and others.
Thanks 🙏
You don't need `switch1Prev` because it always has the same value as `switch1Smoothed.
Just `smoothed = smoothed * 0.95 + input * 0.05` is enough.
It's also worth noting that eyeballs are the fastest-moving part of the human body and naturally have motion very similar to servos.
I would not smooth them, or only very slightly, but have them target something in global space with inverse kinematics, and have the head follow the direction of the eyes slowly and smoothly.
This is a great video i wish I had this back when I starting building animatronics.
That structure would be interesting to add some mems sensors control with PID.
I just fall in love with all your projects
The word “animatronic” is forever associated with man killing kids and stuffing them in a robot.. and i love it
Another way is the single pole digital filer.
Vnew=(Vin-Vold)*delT/tau+Vold
Vold=Vnew
Tau is the time constant (small is fast) and delT is the step size (in your case 10ms). Vin is the signal from the switch. Vnew goes to your servo.
Good video as usual!
It would be interesting to see how the eyes moved if you opted to remove the black eyes, put cameras in their place and tried 3D plans & AI projects with the eyes.
Hey, I was just wondering if there was a tinkercad or something similar to show how you wired everything? Thanks.
0:04 afton if he was brutally glued to the suit
I think this code will really help my skeleton animatronic. It's a modification of a leering skeleton on a grave, powered by an Arduino, with PIR sensors for eyes. It wakes up when it sees motion, with red glowing eyes, and pivots it's head and body to look in the direction of the movement. I'm currently using delays to get attenuated movement, but this will look ten times better with smoothing. Thanks for sharing!
beautiful!
I'd love to build this for my kids but currently do not have solidworks, fusion or any other decent CAD software, actually.
could you possibly share discrete stl files rather then unified STEP, for ease of printing?
Wow nice. I love how simple this one is for an electrical noob like me!
You could scale the smoothing time as an input to characterize different "emotions" in your animatronic.
Energetic states would have sharper smoothing and more lethargic states would smooth more slowly.
I live outside Chicago and i love the creators from other parts of the world! It's 1am and this pops up. So awesome lol
Also your background music is pretty great
I didn't know William Afton was doing a tutorial
With how realistic the robot's actions are, *it's unexpectedly wholesome.*
What joysticks are you using for the controller?
I think he has a tutorial for that
Edit: ua-cam.com/video/ATQblGOjMWQ/v-deo.html
Great work, it really proves that every thing in nature behaves like a logarithmic curve, what you explain here is warping the pulse within a logarithmic curve that shapes the on and off transition instead of having sharp sudden changes. As per comments below yes, this can also be applied to turning LED on or off to make them glow up or glow down (emulate a candle light for example) or to shape sounds to create smooth transitions for amplitude or frequency allowing different sound effects . As someone said below think of all the applications that use pulse width modulation.
Looking good is this the fraggle rock reboot? 😁👍
That smoothing algorithm you used was as elegant as it was ingenious. And the way you demonstrated this in the visual graphing really made this apparent you went from those choppy square waves to those poetic looking curves. You should consider making a full-sized animatronic running 6 - 8 arudinos to show how life like this can be in terms of arm/hand movement, treadle turning, and of course facial movements including your pair of amazing eyes.
FNAF fans coming to learn how to make animatronics?
Heheheh
guilty 😩
Here✋️
me
Here
Excellent tutorial! My own experience with smoothing motion comes from the control used in the Canadarm/Canadarm2 robots. In those, the operator puts in a desired motion vector, and the joint servos are commanded simultaneously to give a blended (resolved) motion along the desired vector, which changes every 80 milliseconds. The operator's command is with two joysticks that give 6 axis control. It looks very smooth and natural (but of course costs multizillion dollars).
Thus is useful!
I did something similar to that smoothing code for an ESC but with integer amount rather than percent. Percent makes so much more sense!
Hey James, It's always interesting to see you make these simple hinging parts. I'm wondering why you used a normal bolt at 1:15, while for the next one (1:32) you seemed to have used a self-tapping screw. Also, how do you like to make the thread in your 3d printed parts? threaded inserts or just threading the 3d-printed hole?
U only need nuts or threaded inserts if it needs to be really solid and withstand a lot of stress lol
Super useful video, thank you for that! The robot projects on this channel combined with some animatronics like these could become terrifyingly characteristic
This was right in the middle of the uncanny valley
really ? i guess the valley is different for everyone
The fact that the uncanny valley exists means that at some point in evolutionary history it was advantageous for humans to be able to detect (and be afraid of) something that looked like a human but wasn't.
@@MrGatlin98 yeah or, detect easily when one human isn't acting normally
These guys make the world go round ...thanks
Boston dynicks should watch you videos
They are way better than this smh
@@Hygix_ I have Boston dynamics dog and it is not as good as this.
@@Notverygoodatall that's a different categories of machine
@@Hygix_ these are both robots
@@Notverygoodatall but different shape and use
What James has created here is a low pass filter (fast input changes are reduced). This can also be used to reduce 'blips' in analogue values such as reading a light sensor etc. I hope you don't mind but I've pasted a function to do this. Call it with input=the analogue value read (converted to double), and f as the cutoff frequency in Hz (try 0.3). Call it from a timed loop (e.g. reading a value and having a delay (e.g.100ms)
double filter(double input, double f)
{
static bool initialise = true;
static double prev_x = 0, prev_y = 0;
double y;
double T;
static unsigned long lastmillis;
T = (millis() - lastmillis) / 1000.00;
//f = 0.2; //Cutoff frequency in Hz, small value makes a slow response
f = f * 2 * PI;
//if (initialise) y = input; else
y = f * T * prev_x + prev_y - f * T * prev_y;
initialise = false;
prev_x = input;
prev_y = y;
lastmillis = millis();
return y;
}
In normal life, there is a acceleration at the start, a "constant" speed in the middle and a deceleration at the end.
This is perfect for my social distance Halloween project. Thank you
Now you just need to train a GAN neural net to learn different actors' facial tics and move the robot servos to match.
A NN is overkill. The only reason to use it would be to simplify the control system. Train a network to match video frames of a face to keyframes of servo positions. That would be a lot of work. A GAN is 100% unneeded.
Díky!
"I'm going to publish all the cad and code for this if you'd like to HAVE A LOOK at it"
damnit
why is this a problem?
@@jameshughes3014 It's phunny
@@experimentalcyborg oh. I am slow today
Nice video! Pretty much showing how easy it is to do essentially just a kalman filter. Changing the percentage you rely on the previous and the next value would be the Q and R in the filter
FIVE NIGHT AT FREDDIES
How a simple piece of code makes such a big difference, thanks!
9:35 Running all events in an infinite loop is not energy efficient nor is using delay functions, the best approach I found when i was working with PIC micro controllers is to use an internal timer TMRO to generate an interrupt at fix intervals and then run all events within such interrupt, the lapsed time within interrupts the micro controller can be in sleep mode until next interrupt saving big time on battery life. Now I use ESP32 with RTOS and internally has the same principle with the added feature that each interrupt checks for task priorities on the queue and that's how multitask operating systems work. The ATMEL 328 used by arduino uno has 2 internal timers that can allow even more options. I think the loop approach used by Arduino is good for beginners but create really bad habits for embedded programming. The way to go is to get familiar with interrupts, service interrupts and priorities.
In animation, this type of movement smoothing is called easing. I don't know the math behind easing, but your video explained the idea nicely!
I love these great little how to videos
It's a great tutorial. Really gives you a good idea how they animated Baby Yoda.
You should make the eyes unsmoothed as they were as real eyes dont have any smoothing when they look around, and for the rest, near the end of the deceleration make the value go straight to zero, so it decelerates then stops suddenly when its almost done decelerating. This will replicate human movement quite a bit better. Great Video!
First order filters are such a huge asset for all digital control systems
Very nice project.
A little tip ;)
You could implement the setSequencer (10:05) using a switch / case to avoid if/else statements and in future projects with more steps, use a Design pattern like state machine.
Using switch/case could be something like this:
void stepSequencer()
{
int ellapsedTime = currentMillis - previousMillis;
bool changeStep = false;
switch(stepFlag)
{
case 0:
if (ellapsedTime
tika muchkond hogo le lowde
You are so fast with Projects, really inspiring
I use this same trick programming games and smooth UI code. the best thing I learned in college haha. maybe the only thing. I love this video thanks for sharing with everyone!
Perfect timing, I'm just about done with the physical design of my omniwheel astromech project, this will help a lot in the movement code.
A good eye rotation calculation has each eye looking at the same point. Then you get a bit of toe in. Then you can move the virtual look at position with your controller ( could be on an arc) This looks more realistic than both eyes in parallel turning at the same speed.
Nice work. Good building and showing how to use a simple low pass filter.
Nice idea. What about sensors to detect distance to object? Then you could have it go cross-eyed as you brought objects close.
Getting back to basics time to time is really important
Thanks and once again great job
I loved that video! Well done! My suggestion for a future video would be a beginner’s guide tu Fusion electronics. Design a simple PCB and and have it made by JLC PCB! Fusion electronics really opened up so many possibilities for me.
I'm definitely going to try this! Thank you James!
same!
ohh, I was having trouble controlling two axes on one of my projects because the delay was messing things up, using the clock instead is such a great tip
I know this is old, but I'm in progress of making this. My version will have face tracking via depthai. And powered by openai API. Love this version of animatronic eyes. thanks for such a great design. And thanks for posting the CAD!
Brilliant, straight-forward, and simple to implement! Thanks James!
James Bruton: Congratulations.
It seems very basic but ...
It's very elaborate.
Similar technique can be used to smooth analog signals, a FIFO buffer of 10 or so values, added together then divided by 10. When a new value enters put the old one out and reaverage. Easiest is to keep an array and cntr. Put the value in at the cntr, increment by on. If the cntr >9 reset to zero. You just overright the last item in.
This is amazing!!!!! I never thought something like this for “any one” can do. Very helpful!! Thank you.
By far the best animatronic 3D printed eye mechanism I've seen. Willing to purchase obj or stl files.
it's important to note that this method of smoothing always adds a bit of delay into the system, so for things that you want to be smooth but still snappy, you'd be better off using a proper easing method which allows you to specify exactly what time it should take to get to its final position, and whether it should ease in or just start immediately like your system does
I really like your little eyeballs and eyelids a LOT more than that first human head you showed!!! I would love to see some of these kinds of things integrated into open dog where the visual sensor for depth would be able to pan and tilt in the same way but in a sort of mechanized organic kinda way like this!
how do i get that model????
Another way to do this is to have a second variable called "speed" (or acceleration). Which you adjust positive or negative based on how far the new value is away from the previous and you can then also make the speed value smoothed. Which will make a smooth start + end possible. Now the start is still 'sudden'.
Just use a PID, you'll get all the variables you need
Wow you are awsome 😍 i always wanted to become a person like you and today, Finally youtube algorithm recommended you. Keep building stuff you are awsome 😉
Great video James. Going to implement this on a small robotic arm to stop it jolting when it moves
I think James just smoothed out the internet!
Really enjoy your work, sir. Just subscribed and look forward to watching many more of your videos! Well done.