UscCmd Possible?

Hi dtech,
I managed to try out your camera interface for a few minutes yesterday - that is pretty cool! There is quite a long lag between adjusting the controls and seeing the camera move, and between when I see the camera move and when the camera’s image updates, so I feel a bit clumsy trying to move it to specific locations, but I am confident that you can improve all of those things! I think it would be really cool if I could click on the view and cause it to automatically turn to point at the location of my click - any chance of adding that feature?

Even if you do not ever make the web server public, I hope you will post some pictures and plans online some time so that we can link to them. This is a cool project!

-Paul

I have sooo much to tell but I will wait for some because this is going to be another novel anyhow…

As simple as I can put it, I have 4-axis joystick control of the arm using a playstation 2 joystick and a PS2 -> USB adapter via a web page on a remote computer, the arm is controlled over wifi network hosting the controls with a web server. I have to refine the controls a bit and tune everything which is getting pretty complicated. It’s not going to be long and I am going to be controlling a R/C tank with the receiver removed and the maestro on board. I plan to remove the turret and mount the arm on it instead and possibly link two maestros. The EEEPC will also be mounted on top and it’s onboard webcam will be the driving eyes. Was thinking the possibility of building an arm page and a tank driving page that way the wife and I can tinker around with it in the house. I’m envisioning this on our living room TV via our micro pc connected to it and a wireless Playstation 2 controller. I’ve also moved the servos using the R and L buttons on the PS2 controller but the timing seems to be a real issue.

Not only this but the timing is multi-dimensional meaning I have to time the video with the controls with the time it takes for the php page to do it’s job with the time it takes the maestro stuff to do it’s thing to the distance and speed and/or report back and the time it takes the servos to move. :open_mouth: Daunting but interesting task I think. I also know if I keep the speed down to about 1 or 2 it is easier to time and everything runs smoother. I’m trying to have speed variable from 1 - 10 depending on the joystick position but anything around 5 and up and timing gets all whacko, if I set to 0 it gets way out of control between the page, camera, and joystick polling. I know this is probably bad code but here is my function that just gets the target of a single servo… here is the single question I have right now…

static unsafe ushort displaySrvPosition(Usc usc, byte srv)
        {
            uscVariables variables;
            ServoStatus[] servos;
            usc.getVariables(out variables, out servos);
				ushort thesrvpos = servos[srv].target;
				return thesrvpos;
        }

I’m sure you can understand what is happening here, probably better than I can cause I just re-used some of the code for --status. Just in case…

It’s simply directly getting the target value for a specified servo… The problem is it is extremely slow to report back.

Is there a faster way to get the target of a servo I am unaware of?

Maybe I have a couple lines in there that do not need to be?

on deck is probably some sort of network voice communication setup using the built in mic on the eepc… two way communications. One thing that I have to point out is the fact that other than the maestro stuff, everything I am doing is being done with open source software that I have been tinkering and working with for years. I’m also an IT&D person so using a network is my game.

Once I win the lottery I am building myself a large scale outdoor version of this so I can mow my lawn from my PC. :laughing:

Hello,

I do not expect that code to be particularly slow, and there is no better way to do it. You could use the COM port, but I do not expect that to be much better, and it would be a big pain to deal with it. I did a little test here, and calling usc.getVariables() in a loop 10000 times takes me a total of about 8 seconds. So you can pretty much call it once per millisecond, which should be good enough, right? How does that compare to the speed you are seeing? If you want to be sure that the slowdown is actually due to that code rather than something else you are doing, put a loop around it and a print statement right afterward so that you know exactly how many times it has run and how long it took. The C# Stopwatch class is also useful for this kind of debugging.

By the way, are you getting updates for multiple servos this way? If so, it might help you to cache the results in a variable and get all of the data for the different servos at the same time.

Also, what are you using this for? If your goal is to set the speed of the servo based on its position, that could also be accomplished with a script running on the Maestro.

-Paul

I’m definitely not seeing those kinds of return times, it’s more like 500ms on this little eeepc. I’m sure the 800mhz processor has something to do with it as well. This and --status are the only two commands I am seeing this with the rest are extremely fast. Is there a way to speed up how fast the data goes from the maestro to the laptop maybe?

Here’s why I am using this.

