Shop OBEX P1 Docs P2 Docs Learn Events
Wanted: Someone to write some PC code for controlling robot over LAN — Parallax Forums

Wanted: Someone to write some PC code for controlling robot over LAN

W9GFOW9GFO Posts: 4,010
edited 2012-03-17 00:28 in General Discussion
I need a windows (multi platform would be nice though) program that can be run on both the driver station laptop and the laptop that is on the Eddie Robot, that will transport serial data coming from the driver station Propeller Chip to the Propeller chip on the Eddie Robot. We are not using MRDS.

A simple diagram follows;

Robot_PC_Code.jpg


It seems so simple but this is out of my area of experience.

Compensation can be either via PayPal or in the form of a rare unopened black Penguin Robot. The code will also be shared for others to use - it seems like it ought to be useful.

I have had a couple people already tell me that they could do it but follow up has been non existent, so any takers, please be dependable.

Also, this *may* lead to more work in the future .
1024 x 461 - 43K

Comments

  • prof_brainoprof_braino Posts: 4,313
    edited 2012-03-15 05:56
    Is it *required* to have two PCs in the picture?
    It seems that the user station would want display capabilities to show user interface elements to the user. Does this *need* to be a PC?
    I would think that the remote end on the robot would not need the extra weight etc. Does the remote *need* to be a PC?

    I'm all about sorting out requirements BEFORE coding starts. This might be something to look at. Right now you eliminate anybody that wants to help that does not have both a pc AND a laptop to spare.

    IF you divide it up into easier, less specific parts, the more flexible parameters might attract more interest.

    For Example, your (highest level) requirements coupld be broken into:
    1) User input station - steering, engine speed
    2) User output station - camera display
    3) wireless link to remote
    4) wireless link to base
    5) robot input - motor speed, steering direction
    6) robot output - camera video stream

    This way, you have several smaller parts, and a person might be able to tackle these one at a time. Also, it leave open the "how" of the implementation. While it could end up to be two PCs this would allow more flexibility.
  • LoopyBytelooseLoopyByteloose Posts: 12,537
    edited 2012-03-15 06:20
    The whole project would be easier and cheaper in Linux (Ubuntu Linux) as you would have a lot of open source applications already developed. In Windows, you will likely find that everything has to be done from scratch - or you have to buy something.

    http://www.linuxpcrobot.org/?q=node/4

    Having said all that, if something has been developed in Python on Linux - it could easily be ported over the Python in Windows.

    And yes, you have lots of layers of network to think about. It is a big project.

    Eddie is very nice, but I am weary of MS.

    http://blogs.msdn.com/b/jodonnell/archive/2011/09/26/presenting-microsoft-s-new-robotics-reference-platform-eddie-at-maker-faire-new-york-sept-17-18.aspx
  • T ChapT Chap Posts: 4,249
    edited 2012-03-15 06:28
    I would like to recommend RealBasic, which would be easy to create builds for osx, pc, lin. I have some apps now that communicate via LAN from any platform to Propeller. Computer to computer is simple also. Each platform costs $100 for the license to be able to create builds. In many cases, no change is required between platforms, just select which platform and create the app. I know an amazing programmer for RealBasic if you want a reference.
  • W9GFOW9GFO Posts: 4,010
    edited 2012-03-15 07:58
    Is it *required* to have two PCs in the picture?
    Yes.

    The program that I need written is only to move serial data from one Propeller to the other over a local area network.
  • W9GFOW9GFO Posts: 4,010
    edited 2012-03-15 08:00
    And yes, you have lots of layers of network to think about. It is a big project.

    LAN only. My understanding is that it is NOT a big project.
  • W9GFOW9GFO Posts: 4,010
    edited 2012-03-15 08:07
    T Chap wrote: »
    I would like to recommend RealBasic, which would be easy to create builds for osx, pc, lin. I have some apps now that communicate via LAN from any platform to Propeller. Computer to computer is simple also.

    As long as it works, it doesn't matter to me in which program the code is developed.

    If I end up having to do it myself, I may look into RealBasic.
  • tonyp12tonyp12 Posts: 1,951
    edited 2012-03-15 08:27
    Do it it in C#, open up sockets on each end change the code below to redirect data to a com port.
    Use QuickSharp if you want to get up and running fast (as other advanced programs you need to create new project etc....)
    http://quicksharp.sourceforge.net/
    using System;
    using System.Net;
    using System.Net.Sockets;
    using System.Text;
    using System.Threading;
    
    
    public class SimpleTcpSrvr
    {
       public static void Main()
       {
          int recv;
          byte[] data = new byte[1024];
          IPEndPoint ipep = new IPEndPoint(IPAddress.Any,
                                 3000);
    
          Socket newsock = new
              Socket(AddressFamily.InterNetwork,
                          SocketType.Stream, ProtocolType.Tcp);
    
          newsock.Bind(ipep);
          newsock.Listen(10);
          Console.WriteLine("Waiting for wifly client...");
          Socket client = newsock.Accept();
          IPEndPoint clientep =
                       (IPEndPoint)client.RemoteEndPoint;
          Console.WriteLine("Connected with {0} at port {1}",
                          clientep.Address, clientep.Port);
    
          data = new byte[1024];
          recv = client.Receive(data); 
          Console.WriteLine(
          Encoding.ASCII.GetString(data, 0, recv)); // should be *HELLO*
          
          Thread.Sleep(100);    // pause for 1/10 of a second. 
          
          string selecttag = "\r000301018200\r"; // inventory+loop iso1800
          data = Encoding.ASCII.GetBytes(selecttag);
          client.Send(data, data.Length,
                            SocketFlags.None);          
                      
                            
          while(true)
          {
             data = new byte[1024];
             recv = client.Receive(data);
             if (recv == 0)
               break;
           
             Console.WriteLine(
                      Encoding.ASCII.GetString(data, 0, recv));
          }
          
          client.Close();
          newsock.Close();
       }
    }
    
  • ratronicratronic Posts: 1,451
    edited 2012-03-15 08:49
    W9GFO I use RobotBasic to interface my computer to the microcontroller in my robots. It is a Windows program that uses Basic to write your program. I have never used the LAN capabilitys but it has commands for that as well as for the serialports, joysticks, video etc. on your computer. Best of all it's free! Take a look through the page I linked to get an understanding of it's capabilities.

    Edit: here is a sample program that I use to read the computer's USB joystick and send the axis out the serial port and display the axis on the computer screen.
    'joystick transmitter program "rfbot3" by Dave Ratcliff 'ratronic' 7/17/11
    'use either parallax #27980 transmitter or #27982 transceiver
    SetCommPort 5,br9600   '8set com port # where parallax transmitter or transceiver is interfaced too
    loop:
      Joysticke 1,j
      x = round(j[0,0]/257)           
      y = round(j[1,0]/257)
      z = round(j[3,0]/257)
      s = round(j[2,0]/257)
      b = j[6,0]
      cs = (x+y+z+s+b) & 255
      serialout "!~#}",x,y,z,s,b,cs
      xystring 0,0,"X        =  ",x,spaces(20)
      xystring 0,40,"Y        =  ",y,spaces(20)
      xystring 0,80,"Z        =  ",z,spaces(20)
      xystring 0,120,"Slider   =  ",s,spaces(20)
      xystring 0,160,"Buttons  =  ",b,spaces(20)
    goto loop:
    
  • Oldbitcollector (Jeff)Oldbitcollector (Jeff) Posts: 8,091
    edited 2012-03-15 09:49
    I've been doing a lot of work with "Just Basic" which is the free version of "Liberty Basic" -- Setting up communication with the Propeller is painless.
    I've got some Instructable projects in the works that demonstrate how to do it.

    OBC
  • Roy ElthamRoy Eltham Posts: 3,000
    edited 2012-03-15 09:59
    If you are trying to go from prop to prop over the LAN, why not just use a Spinneret on both ends? The one on the eddie would need to be plugged into a wireless adapter...
  • W9GFOW9GFO Posts: 4,010
    edited 2012-03-15 11:20
    Having a PC on both ends is the requirement.
  • Computer Geek 101Computer Geek 101 Posts: 179
    edited 2012-03-15 11:31
    If you end up doing it yourself this is something I did similar:
    http://forums.parallax.com/showthread.php?131537-Propeller-Material-Control-and-Data-Collections

    It was written in vb.net and uses a tcp/ip thread for comms.
  • Phil Pilgrim (PhiPi)Phil Pilgrim (PhiPi) Posts: 23,514
    edited 2012-03-15 11:50
    Rich,

    Can the two PCs have a server/client relationship? IOW, one PC (the server) listens for commands and responds, while the other PC (the client) is responsible for initiating communication.

    -Phil
  • Phil Pilgrim (PhiPi)Phil Pilgrim (PhiPi) Posts: 23,514
    edited 2012-03-15 12:10
    One more question: Do the laptops have to be configured for ad hoc (peer-to-peer) wireless networking, or can they communicate through a wireless router?

    -Phil
  • xanaduxanadu Posts: 3,347
    edited 2012-03-15 12:27
    You could use tinkerproxy and serial terminals. That would work over any LAN easily.
  • W9GFOW9GFO Posts: 4,010
    edited 2012-03-15 19:49
    Rich,

    Can the two PCs have a server/client relationship? IOW, one PC (the server) listens for commands and responds, while the other PC (the client) is responsible for initiating communication.

    -Phil

    I think that would be fine.
  • W9GFOW9GFO Posts: 4,010
    edited 2012-03-15 19:50
    One more question: Do the laptops have to be configured for ad hoc (peer-to-peer) wireless networking, or can they communicate through a wireless router?

    -Phil

    I think that through a wireless router is preferred.
  • W9GFOW9GFO Posts: 4,010
    edited 2012-03-15 19:54
    I've been doing a lot of work with "Just Basic" which is the free version of "Liberty Basic" -- Setting up communication with the Propeller is painless.
    I've got some Instructable projects in the works that demonstrate how to do it.

    OBC

    An instructable would be great. I either need someone to do this for me (preferred) or some serious hand holding.
  • Chad GeorgeChad George Posts: 138
    edited 2012-03-15 20:30
    12blocks seems like it could be a good fit for you. Not exactly certain what you want to send over the LAN connection but if keeping some global variables "in-sync" with each other ... then the 12blocks model would suit your needs very well. Plus it makes development of the driver station really easy and lets you compile your final GUI interface into its own EXE.

    To be fair, there isn't currently a GUI block that will share global variables between two instances of 12blocks over TCP ... but its an interesting "use-case" ... I'm sure Hanno or I could get one working in short order if you really wanted to go that direction.
  • W9GFOW9GFO Posts: 4,010
    edited 2012-03-15 20:39
    I wasn't aware that 12blocks was used for developing PC code.
  • W9GFOW9GFO Posts: 4,010
    edited 2012-03-15 21:11
    12blocks seems like it could be a good fit for you. Not exactly certain what you want to send over the LAN connection but if keeping some global variables "in-sync" with each other ... then the 12blocks model would suit your needs very well. Plus it makes development of the driver station really easy and lets you compile your final GUI interface into its own EXE.

    To be fair, there isn't currently a GUI block that will share global variables between two instances of 12blocks over TCP ... but its an interesting "use-case" ... I'm sure Hanno or I could get one working in short order if you really wanted to go that direction.

    I see there is a Mac version. Can it compile to EXE also? An app?

    I would be happy to go with 12blocks if it can do what I need.
  • SRLMSRLM Posts: 5,045
    edited 2012-03-15 21:37
    Interesting problem! I took a quick stab at it this morning (while I was avoiding what I really need to work on) and came up with the partial solution, attached.

    I think the best program would be one that accepts over STDIN the data to transmit to the remote computer, and streams the received data from the remote computer to STDIO. This way you have the most flexibility on how to use it: you can run it stand alone to debug, or in your application you can run the program with standard stream interfaces, or you can directly pipe the input in. Your choice.

    Perhaps the best part is that the program is cross platform (windows, mac, linux, and each computer can be different) and your program that uses the data can be whatever language you choose.

    I got the idea and the base code from the book "Java After Hours". The code isn't done, but I've been able to confirm that the concept works. It should be easy enough to complete, but I just don't have the time right now. It's the end of my school quarter and a bunch of projects are due.

    Let me know if it's of any use...

    Edit: It's a client/server type setup. One of the computers must have a known IP address that the other computer can use. In the example I hardcoded localhost (127.0.0.1) so that you can run both on the same computer. The Intercom.java files are the files directly from the book, while the station.java files are the ones that I modified. To work you have to run the server first, then the client (although this could easily be fixed to have the client keep on retrying to get a connection). They compile and run just like standard Java programs.
  • W9GFOW9GFO Posts: 4,010
    edited 2012-03-15 21:51
    Thanks Cody! But umm, I think you and others are giving me too much credit. I don't know how to use your code. I can program PICs Basic Stamps and Propeller Chips, and that's all! Oh, maybe some html but that doesn't mean much.
  • SRLMSRLM Posts: 5,045
    edited 2012-03-15 23:11
    W9GFO wrote: »
    Thanks Cody! But umm, I think you and others are giving me too much credit. I don't know how to use your code. I can program PICs Basic Stamps and Propeller Chips, and that's all! Oh, maybe some html but that doesn't mean much.

    Ah, well. I can't work on it now, but probably sometime during my spring break (two weeks) I can work on it to make it efficiently usable. I think the problem statement is really interesting so it's a fun challenge to work on, and I think I too could use it for all sorts of things in the future. If you think the approach is good and are willing to wait some, then I'll go ahead and work on it in a few weeks (but let me know!).

    Just out of curiosity, what are your applications on either computer? (eg. source language) This will help evaluate what the easiest interface method is.
  • ilovepiilovepi Posts: 9
    edited 2012-03-16 14:12
    You may want to look into com0com:

    http://com0com.sourceforge.net/
  • max72max72 Posts: 1,155
    edited 2012-03-16 14:49
    Com0com looks really nice...
    From the home page: " It's also possible to use the real serial ports of remote computer like if they exist on a local computer."
    Thanks for the link,
    Massimo
  • Phil Pilgrim (PhiPi)Phil Pilgrim (PhiPi) Posts: 23,514
    edited 2012-03-16 22:16
    Rich,

    Try the attached. It's very alpha, but it might work for you. There are two programs in the zip: a server and a client. Both should be started from a DOS command line, the server first, then the client. The default IP port for the server is 12345, but you can change that to something else if you like. Just be sure that, whatever port you choose, any firewalls in the path have a hole in them for it.

    You can get instructions for each program by running it with a "help" parameter, e.g.:
    serial_server help

    Once both programs are running, anything received from one comm port gets set to the other, and vice-versa. I tried hitting it really hard with data and had some issues with the Propeller getting hung up. I'm still trying to figure out what's going on with that.

    If it works out for you, great! Consider it repayment for the MakerBot extruder you built for me, which works like a champ! :)

    -Phil
  • W9GFOW9GFO Posts: 4,010
    edited 2012-03-16 23:14
    Thanks Phil!

    It looks like just what is needed. What would I need to do to make a simple GUI for it?
  • Phil Pilgrim (PhiPi)Phil Pilgrim (PhiPi) Posts: 23,514
    edited 2012-03-17 00:28
    I 'll see what I can come up with.

    -Phil
Sign In or Register to comment.