Задани на лабораторные работы. ПРК / Professional Microsoft Robotics Developer Studio
.pdf
www.it-ebooks.info
Chapter 16: Autonomous Robots
Start External Program:
\Program Files\MRDS\bin\cf.dsshost.exe
Command-line arguments:
/p:50000 /t:50001
/m:StingerCFDriveByWire.manifest.xml
2. On the Devices tab in the Project Properties, select Pocket PC 2003 Device as the target device. The output file folder should be ProgramFiles\MRDS\bin.
3. Also on the Devices tab, turn off (uncheck) the checkbox beside “Deploy the latest version of the
.NET Compact Framework.” This will make startup faster and avoid possibly overwriting the
.NET executables on the PDA with an older version from your desktop PC. Remember that you must install the latest service pack of V2.0 on your PDA before you try to run an MRDS CF service.
4.
5.
6.
Make sure that Bluetooth is started on your PDA.
To start the debugger, right-click the cf.StingerDriveByWire project and click Debug
Start new instance from the pop-up menu. You should almost immediately see the Windows Mobile equivalent of the hourglass appear on the PDA screen. It takes a little while before a console window appears, and then even longer before the Windows Form appears.
You can set breakpoints in your code, and step through the code, just as if you were running the service locally.
When you get tired of debugging, stop the debugger in Visual Studio. This closes down the service on the PDA and cleans up. The PDA should return to the main screen. When you are satisfied that the program is working correctly, there is nothing further to do.
Setting Up the eBox
When you buy a Stinger CE it comes with an eBox-2300 Jump Start Kit. The eBox already has Windows CE installed on it. There is a large amount of documentation in the Jump Start Kit and on the RoboticsConnection website, which you should read before you begin. This chapter provides only an abbreviated version of the instructions.
Before you mount the eBox on the Stinger and deploy an MRDS service to it, there are many steps involved in setting it up properly. Therefore, this is a long section. It explains how to set up your eBox; configure the serial port; set up Visual Studio; and transfer an OS (operating system) image to the eBox.
You can use a serial-to-Bluetooth device plugged into COM1 on the eBox instead of mounting it on the Stinger. For initial testing, this might be a lot easier because you can leave the eBox on your desk with a keyboard, mouse, and monitor attached, but still test the code running directly on the eBox.
The Parani-SD100 Bluetooth Serial Adapter from Sena Technologies (www.sena.com), shown in Figure 16-12, is an excellent device. It can run off a 9V battery and it has a 100m range.
713
www.it-ebooks.info
Part IV: Robotics Hardware
Figure 16-12
You can set it up as follows:
1.
2.
Configure the SD100 serial interface for 19,2000 baud using the DIP switches.
Plug the SD100 into a COM port on your desktop PC and turn on the Stinger robot. Then run the ParaniWin software to search for the Stinger robot.
3.
4.
Lock the SD100 into Mode 1. Always connect to the same Bluetooth device.
Unplug the SD100 and plug it into your eBox on COM1. (Note that there are two COM ports on the eBox, so make sure you select the correct one.)
Once you have done this, the eBox can communicate with the Stinger via Bluetooth, but no software is required on the eBox because it is unaware of the wireless communication, thanks to the wonders of modern technology! The SD100 acts like a “hardwired” connection.
Booting the eBox for the First Time
This section explains how the boot process works under Windows CE. To some extent this is a throwback to the old days of DOS. If you have experience with DOS, then you can skim through this section. However, many younger readers might not know how the DOS boot process works.
MS-DOS is only used as a vehicle to get Windows CE up and running. If you want a turnkey system, you can set Windows CE to boot directly and avoid all of the complications outlined below.
The Boot Menu
First set up the eBox with a keyboard, mouse, monitor, and UTP Ethernet connection. It comes with a universal 5V power pack that you can plug into the mains power. (You need a suitable adapter plug outside the United States, but the voltage is not an issue).
Turn on your eBox and you should see a menu with white text on a blue background, similar to the one that follows. (This is not the infamous “blue screen of death.”)
MS-DOS 6.22 Startup Menu
========================
1.Boot CE/PC (local nk.bin with /L:1024x768x32)
2.Boot CE/PC (ether via eboot.bin with /L:1024x768x32)
3.Boot CE/PC (ether via eboot.bin with /L:800x600x32)
4.Boot CE/PC (ether via eboot.bin with /L:640x480x32)
714
www.it-ebooks.info
Chapter 16: Autonomous Robots
5.Boot CE/PC (ether via eboot.bin without display settings)
6.Boot CE/PC (Static IP: 192.168.2.232, with /L:1024x768x32)
7.Boot CE/PC (Static IP: 192.168.2.232, with /L:640x480x32)
8.Boot CE/PC (Static IP: 192.168.2.232, without display settings)
9.Clean Boot (no commands)
Enter a choice: 1
F5=Bypass startup files F8=Confirm each line of CONFIG.SYS and AUTOEXEC.BAT [N]
You can select a menu option by pressing the corresponding key number or highlighting it using the up and down arrow keys and pressing Enter. Note that there is a maximum of nine options because a single keystroke is used to make a selection.
If you don’t make a selection from the menu, it will time out and run the default option after a few seconds. To stop the countdown, press the down arrow key to highlight another menu option.
Booting Windows CE
Once you have made a selection from the menu, a program called LOADCEPC.EXE is run to boot the selected Windows CE system image. This image is usually called NK
.BIN but the name is not important. You can have several system images on the embedded hard drive.
Windows CE can be set up to boot directly; it does not require MS-DOS. This is how a production system would be configured, but for development work it is much more convenient to use MS-DOS so that you can boot different versions of the operating system and change configuration settings such as screen resolution.
The Startup menu also gives you the option to boot over the Ethernet from a desktop
PC that has Platform Builder installed on it. The eBox can obtain an IP address via
DHCP or use a static one. Remote booting is not covered here.
The last option in the menu (Clean Boot) simply drops out to MS-DOS. Used for emergency repairs, this option is not covered in the discussion that follows.
MS-DOS Refresher
If you have a background in MS-DOS, then the boot process will be familiar to you. In case you don’t remember how it works or you are unfamiliar with MS-DOS, here is a quick refresher.
When MS-DOS boots up (from the hidden files MSDOS.SYS and IO.SYS), it reads a file called CONFIG
.SYS that contains the menu, which looks like the following:
[menu]
menuitem=LOCAL_1024, Boot CE/PC (local nk.bin with /L:1024x768x32) menuitem=CEPC_1024, Boot CE/PC (ether via eboot.bin with /L:1024x768x32)
(continued)
715
www.it-ebooks.info
Part IV: Robotics Hardware
(continued)
menuitem=CEPC_800, Boot CE/PC (ether via eboot.bin with /L:800x600x32) menuitem=CEPC_640, Boot CE/PC (ether via eboot.bin with /L:640x480x32) menuitem=CEPC_xxx, Boot CE/PC (ether via eboot.bin without display settings) menuitem=IP_1024, Boot CE/PC (Static IP: 192.168.2.232, with /L:1024x768x32) REM menuitem=IP_800, Boot CE/PC (Static IP: 192.168.2.232, with /L:800x600x32) menuitem=IP_640, Boot CE/PC (Static IP: 192.168.2.232, with /L:640x480x32) menuitem=IP_xxx, Boot CE/PC (Static IP: 192.168.2.232, without display settings) menuitem=CLEAN, Clean Boot (no commands)
Rem menudefault=CEPC_1024,15 menudefault=LOCAL_1024,5 Rem menudefault=IP_1024, 5 menucolor=7,1
[LOCAL_1024]
[CEPC_1024]
[CEPC_800]
... (code deleted for brevity) ...
[IP_xxx]
[CLEAN]
[COMMON]
buffers=10,0
files=30
break=on
lastdrive=Z
dos=high,umb device=himem.sys /testmem:OFF
Note the following about the preceding code:
The file is divided into several sections by headings in square brackets. You can comment out lines in the file using REM.
Each menuitem has a name and a description. In this case, the item-specific sections of the file do not contain any code. The COMMON section at the bottom is used by all menu items. It contains MS-DOS configuration settings that are not relevant here.
The menudefault setting specifies the name of the default menu item and the timeout, which are LOCAL_1024 and 5 seconds, respectively, in the example.
When you make a selection, AUTOEXEC.BAT is executed with the name of the selected menu item passed across as the CONFIG environment variable. The AUTOEXEC.BAT looks like the following:
@echo off verify off PROMPT $p$g
REM |
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! |
|
REM |
!! NET_IP can be set to specify a static IP |
!! |
716
www.it-ebooks.info
Chapter 16: Autonomous Robots
REM !! address or left |
blank to use DHCP to obtain |
!! |
|
REM !! an IP address. |
Format of set should be: |
!! |
|
REM !! |
set NET_IP=192.168.2.232 |
!! |
|
REM !! |
|
|
!! |
REM !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
set NET_IRQ=0 set NET_IOBASE=0 set NET_IP=
if “%CONFIG%” == “LOCAL_1024” goto LOCAL_1024 if “%CONFIG%” == “CEPC_1024” goto CEPC_1024 if “%CONFIG%” == “CEPC_800” goto CEPC_800
if “%CONFIG%” == “CEPC_640” goto CEPC_640 if “%CONFIG%” == “CEPC_xxx” goto CEPC_xxx if “%CONFIG%” == “IP_1024” goto IP_1024 if “%CONFIG%” == “IP_640” goto IP_640
if “%CONFIG%” == “IP_xxx” goto IP_xxx if “%CONFIG%” == “CLEAN” goto CLEAN
:LOCAL_1024
REM #################################################################
REM |
Launch LOADCEPC using a local NK.BIN image. |
REM |
with 1024x768x32 display |
loadcepc /L:1024x768x32 nk.bin goto END
:CEPC_1024
REM #################################################################
REM Set RES=/L:1024x768x32 for use with display driver. REM
set RES=/L:1024x768x32 goto WITHRES
... (code deleted for brevity) ...
:IP_xxx
REM #################################################################
REM |
Load image without display |
setting |
REM |
Assign Static IP Address: |
192.168.2.232 |
REM |
|
|
Set NET_IP=192.168.2.232 goto NORES
:WITHRES
REM #################################################################
REM |
Here we actually Launch |
LOADCEPC |
using |
the RES, |
NET_IOBASE, |
REM |
and NET_IRQ env vars we |
just set |
above |
based on |
menu |
(continued)
717
www.it-ebooks.info
Part IV: Robotics Hardware
(continued)
REM selections.
loadcepc /e:%NET_IOBASE%:%NET_IRQ%:%NET_IP% %RES% eboot.bin goto END
:NORES
REM #################################################################
REM Load image without display settings REM
loadcepc /e:%NET_IOBASE%:%NET_IRQ%:%NET_IP% eboot.bin goto END
:CLEAN
:END
The code starts out with a series of IF statements to jump to the correct label based on the CONFIG variable. For example, LOCAL_1024 runs NK.BIN as the system image with a screen resolution of 1024 × 768. Apart from setting some parameters for screen resolution and the network, eventually LOADCEPC.EXE is executed, and from that point Windows CE takes over.
Windows CE displays the desktop, as shown in Figure 16-13. You do not need to log in.
Figure 16-13
718
www.it-ebooks.info
Chapter 16: Autonomous Robots
Windows CE includes a File Explorer, a Command Prompt, and Pocket WordPad (which you can use to edit text files). Although these applications run full-screen, they all have icons on the taskbar and you can switch between them. There is also an icon called Show Desktop at the far right of the taskbar.
Setting Up the Serial Port
The eBox uses a serial port to communicate with the Stinger robot. You have to either mount the eBox on the Stinger and connect the serial cable that is supplied or use a Bluetooth dongle such as the Sena SD100, as explained earlier. Either way, you need to set up the serial port first.
To set up the serial port, follow these steps:
1.
2.
3.
4.
5.
6.
7.
8.
Click Start
Settings
Network and Dial-up Connections.
Click File
New.
In the text box in the Make New Connection dialog box, enter COM1.
Select Direct Connection and click Next.
In the drop-down list Select a device, select Serial Cable on COM1. You can configure the port as shown in Figure 16-14 if you want, but this is not necessary.
Click Finish. An icon labeled COM1 should appear in the folder.
Click Start
Suspend. Be careful not to move the mouse as you click. The screen will go blank and the eBox will save the current settings.
Move the mouse or press a key to wake up the eBox.
Figure 16-14
719
www.it-ebooks.info
Part IV: Robotics Hardware
Once you have your eBox set up correctly, you can mount it on the Stinger as per the instructions. You need to remove the Bluetooth module from the Stinger and replace it with the standard serial (RS-232) module that came with the Stinger CE. Plug the serial cable into the serial module and the other end into COM1 on the eBox.
Alternatively, if you have a Bluetooth Serial Adapter for your eBox, then you don’t need to swap out the Bluetooth module on the Stinger.
Setting Up Visual Studio
If you want to develop services for the eBox, then you need to install a lot of software on your development PC. This software comes with the eBox on CD or it can be downloaded from the RoboticsConnection website. After this, you need to establish a connection to the eBox. The following sections outline software requirements and then provide the steps for establishing a connection.
Software Requirements
The following is a list of software that you need to install to build your services:
Platform Builder: This is a plug-in for Visual Studio. An evaluation version is supplied on CD, but you must first go to the Microsoft Windows Embedded website (www.microsoft.com/ windows/embedded/default.mspx) to obtain a license key. Platform Builder can be used to build Windows CE system images. It can also compile C++ code to produce “native” executables and device drivers (using Embedded Visual C++). However, MRDS uses .NET so the Platform Builder is not needed for compiling code.
You must have Visual Studio 2005 Service Pack 1 installed before you install Platform Builder.
When you run the Platform Builder installation, you must make sure that you select X86 support because the eBox is an X86 platform but only ARM processor support is selected by default.
Board Support Package (BSP): Once you have Platform Builder installed, install the Board Support Package (BSP) for the eBox. A BSP includes the necessary definitions and device drivers to support a particular hardware implementation of an embedded PC. This is available as ICOP_ eBox2300_60B_BSP.msi.
Windows CE SDK: This defines the development environment and a device type that you can use to connect to the eBox over the Ethernet. The installation package is called eBox2300_WinCE600_SDK.msi.
CoreCon component: This is used for communicating with the eBox. It effectively replaces ActiveSync, which you use with a PDA. The package you need to install is called
CoreCon_x86_VS2005.msi.
720
www.it-ebooks.info
Chapter 16: Autonomous Robots
Check the Windows folder on your eBox to confirm that the CoreCon files are there. (They should have been included in the system image that is already on the eBox). You should find two programs: ConmanClient2.exe and CMAccept.exe. If you can’t find these files, you should be able to find them on your development PC using the following path: C:\Program Files\Common Files\Microsoft Shared\CoreCon\1.0\Target\wce400\x86. The necessary files are as follows:
Clientshutdown.exe
ConmanClient2.exe
CMaccept.exe
eDbgTL.dll
TcpConnectionA.dll
Unless you have these files, you will not be able to connect to your eBox remotely. They perform the equivalent function that ActiveSync provides for a PDA. You have to transfer them to the eBox using a flash drive or CF card (see “Transferring Files,” below).
When you are debugging a service on a PDA, if you look in the Remote Process Viewer you will see the equivalent Connection Manager client running on the PDA, but this is not relevant here.
Establishing a Connection to eBox
When you have all of this software installed, open the StingerDriveByWire service in Visual Studio so that you can establish a connection to the eBox. The steps are similar to those for a PDA:
1.
2.
3.
4.
5.
6.
Make sure your eBox is connected to the Ethernet and boot it up. It has a UTP connection on the back.
On the eBox, open a Command Prompt window and use the ipconfig command to determine the IP address of the eBox. You might want to double-check that the network connection is working and that you have the necessary access by pinging the eBox from your desktop PC. It might be necessary to disable the firewall on your desktop PC to enable communication with the eBox.
Click the cf.StingerDriveByWire project in the Visual Studio Solution Explorer panel to ensure that it is the currently selected project.
If you don’t already have the Device toolbar displayed, then click View
Toolbars
Device. (Refer to Figure 16-15, which shows the Device toolbar at the top left side.)
In the Target Device drop-down list in the Device toolbar, select “eBox2300_WinCE600_SDK x86 Device.” (This device will not appear unless you installed the SDK.)
Click the Device Options icon, which is called out in Figure 16-15 (the second icon to the right of the target device).
721
www.it-ebooks.info
Part IV: Robotics Hardware
Connect to |
Device |
|
device icon |
options icon |
Device toolbar |
Options dialog
Device Properties dialog
Configure
TCP/IP
Transport
Figure 16-15
7.
8.
9.
10.
As shown in Figure 16-15, you must select the eBox-2300 in the Options dialog. Then click Properties and click Configure in the Device Properties dialog to finally get to the Configure TCP/IP Transport dialog, where you can enter the IP address of the eBox. Close all the dialogs by clicking OK on each of them.
To connect to the eBox, run the CoreCon client on the eBox. Open File Explorer on the eBox and change to the Windows directory. Double-click ConmanClient2 and then CMAccept to run them.
Alternatively, there is a batch file called CoreCon.cmd in the ProMRDS\CF folder. This contains the following commands:
cd \Windows
start ConmanClient2
start CMAccept
Note the use of the start command, which starts the programs in the background.
Back in Visual Studio, click the “connect to device” icon, which is just to the right of the device list. (It looks like a PDA with a power plug attached). A dialog box will appear and after a short delay it should indicate that the connection was successful, as shown in Figure 16-16.
You can now click Target
Remote Tools to run the various remote tools that are included with Visual Studio. (Refer to back Figure 16-10 for a list of the available Remote Tools).
722