When I move the stick on the controller, the plugin for the stick reads where it is at and then calls the proper php page (with just the movement code) with the parameters, the php then checks the current target, adds my movement amount for that move to it and tells the servo to move to x position. Otherwise I have no other idea how I would go about this. I could code the target stuff into the maestro instead of having it return to the php and then php reacting I guess… Otherwise I’m thinking a sub was much much faster than using the code. I also altered the code a bit, adding another switch for the distance moved so i could adjust that as I speed up the servos. This is all good though I’ll just experiment with it, I’m sure I’ll find somethi that works good enough for what I want. I’m just testing the limitations more than anything right now.

this might shed some light on how I am using that previous function… This has the extra switch in it though

else if (opts["newmove"] != null)
            {
                string[] parts = opts["newmove"].Split(new char[] {','});
                if(parts.Length != 3)
                    opts.error("Wrong number of commas in the argument to move.");
                    byte servo=0;
                    ushort spd=1;
					ushort sweep=0;
					//int step=0;
					//int curpos = 6000;
                try
                {
                    servo = (byte)Int32.Parse(parts[0]);
                    spd = (ushort)Int32.Parse(parts[1]);
					sweep = (ushort)Int32.Parse(parts[2]);
					//int step=30;
					//displaySrvPosition(usc);
                }
                catch(FormatException)
                {
                    opts.error();
                }
                Console.Write(spd);
				Console.Write("|");
				//Console.Write("curpos:");
				//curpos = (ushort)Int32.Parse(displaySrvPosition(usc,servo));
				//curpos = displaySrvPosition(usc,servo);
				ushort curpos = displaySrvPosition(usc,servo);
				//ushort curpos2 =(ushort)Int32.Parse(curpos);
				Console.Write(curpos);
				Console.WriteLine("");
				ushort finalpos = (ushort)(curpos + sweep);
				usc.setSpeed(servo,spd);
                usc.setTarget(servo, finalpos);
				Console.Write(finalpos);
                Console.WriteLine("");
                usc.setScriptDone(0);
            }

The processor on your Eeepc is a Celeron M, not an Atom, right? If so, we have a similar computer here that we can do some tests on if necessary. Does --status also seem to be slow when you run the version that is installed along with the Maestro Control Center? It seems pretty much instantaneous on our Eeepc. How about with your software, running the “Release” executable vs. the “Debug” one? Any chance you have a broken USB cable that is slowing it down? In general, I do not see any reason for it to take 500 ms to get the variables.

If you can’t get this working more quickly, you could still change your application so that the PHP code remembers what the last target was (using a file, database record, or something) and goes off of that instead of trying to read it from the Maestro.

Yes I am running a eeepc 900 with the Celeron. The --status is slower than my function, probably twice as slow. I think I have it figured out though but I have to do some changing and testing this weekend. It’s funny you talk about the PHP remembering the target because this was how I had it at one time… This may be a possibility but I think I have a way to speed things way up, just have to test then I will report my changes and findings. Once again thanks for all the help I really appreciate a company that is willing to back their product like this.

Okay the first thing I did was brought all the pieces into one room so i could eliminate camera delay.

After tinkering I found something extremely interesting: I was polling too fast… speed was the problem but it was too much of it. I have everything timed pretty decent now and have good enough control from the playstation 2 controller. I did wind up keeping the speed down and I also eliminated the attempt at smooth, nearly proportional throttling for a two speed setup where most of the throw of the stick is low speed at 1 and then depending on the setting for that servo it can switch up to 10 at the end of the joystick throw. I moved the cam rotation to the R1 and L1 buttons and made them so you pressed it once and the cam was in normal position (right side up in most cases), press the other it is inverted. All other positions were worthless anyhow. Locally I have the camera lag to a relatively acceptable place, maybe 1/2-1 second. It is noticeable but manageable. I also set up a “home” button by pressing the start button on the playstation 2 controller, it places the arm to a home position.

I’m happy with the arm for now other than I’ve seen some pre-built arm joints I’d like to use on it for rigidity.

Now for the next step…

I’m want 4 gear reduced Mabuchi 540 sized motors and gear reduction units and a speed controller I can run for the maestro on two channels. It would work as follows:

right stick forward BOTH RIGHT motors spin in the same direction

left stick forward BOTH LEFT motors spin in the same direction
right stick forward, left stick back = skid-steer

I want it to be geared waaaay down. I’m not looking for speed as the camera lag would not work with it.

For now I plan to mount everything on a piece of board and then eventually making some sort of chassis for it all.

Any help in any direction would be greatly apprecisted.