Tutorials to .com

Tutorials to .com » Os » Mobile » Robot which can give you inspiration?

Robot which can give you inspiration?

Print View , by: iSee ,Total views: 27 ,Word Count: 3994 ,Date: Mon, 15 Jun 2009 Time: 8:49 AM

Robot which can give you inspiration? Contents

I WiMo

Bluetooth WiMo respected

House WiMo text

Will be left on the tires ...

Electric eye WiMo

WiMoFi

Will the dream WiMo electronic sheep?

Robot which can give you inspiration? If you are interested in one of the best television programs, may be thinking: "ah, it may inspire me how to regulate their own speech and deportment, to be trounced opponents." However, if you have obsessed with the best in the world mobile operating system, may be thinking: "ah, it may inspire me how to programmatically take pictures, use SMS as a data channel, through Bluetooth or WiFi to send data, as well as play songs in the course of the points received notice. "I can not help you will be trounced opponents. However, if you are interested in the content of others, please continue reading.

Although I am engaged in software development at Microsoft has more than fourteen years, but I was the first professional hardware design engineers. I was graduated from the Electrical engineering degree, so early in his career, I am in the design of mainframe. At that time, we must manually with logic gates - not those who think that they are great young people to use the Verilog high-level tools (we have to walk in the fog in a few kilometers to work, but also uphill. We are from very difficult. But we never).

However, such a situation to my friend and colleague Brian Cross is concerned, on a completely different. Whether it is the past, now and in the future, Brian is a true software experts. His entire career were spent at Microsoft for c # as proficient in English, like (it is Brian - of course, Charles Petzold - introduced me to the magic of the managed code). However, Brian is an expert to build a robot, so this for me a bit of irony.

You may have heard of WiMo - Brian build a Windows Mobile ®-based robot, shown in Figure 1 of its icons. WiMo is fully programmable robot that not only electrical engineers can build, so a certain degree of visibility. Brian from the traditional Microsoft point of view, the whole issue as a software problem. In short, you can use Windows Mobile phones and some Lego can build a functioning WiMo, does not require any soldering iron.

Robot which can give you inspiration?

Figure 1 WiMo of the art show

Although they may be very easy to build, but the theme of this column is the mobile development, not robotics. Therefore, today's column is not to discuss how to actually build WiMo, but to introduce executable code base WiMo part of the operation, and discuss how these operations will be applied to mobile applications. If you get the inspiration from this article, you can use the phone to achieve some truly extraordinary operation, so much the better.

First of all important matters to deal with. WiMo by the motor and is basically a simple combination of sensors, mainly for carrying Windows Mobile devices to act as its brain. All the actual work completed by telephone, and the implementation of this work can be all the code WiMo site (wimobot.com) free of charge. If you are interested in building a WiMo, you may want to go to the following link WiMo Construction (wimobot.com / Building.aspx). However, if you only interested in the source code, go to wimobot.com / SourceCode.aspx. We will use up a lot of time to explain this source code, so you may wish to download now.

Please download. I look forward to.

What is that? Yes, need to click disclaimers statement that Brian If you are using the technology to build the machine, but the producers eventually turned into Brian, you do not prosecute Brian. This situation will never happen. Please be assured that we have.

Extract the code, in Visual Studio ® to open the file in WiMo.sln. xml documents do not mind the error; WiMo attractive reason, one of the reasons why Brian is to allow developers "can do anything" rather than Brian's, "We do not consider there is no appropriate test plan issued in terms of" guidelines for corporate packages . WiMo.sln contains a large number of projects, but should be open WiMo projects Form1.cs file. In that document, you can learn in this solution for many of the more meaningful definition of the type of usage.

Bluetooth WiMo respected

WiMo part of the Windows Mobile via Bluetooth to communicate the wheels and sensors. Simmer with laughter it is, Brian chose this connection because he was worried that in trying to wire soldered to the phone when he accidentally destroyed telephone. Do better, because you can now upgrade this code for use in non-robot Affairs. If you want to find a more authoritative source of the source code, you can find from MSDN ® Bluetooth sample at msdn.microsoft.com/embedded/aa714519. However, you will find categories and WiMo Bluetooth MSDN, there are many similarities between the examples.

Most Windows Mobile phones support Bluetooth, the phone if you use Microsoft ® Bluetooth stack (Unfortunately, some phones do not support), WiMo code can be run in its normal. Bluetooth is commonly used, so if you want to prepare an application for telephone communications with the nearby and use Bluetooth as the communication channel more reasonable.

Robot which can give you inspiration?

WiMo brain - Telephone

Now assume that you have from the MSDN example WiMo or copy the Bluetooth category, and has phone and called the "MyDevice" even in the equipment, together with the equipment connected to the code are as follows:

