Can please someone explain acceleration? In the documentation it says that
“Acceleration. This option specifies the acceleration of the servo in units of (0.25 μs) / (10 ms) / (80 ms). For example, with an acceleration of 4, the speed of the servo will change by a maximum of 1250 μs/s every second”
How we come up with 1250 μs/s? I want to calculate how long will it take to move the servo from 1500μs to 2000μs with given speed and acceleration settings (speed = 10, acceleration = 5). Can you please explain me how can I do that?
By default, the units of acceleration for the Maestro are (0.25 μs) / (10 ms) / (80 ms). If we take 0.25 and divide it by 10 and then divide it by 80, we can see that the units are 0.0003125 μs/ms/ms. Since there are 1000 milliseconds in a second, we can multiply that number by 1000 twice and see that the units of acceleration are 312.5 μs/s/s. So if the acceleration value is 4, that corresponds to 312.5 * 4 = 1250 μs/s/s.
There is no simple formula I can give you to calculate how long it will take the Maestro to perform a movement. However, in response to your request, we have made a program that you can run to estimate it. Please see the “Maestro Movement Calculator” in the resources tab of the product page for any of our Maestro products.
Thanks for the response and explanation David! The tool is also super helpful.
However, I have to admit that I am little surprised to see that it is too difficult to calculate the movement of a servo. I checked the code of the tool as well which simulates the behavior of the card and helped me to understand the algorithm. Isn’t it possible to formulate that algorithm to make calculation simpler? Can I assume that it is almost impossible to move more than one servo at the same time interval?
If you disable the acceleration limit (by setting it to 0), then the behavior of the Maestro will be much simpler, and you could estimate the time it takes to make a movement by simply dividing the distance traveled by the speed limit (and doing the right unit conversions). If you want to have an acceleration limit, then the algorithm probably cannot be much simpler than it already is, due to the discrete nature of the speed updates.
It should be possible to make multiple servo movements take approximately the same amount of time by choosing the speed parameter for each servo appropriately. You can run the algorithm in the Maestro Movement Calculator several times with different speed values and pick the one that is closest to what you want.
I had the same issue. It took a while, but in the end I got it today.
At least the first tests with different speed/acceleration were quite promising.
What I do is:
- Calculate the required time for all servos
- Take the maximum and recalculate the speed of the other servos.
You will still have a small error as the speed can only set in integer steps, but I can live with that.
Maybe my C# code is of help for you.
@David, what about adding such a feature in the API? Or even better provide a command to synchronously move the servos like the SSC-32 does?
/// Calculates the required time for the servo move
/// <param name="a">Acceleration as specified by Pololu</param>
/// <param name="v">Speed as specified by Pololu</param>
/// <param name="Distance">(PWM/µs) Distance between two servo positions</param>
private double calcRequiredTime(double a, double v, double Distance)
double distance = Math.Abs(Distance); // (PWM-)distance to travel, don't care about the direction
// Step 1: Calculate time for acceleration / deacceleration
// t = v/a
double t = v / a;
// Step 2: Check distance required
double distance_acceleration = 0.5 * a * t * t;
// Step 3: Check if distance is sufficient to reach full speed.
if (2 * distance_acceleration >= distance)
// Step 4.1: If not calculate new t
double s2 = 0.5 * distance; // Take half the distance as we have Acceleration and Deacceleration
t = Math.Sqrt(s2 / (0.5 * a)); // with s = 0.5*a*t²
return (2 * t);
else // Yes, we reach warp speed
//Step 4.2: Calculate remaining distance
double distance_remaining = distance - 2 * distance_acceleration;
//Step 5: Calculate time for remaining distance
double time_remaining = distance_remaining / v;
// Return acceleration + full speed + deacceleration
return (t + time_remaining + t);
Thanks Ralf! For sharing the information. I will give it a try. What you have done makes perfectly sense. I also agree that @DavidEGrayson, adding a command similar to the one SSC32 have would be super useful.
Thank you both for the feedback on the Maestro.
As I mentioned before, if you disable the Maestro’s acceleration limit feature, then it becomes easier to calculate the time it will take for a servo movement to finish. By just doing some basic linear scaling of the speed parameter, you should be able to get several servo movements to finish at approximately the same time.
For example, you can set the servo that is going to travel the longest distance to have the highest allowed speed. For every other servo, set its speed to be equal to the distance it needs to travel multiplied by the speed of the longest-distance servo and divided by the distance that the longest-distance servo has to travel.
The SSC-32U does not support acceleration limits, so if you disable the acceleration limits on the Maestro and then do the calculations described above, I think you would get the behavior you are asking for.
Please let me know if I have overlooked something and there are more features you would like to see in the Maestro.
thanks for the answer.
I don’t know how it is for Yasinh, but in my case the acceleration was the key argument to switch from the SSC32 to the Maestro controller. And with the SetMultipleTarget command I expected that they are of course in sync.
Probably you would also need the synchronized movement in lots of other application. So, I would assume, it would be a well used (and easy to implement) feature.
Yasin, let me know if you need support. Also the second part, calculating the right speed, is a bit tricky.
Thanks David for the answer. I will give it a try.
Two reasons that I am not using SSC32, first one is pololu is a lot smaller and second one is that acceleration.
I agree with David. It would be helpful that all movement functions are deterministic (means easy to calculate time required to make the movement).
@RalfS: You said that synchronized movements would be easy to implement. Could you explain the details of how that would work and why you think it would be easy?
@yasinh: Is there a specific servo movement algorithm that you would want to use that provides acceleration limiting and has easy-to-predict timing?
Let’s have a look on the intention:
- All (involved) servos should start at the same time
- All (involved) servos should stop at the same time
So what has to be done:
- Determine which servo does need the longest time (in regards of given start,end,acceleration,speed limit)
- Reduce the speed/acceleration of the other servos for this move, so their move duration is the same.
- Start the move of all servos
For 1) you have provided already the algorithm in the web form and I also made am approach in C#.
For 2) Setting the speed/acceleration is already possible, just the calculation has to be added.
For 3) already there
As this is a straight forward calculation I would expect that the Maestro can do it on it’s own. (At least if it can calculate a square root). This would expose the functionality also to sequence programs, etc.
Alternatively, supposed my assumptions are correct, you could even copy&paste my code into your c# library. But this would limit the availability to the .NET world.
Also please be aware, that the code is not fully tested as I had to move on to another solution.
Thank you for the feedback, Ralf. We will look into implementing features like that in future products.