Great blog. thanks.
What I really want to achieve is to move a series of servos in an specific way. Let me explain more in deep.
I have 3 servos that move an aluminum segment, and each servo is placed at the end of the segment, so moving servo1 will cause the segment 1 to displace the segment 2 and the servos that are placed on those segments, like this:
Sv1 = servo1
Sv2 = servo2
Sv3 = servo3
Seg1 = Segment1 (30 cms of alluminium)
Seg2 = Segment2 (30 cms of alluminium)
Seg3 = Segment3 (30 cms of alluminium)
Sv3 ------------------- Object
------------------- Sv2
Sv1 -------------------
Is like a robotic arm or an extension. Sv1 will move the 3 segments and Sv2 will move only the 2 segments above, the Sv3 will only move the last segment. by moving the servos we can extend the arm to reach some point (height), after an analysis made by someone else, he recommend that the servos should move in stages, not just moving the servo to the needed position, so if we need to extend the arm 46 cms we need to past through 2 stages, first move Sv1 13°, Sv2 46° and Sv3 0°, second move Sv1 24°, Sv2 15° and Sv3 14°. The analyst said that if we don’t move this way the forces in the segments could damage the servos or something like that.
So, since I need to move the servos in this way, I was thinking to wait for some time before sending the next position to the servos, to make sure they had arrived to the previous target. Something like this (values are not accurate, they are just to represent that the servo will move to some position):
usc.setTarget(0,1000);
usc.setTarget(1,1250);
usc.setTarget(2,0);
Sleep(2000);//Sleep 2secs
usc.setTarget(0,2500);
usc.setTarget(1,3050);
usc.setTarget(2,1570);
Then I found that the ServoStatus class provides the Position and the Target of the servos, now things change and I can create a more elaborated work. Something like this:
ServoStatus[] servos;
using (var usc = new Usc(deviceList[0]))
{
for (int stage = 0; stage < 2; stage++)//move through stages
{
usc.getVariables(out servos);
var targets = GetTargets(stage);//this method calculates the target using the stage
while (servos[0].position != servos[0].target)
Sleep(someTime);//or maybe just do nothing
usc.setTarget(0, targets[0]);// command the servo to move target 1
while (servos[1].position != servos[1].target)
Sleep(someTime);
usc.setTarget(1, targets[1]);
while (servos[2].position != servos[2].target)
Sleep(someTime);
usc.setTarget(2, targets[2]);
}
}
what is the best way to solve this?? any ideas?