using Microsoft.WindowsMobile.SharedSource.Bluetooth;
BluetoothRadio radio = new BluetoothRadio();
NetworkStream bthStream = null;
foreach (BluetoothDevice device in radio.PairedDevices) {
if (device.Name == "MyDevice") {
try {
bthStream =
device.Connect(StandardServices.SerialPortServiceGuid);
}
catch (SocketException) {
// do error recovery stuff here
}
break;
}
}

In this way, you will receive the standard NetworkStream, and bthStream.Read can make use of bthStream.Write send and receive data. The same simple principle, you can now make calls via Bluetooth. As long as phones can run two applications that you, and you also hope that they communicate with each other, it can be applied to the above-mentioned technology. But there are many other possibilities.

This is with all of the Bluetooth device serial call of the basic method call. For example, if you want to connect to Bluetooth-enabled GPS components, it can perform very similar operations. WiMo blog posting of a person mentioned that he had used similar code from a Bluetooth enabled car engine performance data collected. Lego Mindstorms using Bluetooth technology, this is the Lego version of WiMo works. If you do not exclude a small area of welding, can be inexpensive Bluetooth modem to connect to any serial device. (Brian in WiMo site "to build WiMo need to purchase hardware" section describes the relevant details.) World on a variety of sensors available, you can connect it to any one of a modem. As a mobile developer, as long as data can be delivered to the phone, you will know how to deal with these data. Data delivered to the phone has been a big problem, this is not a.

House WiMo text

Because the brain is a WiMo phone, it can receive from a variety of different sources of order, including SMS. This means that, WiMo can receive from the majority of the planet, as well as Windows Mobile phones or other communications equipment orders, and even with the support of desktop messaging IM client to talk. (Windows Live ™ Messenger is one of them.)

MessageInterceptor category from this process to deal with, such DesktopSms.cs in the WiMo document will be used. This file is located under WiMo.Common.Device in MSDN also has a complete record at go.microsoft.com / fwlink /? LinkId = 120888. MessageInterceptor basically means that "Whenever the phone to receive text messages with these conditions, the will send it to my application." If an application is not running, you can even use MessageInterceptor start it.

With C++ # in most cases, the news listening is easy to achieve. Figure 2 shows the basic code you need.

Robot which can give you inspiration? Figure 2 Message Listener

using Microsoft.WindowsMobile.PocketOutlook;
using Microsoft.WindowsMobile.PocketOutlook.MessageInterception;
const string smsCommandId = "MyAppName";
const string smsComparisonValue = "MyAppSmsIdentfier";
MessageInterceptor intercept =
new MessageInterceptor(InterceptionAction.NotifyAndDelete);
intercept.MessageCondition = new MessageCondition();
intercept.MessageCondition.CaseSensitive = true;
intercept.MessageCondition.ComparisonType =
MessagePropertyComparisonType.StartsWith;
intercept.MessageCondition.ComparisonValue = smsComparisonValue;
intercept.EnableApplicationLauncher(smsCommandId);
intercept.MessageReceived +=
new MessageInterceptorEventHandler(intercept_MessageReceived);
void intercept_MessageReceived(object sender,
MessageInterceptorEventArgs e) {
if (e.Message is SmsMessage) {
SmsMessage sms = (SmsMessage)e.Message;
// sms.Body contains the text of the message we received
}
}
using Microsoft.WindowsMobile.PocketOutlook;
using Microsoft.WindowsMobile.PocketOutlook.MessageInterception;
const string smsCommandId = "MyAppName";
const string smsComparisonValue = "MyAppSmsIdentfier";
MessageInterceptor intercept =
new MessageInterceptor(InterceptionAction.NotifyAndDelete);
intercept.MessageCondition = new MessageCondition();
intercept.MessageCondition.CaseSensitive = true;
intercept.MessageCondition.ComparisonType =
MessagePropertyComparisonType.StartsWith;
intercept.MessageCondition.ComparisonValue = smsComparisonValue;
intercept.EnableApplicationLauncher(smsCommandId);
intercept.MessageReceived +=
new MessageInterceptorEventHandler(intercept_MessageReceived);
void intercept_MessageReceived(object sender,
MessageInterceptorEventArgs e) {
if (e.Message is SmsMessage) {
SmsMessage sms = (SmsMessage)e.Message;
// sms.Body contains the text of the message we received
}
}

You may think that only a brief e-mail messages, but through the above-mentioned categories, you can SMS for a complete data channel. Based on the assumption that the preparation of a round-based games (such as Chess or Chess super exciting version of the Japanese Shogi), in which send and receive text messages through mobile information.

