MCS was written in C++ using VC.Net. The program is mainly tested on Windows XP/2000, although it should work with other version of Windows as well.
The application requires Intel OpenCV library and mfc71.dll and msvcr71.dll. All of these files are included in the binary release zip file.
This figure shows a typical setup for MCS. MCS is started on the same machine with ER1 robot control center (RCC) and hold control of the camera(s) on the robot. On a remote computer, user run a client software to connect to the MCS and RCC on two different ports. To get a image, the client send a request to MCS. Upon this request, MCS capture an image from the specified camera device and send back to client in raw RGB format. For more detail of this protocol, see the MC protocol bellow. The processing unit then processes the image and can issue new action to robot via RCC connection or request another image.
To run MCS together with RCC, do the following steps:
Known bugs: the program may work undesirable when the computer switch to standby mode. Most of the time, you can fix problem simply by restart the server (click on 'Stop' and then 'Start' again).
This chapter is for developers who want to write their own client software to work with MCS or want to rebuild/improve the MCS. General users may want to skip to chapter 6 to learn to use our SDK.
This protocol was designed to run efficient on a reliable network. It has very limited mechanism to detect and correct communication data corruption. However, for our research purpose, this does not create any serious problem.
The MC server/client work on request-response basic. All messages, except the image package, are simply a 4-byte opcode; this can be considered as 32bit unsigned interger, sending in 'native' mode (no swapping). The 'image package' contain the opcode MCOP_IMAGE, followed by image header and data.
MCOP_ACCEPT 0x00080000 MCOP_REJECT 0x00100000 MCOP_SHUTDOWN 0x00800000 MCOP_PING 0x00200000 MCOP_IMAGE 0x00020000 MCOP_NOIMAGE 0x00040000 | SRC_status which SRC_status are: SRC_NOT_READY 0x0001 SRC_ERROR 0x0002Client side:
MCOP_QUERY 0x00010000 | the video source index MCOP_DISCONNECT 0x00400000 MCOP_PING 0x00200000
< MCOP_IMAGE> < width> < height> < depth> < nchannel> < origin> < datasize> < data> < 4 bytes > < 4bytes> < 4bytes> < 4bytes> < 4bytes> < 4bytes> < 4bytes> < datasize bytes>
Users can also reuse the 'comm' library to build new application quickly. This library provides a communciation interface via socket for both MCC and RCC, makes it convinient to both control the robot and access the camera remotely.
List of exported classes:
bool Connect(const CString& address = "127.0.0.1", int port =9000); bool Connect(BYTE b0, BYTE b1, BYTE b2, BYTE b3, int port =9000);
void Disconnect();
CString GetLastErrorMsg();
CString GetLastCommandResponse();
BOOL IsConnected();
void SetConsole(CConsole* pConsole);
int SendCommand(CString cmd)
BOOL WaitFor(const CString& action)
Example:
SendCommand("move 12 d"); //rotate 12 degree
if (WaitFor("move"))
printf("Command success");
else
printf("Command failed. %", GetLassErrorMsg());
Play(PLAY_PHRASE, "Hello world"); Play(PLAY_FILE,"file.mp3");Return status as in SendCommand.
int Move(float distance, CHAR units); //move a distance unit for the current position //rotate until it see the object identifie by objectName. //This command using the built in recognition software for ER1. int MoveRotateTowardObject(const CString &objectName); int MoveRotateTowardColor(int R, int G, int B); //rotate until it see this color //Move toward the object. int MoveDriveTowardObject(const CString &objectName, float stopDistance = 2, CHAR units = 'f'); //Move toward the color. int MoveDriveTowardColor(int R, int G, int B, int percentage = 10);For detail of these functions, refer to the ER1 API. Function returns same as in SendCommand.
int Position(float &x, float &y, float& angle);
int Stop();
int Clear();
int Events(CString &info);
bool Connect(const CString& strAddress, int port); bool Disconnect();
bool IsConnected(){ return m_pClientSocket != NULL;};
bool QueryImage(IplImage** pImg, UINT srcIndex = 0);
void SetConsole(CConsole *pConsole);
IplImage* GetImage(UINT srcIndex = 0);
virtual void SendImage(UINT devIndex = 0);
//Attach the video stream to camera bool Attach(int devID, CString name); //Attach the video stream to AVI file bool Attach(CString fileName, CString name);
bool ReAttach();
void Release();
IplImage* QueryFrame();
This toolkit is a useful tool for researchers. It quitely manages all communications to the camera server and robot control center, provides user a simple and uniform way to access robot and robot camera. The toolkit is available to download from the our project home page. You may also needs to install tcp_udp_ip toolbox ((C) Peter Rydesäter).
This software is Copyright © 2004 The Regents of the University of California. All Rights Reserved. Permission to use, copy, modify, and distribute this software and its documentation for educational, research and non-profit purposes, without fee, and without a written agreement is hereby granted, provided that the above copyright notice, this paragraph and the following three paragraphs appear in all copies. Permission to incorporate this software into commercial products may be obtained by contacting Technology Transfer Office 9500 Gilman Drive, Mail Code 0910 University of California La Jolla, CA 92093-0910 (858) 534-5815 invent@ucsd.edu This software program and documentation are copyrighted by The Regents of the University of California. The software program and documentation are supplied "as is", without any accompanying services from The Regents. The Regents does not warrant that the operation of the program will be uninterrupted or error-free. The end-user understands that the program was developed for research purposes and is advised not to rely exclusively on the program for any reason. IN NO EVENT SHALL THE UNIVERSITY OF CALIFORNIA BE LIABLE TO ANY PARTY FOR DIRECT, INDIRECT, SPECIAL, INCIDENTAL, OR CONSEQUENTIAL DAMAGES, INCLUDING LOST PROFITS, ARISING OUT OF THE USE OF THIS SOFTWARE AND ITS DOCUMENTATION, EVEN IF THE UNIVERSITY OF CALIFORNIA HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. THE UNIVERSITY OF CALIFORNIA SPECIFICALLY DISCLAIMS ANY WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE SOFTWARE PROVIDED HEREUNDER IS ON AN "AS IS" BASIS, AND THE UNIVERSITY OF CALIFORNIA HAS NO OBLIGATIONS TO PROVIDE MAINTENANCE, SUPPORT, UPDATES, ENHANCEMENTS, OR MODIFICATIONS.