Requirements

Demo

Using the Code

Create a MRDS Service and add the partners - NxtDrive and NxtBattery. This will automatically declare and instantiate an object for BatteryOperations and an object for DriveOperations. Please add one more for DriveOperations as the code mentioned below:

Change the MRDS Service in such a way that it implements this interface. Values for all the properties but the first property (GearPower) will be set in the service, and they will be retrieved and used in the UI layer.

Now, add a new WPF project. Declare a property named Service of type IMyLegoCarService, and add a constructor, something like this:

This constructor should be called from the Service’s constructor, so that the service and the UI will be on the same thread. Here “brsr_ipcamera” is the web browser control to display the ip camera’s image/video (in my case my iphone). I added an HTML page to my webserver displaying only the video from the camera. Add a timer control to display the information retrieved from the service periodically. Here I’ve used WPF Dashboard Controls’ dial controls as speedometers (for left motor front, left motor reverse, right motor front and right motor reverse), odometer control as odometer and progress bar control as fuel gauge. Left/Right Power Current properties were used to initialize the speedometers. Left/Right Encoder properties were used to initialize the odometer, these properties basically give us the degrees that the servo motors rotated. Using the formula: distance = Convert.ToInt32(Math.Abs(currentEncoderCurrent) / 360 * 2 * 3.14 * 0.75, we can calculate the distance covered. Here, pi = 3.14 and 0.75 is the radius of the wheels.

Coming back to the service. Declare and/or instantiate the following classes:

Comments and Discussions

There are a few hoops you have to jump through to set up an MRDS project to interact with a WPF window. There is no project type for this in Visual Studio. Wiring it up is not hard, but it's hard to remember all the little details.

Awhile back I put some boilerplate code on my blog, mostly for my own use, which I refer back to when starting a new project. Maybe I'll document it and post it on CodeProject if there is enough interest.

I followed your tutorial to get be able to use WPF with my Lego mindstorm nxt 2.0. The problem I am having is that the WPF form doesn't display, the robot connects and I can view the information in the browser (about the robots state). I tried adding breakpoints to see what was going on and it seems that the Spawn Iterator Task wasn't even being called. Can you help me? I am using MRDS 4 beta 2 and the latest WPF.

Hey gokulnathm;I am trying to use the Visual Basic 2008 Studio Interface I created for experimentation with the Robot NXT 2.0 instead of using the MRDS interface like you created. Could you help with me with this? I understand what you did, and the one thing different between the project I am trying to accomplish and the project you accomplished is the interface. I am doing this for a school project.This is my blueprint of the project: Hardware: *Laptop and Bluetooth adapter *Lego Mindstorms Robot NXT 2.0 Software: *Visual Studio 2008(with visual basic)*Microsoft Robotic Developer Studio Interface & Action Plan: Warning Panel- Bluetooth is Online or OfflineCommand Panel-Left button\Right button\Forward button\Backward button

Try mindsqualls.net, it is a .NET library which can be used with any .NET programming languages to control nxt. I initially tried it, and due to various reasons I moved to MRDS. Learning MRDS might take some time, but once you are comfortable with it you can do a lot compared to any other library.

I'm very new at all this. I just got an assignment from school to work with the lego NTX robot.
We just need to make a remote in visual studio but I want it to do something more. I want to make a bluethooth connection between the NXT and a laptop who gets his orders from another computer threw skype. And if I have anytime left (an if I can do it). I would set-up a cellphone on the robot that transmit his cameraview to the laptop and then via skype to the other pc. So your article comes very in handy. And like you said there's almost no information on the web. If you have any tips or other sources that would come in handy, please tell me

Thanks for the comments ! seems to be an interesting project !! I think sending commands to the bot via skype should not be difficult, this article might be helpful http://www.codeproject.com/KB/cs/SkypeBot.aspx. Streaming the camera to the laptop is straight forward, whereas streaming to another pc via skype might be difficult, good luck with it! Feel free to contact me if you need any help.