Remoting and Robotics

P

Padu

Hi,

I'm developing a remote control panel for a mobile robot I'm developing. The
robot carries a PC that runs a C# app to control the platform. The robot's
PC has a wi-fi card. I'm not concerned with range issues now.

Now I want to create an application that will reside on my laptop that will
send commands to the robot (go forward, brake, pan, tilt, get me a gps fix,
etc) and will receive information messages (gps fix, a bitmap image, sensor
reading, etc).

I'm new to .net development, so I was about to start using direct TCP/IP
sockets when someone told me that remoting would be much easier. I'm
studying it right now.

Now I come here to ask you about what options would be best in this
environment. Keeping in mind the following considerations:

- Access rights and network safety is of no concern
- Performance is a mild concern
- Scalability is of no concern

Also make the other usual assumptions of a robotic environment vs. a
business environment.

Cheers

Padu
 
N

Nicholas Paldino [.NET/C# MVP]

Padu,

Since access rights and network safety is not a concern, nor is
scalability, and performance is a mild concern, I would ABSOLUTELY go with
remoting.

The reason for this is that remoting doesn't offer anything in terms of
safety and access rights, and is reasonably performant when using the tcp/ip
channel along with binary formatting.

However, I would say that generally, the rules of distributed computing
still apply, where you should make "chunky" calls as opposed to, well,
"not-chunky" calls.

Hope this helps.
 
M

Mehdi

I'm developing a remote control panel for a mobile robot I'm developing. The
robot carries a PC that runs a C# app to control the platform. The robot's
PC has a wi-fi card. I'm not concerned with range issues now.

Now I want to create an application that will reside on my laptop that will
send commands to the robot (go forward, brake, pan, tilt, get me a gps fix,
etc) and will receive information messages (gps fix, a bitmap image, sensor
reading, etc).

I'm new to .net development, so I was about to start using direct TCP/IP
sockets when someone told me that remoting would be much easier. I'm
studying it right now.

Now I come here to ask you about what options would be best in this
environment.

..NET remoting would definitely be the best tool to use here. It will allow
to develop your application in no time and adding new commands later on if
necessary will be as easy as adding a new method to a class. Performances
should not really be an issue. You should keep in mind that .NET Remoting
is a .NET only technology though so if you'd like to be able to control
your robot via, say, a Java application or a native Linux C++ application,
then you should stick with the good old sockets.

To do what you want to do in .NET Remoting, you'll have to:
- define an interface containing the command that you want to send to your
robot. E.g GoForward(int distance), Tilt(int degrees)....
- place this interface in a DLL referenced by both the server application
(on the robot) and the client application (on your laptop)
- implement this interface in the server application then expose the
created class via .NET remoting (2 or 3 lines of code for that)
- in the client application, connect to the server, get a reference to the
remote object (2 or 3 lines of code too), then calls its methods as if it
was a normal local object

There are several tutorials on the web that will get you started. Of
course, there will be a few rough edges. To send an image, you won't be
able to simply pass a Bitmap object as a parameter as you would do with
many other types. You'll have to convert your image into a byte array
first. But there is code on the web that you can copy/paste to do that.
Sending events from your robot back to your client application also isn't
that an intuitive thing to implement but once again, there are many
examples on the web.
 
M

Matt

You may want to take a look at Microsoft's new Robotics Studio at http://www.microsoft.com/downloads/...3e-36a4-46be-ad36-01bcfbfb4969&DisplayLang=en

Matt
Hi,

I'm developing a remote control panel for a mobile robot I'm developing. The
robot carries a PC that runs a C# app to control the platform. The robot's
PC has a wi-fi card. I'm not concerned with range issues now.

Now I want to create an application that will reside on my laptop that will
send commands to the robot (go forward, brake, pan, tilt, get me a gps fix,
etc) and will receive information messages (gps fix, a bitmap image, sensor
reading, etc).

I'm new to .net development, so I was about to start using direct TCP/IP
sockets when someone told me that remoting would be much easier. I'm
studying it right now.

Now I come here to ask you about what options would be best in this
environment. Keeping in mind the following considerations:

- Access rights and network safety is of no concern
- Performance is a mild concern
- Scalability is of no concern

Also make the other usual assumptions of a robotic environment vs. a
business environment.

Cheers

Padu
 
G

Greg Young

I disagree with the others here .. I think a connection based protocol will
not work well for you.

I think you should look at implementing a simple UDP based protocol that
doesn't mind packet loss. With a connection based protocol you will often
have your controls go completely dead if it hits an off spot or sits on the
edge of its connection. A UDP based protocol is very simple to create
(especially just to tell it to do actions). More importantly if it hits a
bad spot it might miss a packet or two but it will keep on trucking.
http://msdn.microsoft.com/msdnmag/issues/06/02/UDP/ is worth a read.

Here is some simple client/sending code but it is literally about 15 lines
of code (the receiver being most of it .. the sending side is pretty much
UdpCLient.Send()

using System;
using System.Text;
using System.Net;
using System.Net.Sockets;
class Receiver {
static void Main(string[] args) {
UdpClient client = new UdpClient(1111);
IPEndPoint point = null;
while(true) {
byte[] data = client.Receive(ref point);
if (data.Length > 0) {
Console.WriteLine("Received " + data.Length + " bytes
from " + point.Address);
Console.WriteLine ("\t" +
Encoding.ASCII.GetString(data));
}
}
}
}


Cheers,

Greg Young
MVP - C#
http://codebetter.com/blogs/gregyoung
 
P

Padu

I've just finished my first remoting "hello world" app. Instead of using
console apps, I've created windows forms for both host and client apps. I'm
not sure I've completely understood the concept though.

Following the help file "how to", I've created a remotable type that
inherits from MarshalByRefObj, and has only one method:

public class RemotableType: MarshalByRefObject
{
public string HelloWorld()
{
return "Hello World";
}
}

I've compiled it into RemotableType.dll


Then I've created the host app in a windows form:

public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
private void button1_Click(object sender, EventArgs e)
{
RemotingConfiguration.Configure(@"RemotingHost.exe.config.xml",false);
}
}

The config.xml I've copied from C# help. It is defined as a wellknown
singleton, uses http on port 8989.


Finally the client windows form app has two buttons, a "connect" (now I
understand that it doesnt connect really) and a "Get Hello World":

public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
private RemotableType remoteObject;
private void button2_Click(object sender, EventArgs e)
{
label1.Text = remoteObject.HelloWorld();
}
private void button1_Click(object sender, EventArgs e)
{
RemotingConfiguration.Configure(@"RemotingClient.exe.config.xml",
false);
remoteObject = new RemotableType();
}
}


It all works, both on the same machine or in different machines.

Now, let's say I add a text box to the host application main form. What do I
have to do to add a method that retrieves the value of that text box from
the client app? I know I'll have to add another method to my RemotableType,
but I'm not sure how the dll will access the host windows form app. I
suspect I'm incurring in a major concept flaw here.


Cheers

Padu
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top