Or assume that your phone has a remote configuration application. Do you often misplaced phone? (I bet you it will be with the car key into the side.) You can log on to the IM client, to send voice commands to play is "Hey, Mike, I am here," the WAV file. (However, let me know the location of your phone on a bit absurd.) Or, if you want fashion and should be replaced by the contents of telephone voice "WiMo 5 still alive!" No one could understand the joke, but it is it is a reflection of the attractiveness.

Will be left on the tires ...

This is a bit difficult for me, but ... how to put it? Yes, WiMo will jump Hokey Pokey dance. Yes, I said so. Just as the three rules of robotics, this is actually the protection of human beings. If WiMo evolution to be able to take up arms and said, "Sorry, Brian, I am afraid I can from life", Brian will answer "WiMo, dance!" Then, afterHokey Pokey dance, WiMo will be back in a corner and pretend there have never been so many unpleasant things.

I would not suggest the preparation of your interaction with the Hokey Pokey the Windows Mobile application code, but some of the songs point to be notified is a good idea. WiMo Hokey Pokey to reveal the actual infrastructure is cool.

I am talking about is a Windows Mobile infrastructure and to inform the agent state (SNAPI). Microsoft.WindowsMobile.Status hosted version of its name is located in space, you really should pay attention to is the SystemState.

SystemState other relevant details, go.microsoft.com / fwlink /? LinkId = 120893 to provide a good resource. SystemState click the link attribute. Be able to see whether you can access the system contains about 100 attributes of the list? For example, signal strength, battery level, Bluetooth status, the user is using phone calls as well as equipment such as telephone numbers? How will you use this wealth of access? Wise use. As long as a value which changes have taken place, SNAPI will be issued a notice to you. Even when you choose to change the value, but not run-time application, it can activate the application.

Occurrence of each attribute MediaPlayerTrackTimeElapsed changes, WiMo will be notified and began to dance. It is aware of the songs do at each time point, and make the corresponding action. The following is the relevant code:

using Microsoft.WindowsMobile.Status;
SystemState mediaTimeElapsed =
new SystemState(SystemProperty.MediaPlayerTrackTimeElapsed);
mediaTimeElapsed.Changed +=
new ChangeEventHandler(mediaTimeElapsed_Changed);
void mediaTimeElapsed_Changed(object sender, ChangeEventArgs args) {
int time = (int)args.NewValue;
// Do something with the new value
}
using Microsoft.WindowsMobile.Status;
SystemState mediaTimeElapsed =
new SystemState(SystemProperty.MediaPlayerTrackTimeElapsed);
mediaTimeElapsed.Changed +=
new ChangeEventHandler(mediaTimeElapsed_Changed);
void mediaTimeElapsed_Changed(object sender, ChangeEventArgs args) {
int time = (int)args.NewValue;
// Do something with the new value
}

If you want a state in which the changes occurred to start the application process, please refer to the SystemState method EnableApplicationLauncher. Which includes Form1.cs in the main operation in the implementation of the code WiMo.

Electric eye WiMo

Today, the vast majority of mobile phones are equipped with cameras, WiMo to make full use of its brain a built-in camera. WiMo part in the fixed telephone is located in a motor connected with the disk. WiMo one can do is rotate the camera at the telephone in order to enable you to take photographs, and then rotating the phone back to the original point of view, so you can see the phone screen. This phone can also serve as a basic video camera, you can use it to remote control WiMo, and can see that it is "see" the target.

In Windows Mobile 5.0 (WiMo production basis), the camera API there are some restrictions. It has not hosted interface, and the computer interface is the focus for shooting still images and save to memory card and set up. Use it as a video camera, the frame rate depends on the storage device image and from the memory card in the speed of image retrieval. No one thinks that this effect is desirable, but it can really work.

However, there are also some advantages. First of all, if you had hoped that the preparation of the application from the Trust to call the local DLL, WiMo will provide a perfect example of the preparation. Show WiMoNative item, and then view the solution WiMo the rest of this project is how to interact. If you have managed code in pInvoked from some of the content has been successful by half. Prepared to call your DLL is to export the functions you call platform. For example, see Camera.cs under Wimo.Common.Device at the end of document. Which contains a statement calling the following two platforms:

[DllImport("WiMoNative.dll")]
private static extern int OpenCamera(int id, ref IntPtr hCamera);
[DllImport("WiMoNative.dll")]
private static extern int CloseCamera(IntPtr hCamera);

The following is the same function of the local WiMoNative.cpp statement:

HRESULT OpenCamera(DWORD dwResolutionId, HANDLE* hCamera);
HRESULT CloseCamera(HANDLE hCamera);

In addition, WiMoNative.cpp very likely that you have ever seen most of the DirectShow briefly. OpenCamera filter function can build graphics, and in about 60 lines of code in the appropriate pin articulated. Over the years, in order to understand the working principle of DirectShow, I have a number of experts for advice. But each time my eyes are not up to five minutes. But on the code, I think there is nothing more than step by step analysis of a pure sample of the more meaningful.

