Shop OBEX P1 Docs P2 Docs Learn Events
Need some help to Control a robot via website - Page 2 — Parallax Forums

Need some help to Control a robot via website

2»

Comments

  • charleyshfcharleyshf Posts: 165
    edited 2012-04-22 05:58
    Just wanted to post an update, I have been googling all over the place for the past few days to see what others have done to remotely control their robots, I've looked at LabView(expensive) and also there are a few people doing something similar with the arduino. There are many different ideas, different programming languages(which I am not good at). Most of the ideas I saw so far people are using Microsoft VB to make their interface or GUI, then it's just a matter of having your robot programmed to respond to what commands are sent to it. I am still gong to try working on node.js today, and see what I can come up with.
  • Mike GMike G Posts: 2,702
    edited 2012-04-22 07:25
    charleyshf, there has been a lot of great suggestions on this topic. Ultimately you'll figure out what works best for your project.

    You know that C# code I posted? This morning I tested the code on my MatchPort b/g device and it worked out of the box. I had to change the IP (or name), Port, and add a HOSTS entry for the MatchPort.

    The IP is the DHCP assigned IP.
    The port, 10001, is the port I assigned in the MathcPost configuration. 10001 talks to the Propeller via serial.

    HOSTS is a file on your computer that resolves DNS names. On a windows box HOSTS is located in the following directory.
    C:\WINDOWS\system32\drivers\etc
    127.0.0.1		localhost loopback
    ::1			localhost
    192.168.1.107		MatchPort
    

    The The C# code is setup to accept URLs and resolve the URL to an IP address (DNS). The code will also accept an IP address. You need to add a HOSTS entry because the code uses DNS to assign configuration to the socket. It might sound a little confusing but later you'll appreciate the DNS look up.

    It really does not matter what language you decide to use. The important thing is gaining a conceptual understanding.
  • charleyshfcharleyshf Posts: 165
    edited 2012-04-22 08:37
    Hi!

    I think that's what is getting to me with this, there are a few different ways to go about this, and I have to face learning another programming language to do this. I have been using a serial terminal thus far to control my robot which is really basic and lacks quite a bit, but it works. The other issue is that I do not know how to program in C#, I have played around with it in the past but not very much. I did download visual c express and tried the code you posted, updated the hosts file(my matchport has a static ip) and it does work, I had just thrown together some quick spin code to receive the text on the prop from the matchport and then display it out to PST, I get "This is a testDI192.168.1.3" , it's probably something I overlooked on the spin code..

    In any event, it does work, and thank you for the example.

    Mike G wrote: »
    charleyshf, there has been a lot of great suggestions on this topic. Ultimately you'll figure out what works best for your project.

    You know that C# code I posted? This morning I tested the code on my MatchPort b/g device and it worked out of the box. I had to change the IP (or name), Port, and add a HOSTS entry for the MatchPort.

    The IP is the DHCP assigned IP.
    The port, 10001, is the port I assigned in the MathcPost configuration. 10001 talks to the Propeller via serial.

    HOSTS is a file on your computer that resolves DNS names. On a windows box HOSTS is located in the following directory.
    C:\WINDOWS\system32\drivers\etc
    127.0.0.1        localhost loopback
    ::1            localhost
    192.168.1.107        MatchPort
    

    The The C# code is setup to accept URLs and resolve the URL to an IP address (DNS). The code will also accept an IP address. You need to add a HOSTS entry because the code uses DNS to assign configuration to the socket. I might sound a little confusing but later you'll appreciate the DNS look up.

    It really does not matter what language you decide to use. The important thing is gaining a conceptual understanding.
  • Mike GMike G Posts: 2,702
    edited 2012-04-22 08:51
    It does not matter what language you decide to use. All languages have pro and cons. The important thing is, you have a working model. You can use the C# code for testing and verifying since you know it works.

    If you decide to go with C#, you have a core socket handler that can be used in a client or server application. I think the node.js looks very interesting.
  • charleyshfcharleyshf Posts: 165
    edited 2012-04-23 08:58
    Okay, well this isn't going so well.. I've looked into all the options in this thread and I have to say I feel like a total idiot, my first mistake was to think this would be a relative easy task, it's not. I was looking at a few examples using an arduino with node.js, and it looks promising, there are examples out there but apparently some of the code examples for nodejs are not cross-platform, different syntax and that's not even talking about the different modules that you can load into nodejs. Since I am not familiar with these different programming languages it's very confusing trying to decide which direction I should take with this, last time I even worked on a website was over 8 years ago, things have changed quite a bit since then... Anyone want to make a few extra bucks?
  • RaymanRayman Posts: 14,838
    edited 2012-04-23 09:07
    I still think Visual Basic is going to be your easiest approach...

    I would start with putty (or some other telnet app) to first get the robot talking to the PC over port 25.
    Then, making a VB app to provide a GUI should be relatively simple...
  • RaymanRayman Posts: 14,838
    edited 2012-04-23 09:15
    I just found this page for you with code and instructions for writing your own telnet client in Visual Basic Express:
    http://www.puzbie.co.uk/shopdata/gg_blog.php?id=115&cat=1
  • charleyshfcharleyshf Posts: 165
    edited 2012-04-23 09:22
    Thank you Rayman..

    I actually already have my robot working over Telnet, that's how I have been controlling it, it can also be controlled over a virtual serial port. The spin code on the robot is mostly spitting out a menu with options(turning on a switch, moving left/right/stopping, so that part works good, just would like to get a better interface where I could display data from different sensors (sonar/temp/humidity/etc). I'm going to give that link a try, I noticed it talked about VB8, but do you think it would work with VB10?
  • RaymanRayman Posts: 14,838
    edited 2012-04-23 09:39
    I would think it would work with VB10 too. There appears to be a big difference between VB6 and VB8. But, I haven't heard of big differences between VB8 and VB10.
    But, I'm not a good person to ask about that though. I haven't actually used Visual Basic in a long time. I mostly use Visual C++...

    BTW: If you do get it talking with Visual Basic, please let us know here... I think there are a lot of people that want to do the same thing...
  • Mike GMike G Posts: 2,702
    edited 2012-04-23 10:31
    Just of of curiosity, you guys realize that the C# code I post does what you need, right?

    There is no major different between VB 2010 and C# 2010. The libraries are all the same. Syntax is different; one is VB the other is C#.

    The posted script can be used in a client or server application (web site). As a matter of fact, the code can exist on an external web server and still control the robot given a proper home router configuration. Is there some adversity to using C#? Would you like me to roll a VB version?

    http://www.agaverobotics.com/spinneret/controlpanel.htm
  • charleyshfcharleyshf Posts: 165
    edited 2012-04-23 11:35
    @Rayman, Will do, I can tell you already it didn't work with vb10, downloading and installing vb8 now
  • charleyshfcharleyshf Posts: 165
    edited 2012-04-23 12:26
    @RayMan, never mind my last post about VB10 not working with that link you provided me, there's some issue when you copy and then paste the code, after making corrections I can say it does work, so a vb program can be made to use telnet. The other thing I stumbled across with VB was this site: http://www.andrew.cmu.edu/user/schapiro/documents/VB2bb.pdf . Even though he's using a basic stamp it doesn't matter, and he is using a serial port connection to control the robot (which I had mentioned before I can either telnet to the Matchport module or make a serial connection to it, in my case com4). This doesn't look to bad to work with, have to dig into it more and see how far I can get.

    Thanks again
  • charleyshfcharleyshf Posts: 165
    edited 2012-04-23 20:01
    For me I know next to nothing about either VB or #C, I just wanted to find a way to get something going that wouldn't drive me crazy trying to figure it out, so far I have gotten VB2010 with some code to work(simple buttons for direction control of the bot) and then have it send commands through the serial port which in turn connects to the Matchport b/g via WiFi which is connected to the prop. Forgive me for asking this but is there an advantage to using #C over VB? I honestly do not know at this point.


    Mike G wrote: »
    Just of of curiosity, you guys realize that the C# code I post does what you need, right?

    There is no major different between VB 2010 and C# 2010. The libraries are all the same. Syntax is different; one is VB the other is C#.

    The posted script can be used in a client or server application (web site). As a matter of fact, the code can exist on an external web server and still control the robot given a proper home router configuration. Is there some adversity to using C#? Would you like me to roll a VB version?

    http://www.agaverobotics.com/spinneret/controlpanel.htm
  • Mike GMike G Posts: 2,702
    edited 2012-04-23 21:51
    The main difference, C# programers get paid more than VB programers. Both language target the .NET runtime and compile down to the same intermediate code. In my opinion there's no difference.
  • charleyshfcharleyshf Posts: 165
    edited 2012-04-25 18:45
    So far I have had some great results with this, one thing I am looking into now is getting data back from sensors on the robot with the prop. One thing I forgot all about with the Matchport b/g module is that is has TWO serial ports on it, I am wondering if it would be better to use one port for control of the robot and the other port would be used for receiving sensor data. Some of the sensors I am planning on using are ping sensors, compass module, and possibly a gps module, I would think that prop should be able to handle this without a problem..
Sign In or Register to comment.