PDA

View Full Version : [Question(s)] Making a web interface for pan/tilt



madhatter
09-19-2008, 09:10 PM
Hi everyone,

I am new to this forum and robotics as well. I decided to purchase the Pan Tilt Kit from Trossen (Item #: RK-PT-200), attached a camera, and have been having a lot of fun programming it in C#. I started merely editing the example program to get used to how to interact with the servos. I'm starting to get the hang of it and would like make this more useful. I would like to create a web interface that would be able to control my camera remotely. I would also like to play around with getting it working with roborealm, which I am having some issues with...but that's another story :-P

So I have all of the features created in C# that I wish to have on my webpage. I've seen a webserver feature with phidgets, but I'd rather host it on a LAMP server. I'm new to programming and would like to know if there is a way to easily move my code to something usable on a webserver. I know a bit of java but I want this to be very light weight. Any input is greatly appreciated. Thanks!

Adrenalynn
09-20-2008, 01:15 AM
Welcome to the TRC!

What servo controller are you using?

Much C# can be ported over under Mono on the unices and C# itself is intended to be very "web-aware". Most servo controllers are simply serial devices with a published protocol, so it's entirely feasible to just do client-server in your language of choice and connect the server directly to the servo controller.

You mention coding against LAMP, but not what you plan on coding in - your thoughts/desires?

Again - welcome!

madhatter
09-20-2008, 02:35 AM
Thanks for the quick reply! The kit came with the Phidgets USB 8-Servo Controller (http://www.trossenrobotics.com/p/phidget-advanced-usb-servo-controller.aspx). I thought since I was new at this USB would be easier for a plug and play situation. Is this as easy to connect to as the serial controllers? Phidgets seems to have pretty good all around support for different OS's so I'm assuming it won't be too much of an issue talking to the controller.

I really have no idea what language to code in, which in my main question. I really admire what the guy who created MIDAS did. His web interface looks light, and similar to the type of look I'd like:
http://web.mit.edu/zacka/www/images/screenshot.gif

I have a camera connected which I will have a streaming video embedded in the same page (which I think should work great in "motion" under an ubuntu LAMP setup.


You mention coding against LAMP, but not what you plan on coding in - your thoughts/[email protected] Did you mean to say "coding against java"? Sorry, I'm a bit confused.

So as stated previously, I'd like to get it running with a LAMP server and motion. Is there a way to integrate it with PHP perhaps? If there is an easy way to link the page to talk to the controller in real time I'm down for trying anything I can as well. Thanks for the input!

Adrenalynn
09-20-2008, 03:32 AM
Sure! Not terribly difficult to implement that interface.

LAMP is Linux/Apache/MySQL/PHP as a stack of software.

Generally, you're going to need client-side software for your streaming video. PHP is probably going to be your weapon of choice for the server side. When I say "against" - I don't mean "against" as-in "anti" - to "code against" a library or stack really means something more like "butted up against" or "joined to"

The USB controller is really just a serial device. If I'm not mistaken, that one should be creating a virtual serial port that you can write to. Alas, I don't have any phidgets stuff at all, so I'm not the best choice for documenting that process. Metaform3D here might know better than I - I think he was using a phidgets controller at one point. I'm more the SSC-32 "expert".

metaform3d
09-20-2008, 02:15 PM
I think madhatter's main question was about programming the web server side, not driving the controllers. I'd also be interested to learn how to create a web page that can drive a controller someplace, so I'll be watching this thread.

If you want to see what I've done with Phidgets you can download the iLush source (http://forums.trossenrobotics.com/downloads.php?do=file&id=70). There are some lower-level C# classes for interfacing with devices which are intended to be reusable.

Adrenalynn
09-20-2008, 03:52 PM
Well, I'd kinda think that knowing if/how you can get to the controller from unsupported languages would be a pretty important part, right?

There's two ways I can see this architecture:

Client -> Server -> Controller
or
Client -> Server Push -> Private Client -> Controller

I think I'd pick the first if my server was going to sit next to my controller physically, the the second if I was going to host access in a datacenter.

If there are no PHP libraries, for example, but the controller can talk a simple serial protocol (like the SSC-32, for example, or the Serializer) - then the web server will send commands to the controller directly.

For the SSC-32, I could have a dynamic button written with PHP that says "center the servo", and I'd open a serial port and send "#1 1500<cr>" from within PHP. Ditto CGI, for example.

That's why I was curious what the controller could handle. I'll go look it up later - I've got to put some exception cases to bed in this code I'm working on...

madhatter
09-21-2008, 01:09 AM
Here are a couple of pictures of my pan/tilt setup with the camera on as well. I just made the case this weekend with what tools/materials I had available (cant have much in a college dorm :rolleyes:), to just keep it standing up and steady for now. I'll have to get a project box to replace it as some point.
http://maddhat.com/etc/forums/pan-tilt-front.pnghttp://maddhat.com/etc/forums/pan-tilt-side.png
I have a box set aside for this project, an IBM T23 with I believe a 1.2gHz proc, 512mb RAM, and 40GB HDD. Should be fine to just run ubuntu server 8.04 with AMP. I will setup motion to do the capture and streaming video for now. So I guess right now I need to find something that will play nice with PHP.. and learn how to get the phidgets controller talking to the app I write! Yikes! I'll work on it as much as I can this week, and post my results. Let me know if anyone finds something that would help. Id greatly appreciate it!

@Adrenalynn: I'd like to go with option 1 -
Client -> Server -> Controller
It seems the API is pretty handy for the phidgets controller, and shows all ways to interact with different languages... I'll just have to figure out the basics of whichever language I choose to use that can work with PHP.

@metaform3d: I tried the source code you have for ilush but couldn't get it working, it said I needed the phidgets21, so I moved all the phidgets21 files to every project directory in it I could think of and re-opened with Visual Studio 2008, but still no luck. :sad:

MikeG
09-23-2008, 07:43 AM
This might be of some help.
http://www.crustcrawler.com/products/smartarm/remote/index.php

Itís a pretty simple setup. A client PC is attached to the Dynamixel controlling hardware. The client PC is running a console application written in .NET that communicates with a web server (Linus/Appach/MySQL/PHP) using XML and HTTP GET. The XML is used to save the state of the Dyanmixel network. Once the client application is running, you can monitor and control the Dynamixel network from the coffee shop down the street. Like I said, the setup is pretty simple but I thought the XML stuff might be of interest.

I prefer using an IP camera for video. For around $100 you can simply drop a frame on a web page.

Good luck with your project.