The advent of WiMo is Brian announced, "I want to learn new things. I will deal with the electronics to produce a robot." As a starting point. But this is only half the story. Brian also said, "These are the Windows Mobile Managed Classes I prepared. I should do something to show how to use them." WiMo If you feel exhausted almost all the world's technology, is no exaggeration. This is the intentional.

TCP / IP is one of a technical. WiMo can with the desktop PC through WiFi communications, WiFi and wired Ethernet connections using the same hosting TcpClient. This code is located under Wimo.Common in WimoNetTcp.cs. TcpClient the MSDN page on the address is msdn.microsoft.com / system.net.sockets.tcpclient.

Through the TCP communication and similar communication via Bluetooth. First of all, to connect, and then use NetworkStream to send and receive data. If you want to connect to the server, it is very simple, the code is as follows:

using System.Net.Sockets;
using System.Net;
const string myServer = "www.myserver.com";
const int myPort = 11000;
TcpClient client = new TcpClient();
client.Connect(myServer, myPort);
NetworkStream stream = client.GetStream();
// From here you can call the stream.Read and stream.Write APIs
stream.Close();
using System.Net.Sockets;
using System.Net;
const string myServer = "www.myserver.com";
const int myPort = 11000;
TcpClient client = new TcpClient();
client.Connect(myServer, myPort);
NetworkStream stream = client.GetStream();
// From here you can call the stream.Read and stream.Write APIs
stream.Close();

If you want to communicate with another device, you can use the IP address using host name instead of the client.Connect version. Of course, you also need a way to access the remote computer's IP address. However, to obtain her address is very easy. For example, suppose you need to own IPv4 address.

string myHostName = Dns.GetHostName();
IPHostEntry hostEntry = Dns.GetHostEntry(myHostName);
foreach (IPAddress ip in hostEntry.AddressList) {
if (ip.AddressFamily == AddressFamily.InterNetwork) {
// ip is the IPv4 address
}
}

If you want to prepare an application to enable it to TCP and the other through the same phone communication applications, it can get your IP address, send it via SMS to another phone, and then let it use the IP phone address to establish a connection with you. To do this, you can see the type of TcpListener at msdn.microsoft.com / system.net.sockets.tcplistener. The idea of more or less as follows:

TcpListener listener =
new TcpListener(IPAddress.Any, port);
listener.Start();
TcpClient client = listener.AcceptTcpClient();
listener.Stop();

This is a TCP / IP for a brief overview, but I believe it is sufficient follow-up allows you to perform the operation.

Will the dream WiMo electronic sheep?

WiMo a lot of the basic code, introduced here only a small part. WiMo is actually a group of robots, from a large number of different wheel and sensor module. WiMo early use of the robot parts (motors, micro-controller and the circuit board) to build from. But the WiMo into the other elements, including large trucks and remote control of Lego Mindstorms. Currently, Brian is studying how the Roomba vacuum cleaner into WiMo (you can find in the source code of the beginning of the code). Which contains a large amount of base used to extract these different types of short codes, as well as with low-cost micro-controller to communicate useful information.

I write this column is designed to introduce some in the development of Windows Mobile applications using the technology. However, if you want to know more about some of the relevant content, and do not flinch. If you would like to e-learning in-depth study, even if you do not understand the inductors and capacitors distinction between, WiMo is a good starter kit. What should be the purchase of components from how to be articulated together, and then how to write code and its interaction, Wimobot site will provide you with all the necessary steps.

If you can dance the Hokey Pokey dance equipment are not interested in, you still have a great choice. A typical Windows Mobile phone hardware used in all aspects of Microsoft than I am just starting to use the PC at best. Its faster processor, RAM bigger and bigger storage space, higher screen resolution, and can carry.

Do you use Windows Mobile 6 device to replace the Windows Mobile 5.0 device? WM5 device you are using right now? You are likely to disable a cell phone service, but other services should still be able to function properly. If this is the case, you wasted a fully programmable mobile computer - you should use it to do. The production of the robot. The production of security cameras (WiMo photographs and pictures can be sent to the PC, and this process does not require any wheels or sensor). Use Bluetooth to build or purchase a "weather station", and then use your phone to collect and analyze the data. Even started to look Astromech Droid. ( "WiMo, to keep up with.")

I think that the "sky is the limits", but this too ... narrow. If you read this part, you may be an engineer. You can carry out any work - as long as you take the first step. WiMo and I hope this column will bring you inspiration so you can use Windows Mobile devices to achieve a number of exciting features. I wish you a happy coding.


Mobile OS Articles


Can't Find What You're Looking For?


Rating: Not yet rated

Comments

No comments posted.