After many unsuccessful try to bring back compatibility for servo speed control into the new MRLComm, I decide to run some test to understand better the old style speed control

I modify MRLComm used with version 107 and version 1412 to report the time it take to move the servo from 0 to 180 (or 180 to 0) at various speed setting and compute the angular velocity at those speed setting

Here`s the results

Speed       107    1412
            deg/s  deg/s
0.99        520     195

0.9          54      19

0.8          27       9

0.7          18       6

0.6          13       5

0.5          11       4

0.4           9       3

0.3           8       3

0.2           7      NA

0.1           6      NA

with that result no wonder why I coun`t make the new speed control to emulate old one

note the the speed have been decrease by a factor of 2.5 between version 107 and 1412

 

Mats

8 years 2 months ago

Nice test. I tried to plot the values, and as you say it looks like there is a factor 2.5 between the tow implementations. 

What strikes me is that the speed function doesn't look linear at all. The measured speed increases very much as the requested speed comes closer to 1.

So the area between .9 and .99 could be interesting to examine little more.

Is the goal to make it linear ?

/Mats

 

calamity

8 years 2 months ago

In reply to by Mats

Hi Mats

The goal is to be able to replicate the old behaviour into the new MRLComm

I have notice that the curb in the plot need more data between 0.9 and 0.99, but for a servo that turn a robot part, it`s speed will max out well before the .99 value. From the physical test I did some time ago, rothead can turn at about 200 deg/sec, while the arms and torso servo turn more in the range of 10 - 25 deg/sec (at  least on my build) 

I did not run the test many time, n=2 for each speed setting, so to get a solid plot function of this it probably need way more data. But that`s enough to see that it`s not linear.

But the data also told me that the old behavior is not the way to go. The resulting speed vary with the change made in MRLComm and with the load on the Arduino. 

the new speed control use a more constant timing (millis()) to update the servo position and use a measurable unit (in deg/sec) to set the speed of the servo. So if x ms elapse since the last update, move the servo by y degrees.

So yesterday I made change to the speed control in hope it give better results with the gestures scripts Gael used. I have map the speed setting to the data set I got for v107

So when setSpeed(0.7) is called, it will do a setVelocity (18), when setSpeed(0.6) -> setVelocity(13) etc.

So setSpeed is keep for back compatibility, but is now deprecate in favor of setVelocity

 I just tested the version 1.0.1670 with your new modifications, and the approach is very similar to version 1.0.107. It's nice!! I need to run some more tests but it seems pretty concluant!

The servo button modification is also much better of course! There is still something I would suggest, when using voice command to detach a servo, it would be logic that the button servo on the slider GUI also shows that it is detached. Other wise it's a bit confusing.

so, the old speed behavior was actual exponential ...  in that a linear input from 0.0 to 1.0 would yeild an exponential range of outputs.  (I used excel to visualize and validate this assumption.)

So,, in order to fit a curve to this, I took the natural log of the obeesrved speeds from Calamity's tests.  This made the relationship between the input to output linear...

Next,  I did a standard linear regression of the data set computing the slop & intercept of the best fit line to the data set.

Lastly,  I take the output and raise it to the exponential  (e) ..  This approach created a nicely fit exponential curve that models the measured values.

 

Below the blue diamons are the values from Calamity, and the red squares are the computed value.

 

I've checked in this change..  Hopefully it provides a slightly smoother mapping from the old style setSpeed and the new setVelocity.

 

My Final Values for this were:

slope = 3.26

intercept = 1.0

The equation being:

val = e ^ (slope * speed + intercept) 

 

 

 

 

I'm happy that it work great for you

 

about  the servo attach/detach

There is two things completly different that usethe same name and that are call "attach"

one is call base on Arduino servo library that call servo.attach. This method simply turn the servo power on/off. This is the version of attach you mostly use in your script

the other method will send a command to arduino to create some internal unit to manage the servo. All devices or sensor connected to Arduino use that method. That what was call when you initialize the inMoov. 

The GUIs are showing the 2nd method state.

But yes, some improvment need to be add to the GUIs to show/set if the servo have been turn on/off

I'm not sure I fully understand your question

servo.detach() is equivalent of turning it off, you can turn it on again with servo.attach()

servo.detach(arduino) will completely remove the servo instance from the arduino (all data, free up memory). To use the servo again you need to call servo.attach(arduino, pin, posToMove)

Yes I do , no errors , all is clean.

I send to you the noworky

 

sleep(5) #just to take the video for calamity :)
Arduino = Runtime.createAndStart("Arduino","Arduino")
Arduino.setBoard("atmega2560")
Arduino.connect("com3")
from org.myrobotlab.service import Servo
servo = Runtime.create("servo","Servo")
servo.setSpeed(0.2)
servo.setMinMax(10,160)
servo = Runtime.start("servo","Servo")
servo.attach(Arduino, 13, 10, 20)
sleep(10)
print "is detach ?"
servo.detach()
print "mmm no :)"

 

 

ok,

the way the arduino servo library is limitating. I manage to have it start at rest position, but if your head is not near the rest position, it will move quickly to that position. Unfortunatly, there is nothing I can do to slow it down at that level unless we modify the arduino servo library.

 

But I couln't replicate your problem with detach. I have try your script and on the detach() call, my servo turn off, I can turn it by hand and it got powered on with the attach(). 

v1684 should fix where the servo moved on attach, flash the arduino...

 

MMM aarg I think I have identified my problem. It's my f***** CYS servo ! 

They can't be detached. And they send interferences all over the circuit and power ON other servos. It's so bad, I think I must change them.