[TeamTalk 112]: [649] usarsim: 1) imported updates from usarsim to bring system current, to use, get latest (3.14) required base files and recompile
tk@edam.speech.cs.cmu.edu
tk at edam.speech.cs.cmu.edu
Wed Jul 11 12:23:32 EDT 2007
An HTML attachment was scrubbed...
URL: http://mailman.srv.cs.cmu.edu/pipermail/teamtalk-developers/attachments/20070711/ad441e21/attachment-0001.html
-------------- next part --------------
Added: usarsim/System/Makefile
===================================================================
--- usarsim/System/Makefile (rev 0)
+++ usarsim/System/Makefile 2007-07-11 16:23:30 UTC (rev 649)
@@ -0,0 +1,34 @@
+LINUX_DIR=../../ut2004-linux/
+
+MAPS=$(LINUX_DIR)/Maps/DM-RoboticsLab_250.ut2
+
+PACKAGES=$(LINUX_DIR)/System/USARBotAPI.u \
+ $(LINUX_DIR)/System/USARBot.u \
+ $(LINUX_DIR)/System/USARMisPkg.u \
+ $(LINUX_DIR)/System/USARModels.u \
+ $(LINUX_DIR)/System/USARVictims.u \
+ $(LINUX_DIR)/System/TreasureHunt.u
+
+INIS=$(LINUX_DIR)/System/USARSim.ini
+
+BATCH=$(LINUX_DIR)/System/usar_sx.sh
+
+all: ucc $(MAPS) $(PACKAGES) $(INIS) $(BATCH)
+
+ucc:
+ wine UCC.exe make -ini=USARSim.ini
+
+$(LINUX_DIR)/Maps/%.ut2:../Maps/%.ut2
+ cp -f $< $@
+
+$(LINUX_DIR)/System/%.u:%.u
+ cp -f $< $@
+
+$(LINUX_DIR)/System/%.ini:%.ini
+ cp -f $< $@
+
+$(LINUX_DIR)/System/%.sh:%.sh
+ cp -f $< $@
+
+
+
Modified: usarsim/System/USARSim.ini
===================================================================
--- usarsim/System/USARSim.ini 2007-07-10 00:40:26 UTC (rev 648)
+++ usarsim/System/USARSim.ini 2007-07-11 16:23:30 UTC (rev 649)
@@ -100,23 +100,13 @@
ServerPackages=XWeapons
ServerPackages=XInterface
ServerPackages=Vehicles
-ServerPackages=TeamSymbols_UT2003
-ServerPackages=TeamSymbols_UT2004
-ServerPackages=BonusPack
-ServerPackages=SkaarjPack_rc
-ServerPackages=SkaarjPack
-ServerPackages=UTClassic
-ServerPackages=UT2k4Assault
-ServerPackages=Onslaught
ServerPackages=GUI2K4
-ServerPackages=UT2k4AssaultFull
-ServerPackages=OnslaughtFull
-ServerPackages=xVoting
ServerPackages=USARBotAPI
ServerPackages=USARBot
ServerPackages=USARModels
ServerPackages=USARMisPkg
ServerPackages=USARVictims
+ServerPackages=TreasureHunt
UseStaticMeshBatching=True
ColorHighDetailMeshes=False
ColorSlowCollisionMeshes=False
@@ -469,16 +459,7 @@
EditPackages=XAdmin
EditPackages=XWebAdmin
EditPackages=Vehicles
-EditPackages=BonusPack
-EditPackages=SkaarjPack_rc
-EditPackages=SkaarjPack
-EditPackages=UTClassic
-EditPackages=UT2k4Assault
-EditPackages=Onslaught
EditPackages=GUI2K4
-EditPackages=UT2k4AssaultFull
-EditPackages=OnslaughtFull
-EditPackages=xVoting
EditPackages=StreamlineFX
EditPackages=UTV2004c
EditPackages=UTV2004s
@@ -487,6 +468,7 @@
EditPackages=USARModels
EditPackages=USARMisPkg
EditPackages=USARVictims
+EditPackages=TreasureHunt
CutdownPackages=Core
CutdownPackages=Editor
CutdownPackages=Engine
@@ -518,8 +500,8 @@
ApplicationPaths[0]=/ServerAdmin
Applications[1]=xWebAdmin.UTImageServer
ApplicationPaths[1]=/images
-bEnabled=False
-ListenPort=80
+bEnabled=True
+ListenPort=8080
[Engine.Console]
ConsoleHotKey=9
Modified: usarsim/System/make.bat
===================================================================
--- usarsim/System/make.bat 2007-07-10 00:40:26 UTC (rev 648)
+++ usarsim/System/make.bat 2007-07-11 16:23:30 UTC (rev 649)
@@ -3,5 +3,6 @@
IF EXIST USARModels.u move /Y USARModels.u USARModelsu.bak
IF EXIST USARVictims.u move /Y USARVictims.u USARVictimsu.bak
IF EXIST USARMisPkg.u move /Y USARMisPkg.u USARMisPkgu.bak
+IF EXIST TreasureHunt.u move /Y TreasureHunt.u TreasureHuntu.bak
ucc make -ini=USARSim.ini
pause
Deleted: usarsim/System/make.csh
===================================================================
--- usarsim/System/make.csh 2007-07-10 00:40:26 UTC (rev 648)
+++ usarsim/System/make.csh 2007-07-11 16:23:30 UTC (rev 649)
@@ -1,18 +0,0 @@
-#!/bin/sh
-
-LINUX_DIR=../../ut2004-linux/System
-
-touch mark
-mv USARBotAPI.u USARBotAPI.u.bak
-mv USARBot.u USARBot.u.bak
-mv USARModels.u USARModels.u.bak
-mv USARVictims.u USARVictims.u.bak
-mv USARMisPkg.u USARMisPkg.u.bak
-wine UCC.exe make -ini=USARSim.ini
-
-for file in `find . -type f -newer mark | grep -v "bak$"`
-do
-echo "Got new file $file"
-mv -f $LINUX_DIR/$file $LINUX_DIR/$file.bak
-cp $file $LINUX_DIR/$file
-done
Modified: usarsim/System/usar_sx.bat
===================================================================
--- usarsim/System/usar_sx.bat 2007-07-10 00:40:26 UTC (rev 648)
+++ usarsim/System/usar_sx.bat 2007-07-11 16:23:30 UTC (rev 649)
@@ -1,2 +1,2 @@
-ucc server %1%?game=USARBot.USARDeathMatch?TimeLimit=0?GameStats=False -ini=USARSim.ini -log=usar_server.log
+ucc server %1%?game=TreasureHunt.TreasureHuntGame?TimeLimit=0?GameStats=False?AdminName=admin?AdminPassword=findT -ini=USARSim.ini -log=usar_server.log
pause
Deleted: usarsim/System/usar_sx.csh
===================================================================
--- usarsim/System/usar_sx.csh 2007-07-10 00:40:26 UTC (rev 648)
+++ usarsim/System/usar_sx.csh 2007-07-11 16:23:30 UTC (rev 649)
@@ -1,3 +0,0 @@
-#!/usr/local/bin/tcsh
-
-./ucc-bin server $1?game=USARBot.USARDeathMatch?TimeLimit=0?GameStats=False -ini=USARSim.ini -log=usar_server.log
Copied: usarsim/System/usar_sx.sh (from rev 646, usarsim/System/usar_sx.csh)
===================================================================
--- usarsim/System/usar_sx.sh (rev 0)
+++ usarsim/System/usar_sx.sh 2007-07-11 16:23:30 UTC (rev 649)
@@ -0,0 +1,3 @@
+#!/bin/bash
+
+./ucc-bin server $1?game=TreasureHunt.TreasureHuntGame?TimeLimit=0?GameStats=False?AdminName=admin?AdminPassword=findT -ini=USARSim.ini -log=usar_server.log -nohomedir
Modified: usarsim/Tools/ImageSrv/ImageSrvDlg.cpp
===================================================================
--- usarsim/Tools/ImageSrv/ImageSrvDlg.cpp 2007-07-10 00:40:26 UTC (rev 648)
+++ usarsim/Tools/ImageSrv/ImageSrvDlg.cpp 2007-07-11 16:23:30 UTC (rev 649)
@@ -23,7 +23,7 @@
#define UTCAPP "ut2004.exe"
#define DLLFILE "Hook.dll"
#define UTWND FindWindow(NULL,"Unreal Tournament 2004")
-#define UTCCMD "?spectatoronly=1?TimeLimit=0?quickstart=true -ini=usarsim.ini" //Client
+#define UTCCMD "?spectatoronly=1?game=USARBot.USARDeathMatch?TimeLimit=0?quickstart=true -ini=usarsim.ini" //Client
#define UTSCMD "?spectatoronly=1?quickstart=true -ini=usarsim.ini" //Server
#define UT_ADDRESS "127.0.0.1"
Modified: usarsim/Tools/Usar_UI/USARRoute.cpp
===================================================================
--- usarsim/Tools/Usar_UI/USARRoute.cpp 2007-07-10 00:40:26 UTC (rev 648)
+++ usarsim/Tools/Usar_UI/USARRoute.cpp 2007-07-11 16:23:30 UTC (rev 649)
@@ -70,8 +70,8 @@
GetClientRect(&rect);
m_OffsetX=(rect.right+rect.left)/2;
m_OffsetY=(rect.bottom+rect.top)/2;
- m_ScaleX=0.2;
- m_ScaleY=0.2;
+ m_ScaleX=0.2f;
+ m_ScaleY=0.2f;
m_Data=NULL;
return true;
}
Modified: usarsim/Tools/Usar_UI/UsarDlg.cpp
===================================================================
--- usarsim/Tools/Usar_UI/UsarDlg.cpp 2007-07-10 00:40:26 UTC (rev 648)
+++ usarsim/Tools/Usar_UI/UsarDlg.cpp 2007-07-11 16:23:30 UTC (rev 649)
@@ -1,754 +1,770 @@
-// UsarDlg.cpp : implementation file
-//
-#include "stdafx.h"
-#include "Usar.h"
-#include "UsarDlg.h"
-#include "USARSocket.h"
-#include "USARRoute.h"
-#include "MessagePanel.h"
-#include "MessageParser.h"
-
-#ifdef _DEBUG
-#define new DEBUG_NEW
-#undef THIS_FILE
-static char THIS_FILE[] = __FILE__;
-#endif
-
-#define PORTNUM 3000
-#define MSGLINES 1000
-#define POINTSNUM 10000
-
-int MaxMsg=256;
-BOOL bLOCK=false;
-
-/////////////////////////////////////////////////////////////////////////////
-// CAboutDlg dialog used for App About
-
-class CAboutDlg : public CDialog
-{
-public:
- CAboutDlg();
-
-// Dialog Data
- //{{AFX_DATA(CAboutDlg)
- enum { IDD = IDD_ABOUTBOX };
- //}}AFX_DATA
-
- // ClassWizard generated virtual function overrides
- //{{AFX_VIRTUAL(CAboutDlg)
- protected:
- virtual void DoDataExchange(CDataExchange* pDX); // DDX/DDV support
- //}}AFX_VIRTUAL
-
-// Implementation
-protected:
- //{{AFX_MSG(CAboutDlg)
- //}}AFX_MSG
- DECLARE_MESSAGE_MAP()
-};
-
-CAboutDlg::CAboutDlg() : CDialog(CAboutDlg::IDD)
-{
- //{{AFX_DATA_INIT(CAboutDlg)
- //}}AFX_DATA_INIT
-}
-
-void CAboutDlg::DoDataExchange(CDataExchange* pDX)
-{
- CDialog::DoDataExchange(pDX);
- //{{AFX_DATA_MAP(CAboutDlg)
- //}}AFX_DATA_MAP
-}
-
-BEGIN_MESSAGE_MAP(CAboutDlg, CDialog)
- //{{AFX_MSG_MAP(CAboutDlg)
- // No message handlers
- //}}AFX_MSG_MAP
-END_MESSAGE_MAP()
-
-/////////////////////////////////////////////////////////////////////////////
-// CUsarDlg dialog
-
-CUsarDlg::CUsarDlg(CWnd* pParent /*=NULL*/)
- : CDialog(CUsarDlg::IDD, pParent)
-{
- //{{AFX_DATA_INIT(CUsarDlg)
- m_Server = _T("");
- m_Location = _T("");
- m_Rotation = _T("");
- m_Time = _T("");
- //}}AFX_DATA_INIT
- // Note that LoadIcon does not require a subsequent DestroyIcon in Win32
- m_hIcon = AfxGetApp()->LoadIcon(IDR_MAINFRAME);
- m_Control = false;
- m_arOut = NULL;
- m_arIn = NULL;
-}
-
-void CUsarDlg::DoDataExchange(CDataExchange* pDX)
-{
- CDialog::DoDataExchange(pDX);
- //{{AFX_DATA_MAP(CUsarDlg)
- DDX_Control(pDX, IDC_TAB1, m_Table);
- DDX_Control(pDX, IDC_COMBO1, m_Command);
- DDX_Control(pDX, IDC_BUTTON2, m_Send);
- DDX_Control(pDX, IDC_BUTTON1, m_Connect);
- DDX_Control(pDX, IDC_LIST1, m_Msg);
- DDX_Text(pDX, IDC_EDIT1, m_Server);
- DDX_Text(pDX, IDC_EDIT2, m_Location);
- DDX_Text(pDX, IDC_EDIT3, m_Rotation);
- DDX_Text(pDX, IDC_EDIT4, m_Time);
- //}}AFX_DATA_MAP
-}
-
-BEGIN_MESSAGE_MAP(CUsarDlg, CDialog)
- //{{AFX_MSG_MAP(CUsarDlg)
- ON_WM_SYSCOMMAND()
- ON_WM_PAINT()
- ON_WM_QUERYDRAGICON()
- ON_BN_CLICKED(IDC_BUTTON1, OnConnect)
- ON_BN_CLICKED(IDC_BUTTON2, OnSend)
- ON_CBN_SELCHANGE(IDC_COMBO1, OnSelchangeCombo1)
- ON_BN_CLICKED(IDC_BUTTON3, OnControl)
- ON_BN_CLICKED(IDC_BUTTON4, OnZoomIn)
- ON_BN_CLICKED(IDC_BUTTON5, OnZoomOut)
- ON_BN_CLICKED(IDC_BUTTON7, OnOriginal)
- ON_BN_CLICKED(IDC_BUTTON6, OnClear)
- ON_LBN_DBLCLK(IDC_LIST1, OnDblclkList1)
- //}}AFX_MSG_MAP
-END_MESSAGE_MAP()
-
-/////////////////////////////////////////////////////////////////////////////
-// CUsarDlg message handlers
-
-BOOL CUsarDlg::OnInitDialog()
-{
- CDialog::OnInitDialog();
-
- // Add "About..." menu item to system menu.
-
- // IDM_ABOUTBOX must be in the system command range.
- ASSERT((IDM_ABOUTBOX & 0xFFF0) == IDM_ABOUTBOX);
- ASSERT(IDM_ABOUTBOX < 0xF000);
-
- CMenu* pSysMenu = GetSystemMenu(FALSE);
- if (pSysMenu != NULL)
- {
- CString strAboutMenu;
- strAboutMenu.LoadString(IDS_ABOUTBOX);
- if (!strAboutMenu.IsEmpty())
- {
- pSysMenu->AppendMenu(MF_SEPARATOR);
- pSysMenu->AppendMenu(MF_STRING, IDM_ABOUTBOX, strAboutMenu);
- }
- }
-
- // Set the icon for this dialog. The framework does this automatically
- // when the application's main window is not a dialog
- SetIcon(m_hIcon, TRUE); // Set big icon
- SetIcon(m_hIcon, FALSE); // Set small icon
-
- // TODO: Add extra initialization here
- m_Server = "localhost";
- m_Command.LimitText(128);
- //m_arIn = NULL;
- //m_arOut = NULL;
- m_Socket = new USARSocket(this);
-
- //m_Control = false;
-
- m_CachedMove.vx=0.001f;
- m_CachedMove.vy=0.001f;
- m_CachedMove.rx=-1;
- m_CachedMove.cx=0.001f;
- m_CachedMove.cy=0.001f;
- m_CachedMove.cz=0.001f;
-
- memset(&m_Joyinfo,0,sizeof(JOYINFOEX));
- m_Joyinfo.dwSize = sizeof(JOYINFOEX);
- m_Joyinfo.dwFlags = JOY_RETURNPOV | JOY_RETURNX | JOY_RETURNY | JOY_RETURNZ | JOY_RETURNR;
-
- m_Table.Init();
- m_finishTime = clock();
-
- UpdateData(false);
- return TRUE; // return TRUE unless you set the focus to a control
-}
-
-void CUsarDlg::OnSysCommand(UINT nID, LPARAM lParam)
-{
- if ((nID & 0xFFF0) == IDM_ABOUTBOX)
- {
- CAboutDlg dlgAbout;
- dlgAbout.DoModal();
- }
- else
- {
- CDialog::OnSysCommand(nID, lParam);
- }
-}
-
-// If you add a minimize button to your dialog, you will need the code below
-// to draw the icon. For MFC applications using the document/view model,
-// this is automatically done for you by the framework.
-
-void CUsarDlg::OnPaint()
-{
- if (IsIconic())
- {
- CPaintDC dc(this); // device context for painting
-
- SendMessage(WM_ICONERASEBKGND, (WPARAM) dc.GetSafeHdc(), 0);
-
- // Center icon in client rectangle
- int cxIcon = GetSystemMetrics(SM_CXICON);
- int cyIcon = GetSystemMetrics(SM_CYICON);
- CRect rect;
- GetClientRect(&rect);
- int x = (rect.Width() - cxIcon + 1) / 2;
- int y = (rect.Height() - cyIcon + 1) / 2;
-
- // Draw the icon
- dc.DrawIcon(x, y, m_hIcon);
- }
- else
- {
- CDialog::OnPaint();
- }
-}
-
-// The system calls this to obtain the cursor to display while the user drags
-// the minimized window.
-HCURSOR CUsarDlg::OnQueryDragIcon()
-{
- return (HCURSOR) m_hIcon;
-}
-
-void CUsarDlg::OnConnect()
-{
- // TODO: Add your control notification handler code here
- UpdateData();
- if (m_arOut==NULL) {
- if (!m_Socket->Create()) {
- MessageBox("Can't create socket","Socket",MB_OK);
- return;
- }
- if (!m_Socket->Connect(m_Server,PORTNUM)) {
- MessageBox("Can't connect to server","Connect",MB_OK);
- m_Socket->Close();
- return;
- }
- m_File = new CSocketFile(m_Socket);
- m_arIn = new CArchive(m_File, CArchive::load);
- m_arOut = new CArchive(m_File, CArchive::store);
- m_Connect.SetWindowText("Disconnect");
- InitZoom();
- m_Send.EnableWindow(true);
- //if (m_HasJoystick)
- GetDlgItem(IDC_BUTTON3)->EnableWindow(true);
- //clear data
- m_Movement.raw.RemoveAll();
- m_Movement.points.RemoveAll();
- //CString str;
- //m_arIn->ReadString(str);
- //m_Msg.AddString(str);
- }
- else {
- if (m_arIn!=NULL) {
- delete m_arIn;
- m_arIn=NULL;
- }
- delete m_arOut;
- m_arOut=NULL;
- delete m_File;
- m_File=NULL;
- m_Socket->Close();
- m_Connect.SetWindowText("Connect");
- m_Send.EnableWindow(false);
- GetDlgItem(IDC_BUTTON3)->EnableWindow(false);
- }
-}
-
-void CUsarDlg::OnSend()
-{
- // TODO: Add your control notification handler code here
- CString str;
- if (m_arOut==NULL) return;
- m_Command.GetWindowText(str);
- m_Command.InsertString(0,str);
- try {
- m_arOut->WriteString(str);
- m_arOut->WriteString("\r\n");
- m_arOut->Flush();
- }catch (CException* e) {
- e->Delete();
- MessageBox("Loss connection. Exit!","Error",MB_OK|MB_ICONSTOP);
- exit(1);
- }
-}
-
-void CUsarDlg::OnSelchangeCombo1()
-{
- // TODO: Add your control notification handler code here
- CString str;
- int i = m_Command.GetCurSel();
- m_Command.GetLBText(i,str);
- m_Command.SetWindowText(str);
-}
-
-void CUsarDlg::ProcessPendingRead()
-{
- // TODO: Add your message handler code here and/or call default
- CString str;
- int tmp,process=1;
-
- do {
- m_arIn->ReadString(str);
- m_Msg.InsertString(0,str);
- if (m_Msg.GetCount()>=MSGLINES)
- m_Msg.DeleteString(MSGLINES);
- tmp = str.GetLength()*6;
- if (tmp>MaxMsg) {
- MaxMsg = tmp;
- m_Msg.SetHorizontalExtent(tmp);
- }
- // If we get more than one STA message, we possibly have heavy traffic.
- // So we discard all the messages after the second STA message to
- // empty the queue.
- if (str.Find("STA")==0) {
- if (process==1) process=2;
- else if (process==2) process=0;
- }
- if (process) ProcessMessage(str);
-
- }while(!m_arIn->IsBufferEmpty());
-
- UpdateData(false);
- Sleep(5);
-}
-
-void CUsarDlg::ProcessMessage(CString str)
-{
- int p1,p2;
- //Robot state
- if (str.Find("STA")==0 || str.Find("{Type GroundTruth}")>0) {
- p1 = str.Find("{Time");
- if (p1>0) {
- p1 += 5;
- p2 = str.Find("}",p1);
- m_Time = str.Mid(p1,p2-p1);
- }
- p1 = str.Find("{Location",p2);
- if (p1>0) {
- p1 += 9;
- p2 = str.Find("}",p1);
- m_Location = str.Mid(p1,p2-p1);
- }
- p1 = str.Find("{Orientation",p2);
- if (p1>0) {
- p1 += 12;
- p2 = str.Find("}",p1);
- m_Rotation = str.Mid(p1,p2-p1);
- }
- AddPoint(m_Location,m_Rotation);
- return;
- }
-}
-
-void CUsarDlg::OnControl()
-{
- // TODO: Add your control notification handler code here
- if (!m_Control) {
- GetDlgItem(IDC_BUTTON3)->SetWindowText("&Control");
- SetCapture();
- m_Control=true;
- int srcWidth = GetSystemMetrics(SM_CXSCREEN)-25;
- int srcHeight = GetSystemMetrics(SM_CYSCREEN)-25;
- GetWindowRect(&m_winPos);
- RECT tmp;
- tmp.left = m_winPos.left>25?m_winPos.left:25;
- tmp.right = m_winPos.right<srcWidth?m_winPos.right:srcWidth;
- tmp.top = m_winPos.top>25?m_winPos.top:25;
- tmp.bottom = m_winPos.bottom<srcHeight?m_winPos.bottom:srcHeight;
- m_winRange.left=tmp.left-m_winPos.left;
- m_winRange.right=tmp.right-m_winPos.left-5;
- m_winRange.top=tmp.top-m_winPos.top;
- m_winRange.bottom=tmp.bottom-m_winPos.top-50;
- m_moveAmount=0.0;
- m_turnAmount=0.0;
- m_pitchAmount=0;
- m_yawAmount=0;
- m_oldMX=-1;
- m_oldMY=-1;
- }
- else {
- GetDlgItem(IDC_BUTTON3)->SetWindowText("&Command");
- m_Control=false;
- ReleaseCapture();
- }
-}
-
-LRESULT CUsarDlg::WindowProc(UINT message, WPARAM wParam, LPARAM lParam)
-{
- // TODO: Add your specialized code here and/or call the base class
- switch(message)
- {
- case WM_CREATE:
- /* Capture the joystick. If this fails, beep and display
- * error.
- */
- if(joySetCapture(m_hWnd, JOYSTICKID1, 0, FALSE))
- {
- MessageBeep(MB_ICONEXCLAMATION);
- MessageBox("Couldn't capture the joystick", NULL, MB_OK | MB_ICONEXCLAMATION);
- m_HasJoystick = false;
- //return -1;
- }
- else m_HasJoystick = true;
- break;
-
- case MM_JOY1MOVE :
- //if (m_Control) Rotate(lParam);
- /*if (m_Control)*/ Move();
- break;
- case WM_RBUTTONDOWN:
- if (m_arOut!=NULL) OnControl();
- break;
- case WM_ACTIVATE:
- if (LOWORD(wParam)==WA_INACTIVE)
- ReleaseCapture();
- else if (m_Control && m_arOut!=NULL)
- SetCapture();
- break;
- case WM_DESTROY:
- /* We're shutting down. Release capture on the joystick,
- * make sure any sounds that are playing are stopped.
- */
- if (m_HasJoystick) joyReleaseCapture(JOYSTICKID1);
- PostQuitMessage(0);
- break;
- }
- return CDialog::WindowProc(message, wParam, lParam);
-}
-
-BOOL CUsarDlg::PreTranslateMessage(MSG* pMsg)
-{
- // TODO: Add your specialized code here and/or call the base class
- int processed;
- if (!m_Control) return CDialog::PreTranslateMessage(pMsg);
- switch(pMsg->message) {
- case WM_KEYDOWN:
- processed=KMove(pMsg->wParam,pMsg->lParam,1);
- break;
- case WM_KEYUP:
- processed=KMove(pMsg->wParam,pMsg->lParam,0);
- break;
- case WM_MOUSEMOVE:
- processed=KMove(pMsg->wParam,pMsg->lParam,2);
- break;
- default:
- processed=0;
- }
- if (processed) return true;
- else {
- if (pMsg->message!=WM_MOUSEMOVE&&(m_pitchAmount!=0||m_yawAmount!=0)) {
- SYSTEMTIME systime;
- GetSystemTime(&systime);
- if ((systime.wMilliseconds-m_systime.wMilliseconds)>0.1) {
- m_pitchAmount=0;
- m_yawAmount=0;
- CString str="CAMERA {Rotation 0,0,0}\r\n";
- //m_Msg.InsertString(0,str);
- if (m_arOut!=NULL) {
- try {
- m_arOut->WriteString(str);
- m_arOut->Flush();
- }catch (CException* e) {
- e->Delete();
- MessageBox("Loss connection. Exit!","Error",MB_OK|MB_ICONSTOP);
- exit(1);
- }
- }
- Sleep(50);
- }
- }
- return CDialog::PreTranslateMessage(pMsg);
- }
-}
-
-int CUsarDlg::KMove(WPARAM wParam, LPARAM lParam, int type)
-{
- CString str;
- int processed=1;
- int x,y;
- switch(wParam) {
- case VK_LEFT:
- m_turnAmount=type?m_turnAmount+0.2f:0.0f;
- m_turnAmount=(m_turnAmount>20.0f)?20.0f:m_turnAmount;
- str.Format("DRIVE {Left %f} {Right %f} {Normalized true}\r\n",-m_turnAmount,m_turnAmount);
- break;
- case VK_RIGHT:
- m_turnAmount=type?m_turnAmount+0.2f:0.0f;
- m_turnAmount=(m_turnAmount>20.0f)?20.0f:m_turnAmount;
- str.Format("DRIVE {Left %f} {Right %f} {Normalized true}\r\n",m_turnAmount,-m_turnAmount);
- break;
- case VK_UP:
- m_moveAmount=type?m_moveAmount+0.2f:0.0f;
- m_moveAmount=(m_moveAmount>20.0f)?20.0f:m_moveAmount;
- str.Format("DRIVE {Left %f} {Right %f} {Normalized true}\r\n",m_moveAmount,m_moveAmount);
- break;
- case VK_DOWN:
- m_moveAmount=type?m_moveAmount+0.2f:0.0f;
- m_moveAmount=(m_moveAmount>20.0f)?20.0f:m_moveAmount;
- str.Format("DRIVE {Left %f} {Right %f} {Normalized true}\r\n",-m_moveAmount,-m_moveAmount);
- break;
- case VK_RETURN:
- case VK_ESCAPE:
- break;
- default:
- processed=0;
- }
- if (m_arOut!=NULL&&str.GetLength()>1) {
- try {
- m_arOut->WriteString(str);
- m_arOut->Flush();
- }catch (CException* e) {
- e->Delete();
- MessageBox("Loss connection. Exit!","Error",MB_OK|MB_ICONSTOP);
- exit(1);
- }
- }
-
- if (type==2) {
- x=LOWORD(lParam);
- y=HIWORD(lParam);
- //str.Format("Mouse x=%d y=%d W=%d H=%d",x,y,m_winWidth,m_winHeight);
- //m_Msg.InsertString(0,str);
- if ((x>m_winRange.left)&&(x<m_winRange.right)&&
- (y>m_winRange.top)&&(y<m_winRange.bottom)) {
- if (m_oldMX<0) m_oldMX=x;
- if (m_oldMY<0) m_oldMY=y;
- m_pitchAmount=(m_oldMY-y)*0.02f;
- if (m_pitchAmount>0.08f) m_pitchAmount=0.08f;
- if (m_pitchAmount<-0.08f) m_pitchAmount=-0.08f;
- m_yawAmount=(x-m_oldMX)*0.02f;
- if (m_yawAmount>0.08f) m_yawAmount=0.08f;
- if (m_yawAmount<-0.08f) m_yawAmount=-0.08f;
- m_oldMX=x;
- m_oldMY=y;
- str.Format("CAMERA {Rotation 0,%f,%f}\r\n",m_pitchAmount,m_yawAmount);
- if (m_arOut!=NULL) {
- try {
- m_arOut->WriteString(str);
- m_arOut->Flush();
- }catch (CException* e) {
- e->Delete();
- MessageBox("Loss connection. Exit!","Error",MB_OK|MB_ICONSTOP);
- exit(1);
- }
- }
- GetSystemTime(&m_systime);
- }
- else
- SetCursorPos((m_winPos.left+m_winPos.right)/2,(m_winPos.top+m_winPos.bottom)/2);
-
- }
- return processed;
-}
-
-void CUsarDlg::Move()
-{
- CString str,tmp;
- WORD x,y,pov;
- float rx,ry,rz,d;
- float vx,vy,vz;
-
- rx = 0; ry = 0; rz = 0;
- //ry = m_Movement.c_Rotation.y;
- vx =0; vy = 0; vz = 0;
- d = 0;
-
- joyGetPosEx(JOYSTICKID1, &m_Joyinfo);
-
- // Trun left/right
- x = LOWORD(m_Joyinfo.dwXpos) >> 11;
- if (x <= 11) vx = (x - 12)/0.6f;
- else if (x >= 20) vx = (x - 19)/0.6f;
-
- // Move forward/backward
- y = LOWORD(m_Joyinfo.dwYpos) >> 11;
- if (y <= 11) vy = (y - 12)/0.6f;
- else if (y >= 20) vy = (y - 19)/0.6f;
-
- if (vx!=m_CachedMove.vx||vy!=m_CachedMove.vy) {
- m_CachedMove.vx = vx;
- m_CachedMove.vy = vy;
- str.Format("DRIVE {Left %f} {Right %f} {Normalized true}\r\n",vx-vy,-vy-vx);
- //m_Msg.InsertString(0,str);
- }
-
- // View pitch & yaw
- pov = LOWORD(m_Joyinfo.dwPOV);
- rx=0;ry=0;rz=0;
- if (pov<36000) {
- d = pov*3.1415926f/18000;
- ry=(float)(0.006*cos(d));
- rz=(float)(0.006*sin(d));
- }
- rx=0;
-
- if (rx!=m_CachedMove.cx || m_CachedMove.cx!=0 ||
- ry!=m_CachedMove.cy || m_CachedMove.cy!=0 ||
- rz!=m_CachedMove.cz || m_CachedMove.cy!=0) {
- m_CachedMove.cx = rx;
- m_CachedMove.cy = ry;
- m_CachedMove.cz = rz;
- tmp.Format("CAMERA {Rotation %f,%f,%f}\r\n",rx,ry,rz);
- //m_Msg.InsertString(0,tmp);
- str+=tmp;
- }
-
- if (m_arOut!=NULL&&str.GetLength()>1) {
- try {
- m_arOut->WriteString(str);
- m_arOut->Flush();
- }catch (CException* e) {
- e->Delete();
- MessageBox("Loss connection. Exit!","Error",MB_OK|MB_ICONSTOP);
- exit(1);
- }
- }
- /*
- str.Format("X=%d %d Y=%d %d Z=%d %d R=%d POV=%d %d",
- m_Joyinfo.dwXpos,x,
- m_Joyinfo.dwYpos,y,
- m_Joyinfo.dwZpos,0,
- m_Joyinfo.dwRpos,
- m_Joyinfo.dwPOV,pov);
-
- m_Msg.InsertString(0,str);
- */
-}
-
-void CUsarDlg::AddPoint(CString Location, CString Rotation)
-{
- int x0,y0,z0;
- int x,y,z;
- int p1,p2;
-
- if (bLOCK) return;
- p1 = Location.Find(',');
- p2 = Location.Find(',',p1+1);
- x0 = (int)(-atof((LPCSTR)Location.Left(p1))*500);
- x = (int)((float)x0*m_Zoom.scaleX+m_Zoom.offsetX);
- y0 = (int)(-atof((LPCSTR)Location.Mid(p1+1,p2-p1))*500);
- y = (int)((float)y0*m_Zoom.scaleY+m_Zoom.offsetY);
- z0 = (int)(atof((LPCSTR)Location.Mid(p2+1))*500);
- if (m_Movement.c_Location.x!=x0||m_Movement.c_Location.y!=y0||m_Movement.points.GetSize()==0) {
- m_Movement.c_Location.x=x;
- m_Movement.c_Location.y=y;
- m_Movement.points.Add(m_Movement.c_Location);
- m_Movement.c_Location.x=x0;
- m_Movement.c_Location.y=y0;
- m_Movement.raw.Add(m_Movement.c_Location);
- m_Movement.z = z0;
- m_Table.DrawPoint(&m_Movement);
- }
-
- p1 = Rotation.Find(',');
- p2 = Rotation.Find(',',p1+1);
- z = (int)(atof((LPCSTR)Rotation.Left(p1))*10430.37835);
- x = (int)(atof((LPCSTR)Rotation.Mid(p1+1,p2-p1))*10430.37835);
- y = (int)(atof((LPCSTR)Rotation.Mid(p2+1))*10430.37835);
- if (m_Movement.c_Rotation.x!=x||m_Movement.c_Rotation.y!=y||m_Movement.points.GetSize()==0) {
- m_Movement.c_Rotation.x=x;
- m_Movement.c_Rotation.y=y;
- m_Table.DrawPoint(&m_Movement);
- }
- if (m_Movement.points.GetSize()>=POINTSNUM) m_Movement.points.RemoveAt(0);
- if (m_Movement.raw.GetSize()>=POINTSNUM) m_Movement.raw.RemoveAt(0);
-}
-
-void CUsarDlg::InitZoom()
-{
- USARRoute * ur;
- ur = ((USARRoute *)m_Table.m_tabPages[m_Table.m_tabCurrent]);
- m_Zoom.offsetX = ur->m_OffsetX;
- m_Zoom.offsetY = ur->m_OffsetY;
- m_Zoom.scaleX = ur->m_ScaleX;
- m_Zoom.scaleY = ur->m_ScaleY;
-}
-
-
-void CUsarDlg::UpdatePoints()
-{
- POINT p;
- int n = m_Movement.points.GetSize();
- for (int i=0;i<n;i++) {
- p = m_Movement.raw.GetAt(i);
- p.x = (int)(p.x*m_Zoom.scaleX+m_Zoom.offsetX);
- p.y = (int)(p.y*m_Zoom.scaleY+m_Zoom.offsetY);
- m_Movement.points.SetAt(i,p);
- }
-}
-
-void CUsarDlg::OnZoomIn()
-{
- // TODO: Add your control notification handler code here
- bLOCK = true;
- m_Zoom.scaleX *= 2.0;
- m_Zoom.scaleY *= 2.0;
- UpdatePoints();
- bLOCK = false;
- m_Table.DrawPoint(&m_Movement);
-}
-
-
-void CUsarDlg::OnZoomOut()
-{
- // TODO: Add your control notification handler code here
- bLOCK = true;
- m_Zoom.scaleX /= 2.0;
- m_Zoom.scaleY /= 2.0;
- UpdatePoints();
- bLOCK = false;
- m_Table.DrawPoint(&m_Movement);
-}
-
-void CUsarDlg::OnOriginal()
-{
- // TODO: Add your control notification handler code here
- bLOCK = true;
- m_Zoom.scaleX = 0.2f;
- m_Zoom.scaleY = 0.2f;
- UpdatePoints();
- bLOCK = false;
- m_Table.DrawPoint(&m_Movement);
-}
-
-void CUsarDlg::OnClear()
-{
- // TODO: Add your control notification handler code here
- POINT p;
- if (m_Movement.raw.GetSize()<1) return;
- bLOCK = true;
- p = m_Movement.raw.GetAt(m_Movement.raw.GetSize()-1);
- m_Movement.raw.RemoveAll();
- m_Movement.raw.Add(p);
- p = m_Movement.points.GetAt(m_Movement.points.GetSize()-1);
- m_Movement.points.RemoveAll();
- m_Movement.points.Add(p);
- bLOCK = false;
- m_Table.DrawPoint(&m_Movement);
-}
-
-void CUsarDlg::OnDblclkList1()
-{
- // TODO: Add your control notification handler code here
- CString str;
- m_Msg.GetText(m_Msg.GetCurSel(),str);
- //MessageBox(str,"Message",MB_OK);
- CMessagePanel msg = new CMessagePanel();
- msg.SetMessage(str);
- msg.DoModal();
-}
+// UsarDlg.cpp : implementation file
+//
+#include "stdafx.h"
+#include "Usar.h"
+#include "UsarDlg.h"
+#include "USARSocket.h"
+#include "USARRoute.h"
+#include "MessagePanel.h"
+#include "MessageParser.h"
+
+#ifdef _DEBUG
+#define new DEBUG_NEW
+#undef THIS_FILE
+static char THIS_FILE[] = __FILE__;
+#endif
+
+#define PORTNUM 3000
+#define MSGLINES 1000
+#define POINTSNUM 10000
+
+int MaxMsg=256;
+BOOL bLOCK=false;
+
+/////////////////////////////////////////////////////////////////////////////
+// CAboutDlg dialog used for App About
+
+class CAboutDlg : public CDialog
+{
+public:
+ CAboutDlg();
+
+// Dialog Data
+ //{{AFX_DATA(CAboutDlg)
+ enum { IDD = IDD_ABOUTBOX };
+ //}}AFX_DATA
+
+ // ClassWizard generated virtual function overrides
+ //{{AFX_VIRTUAL(CAboutDlg)
+ protected:
+ virtual void DoDataExchange(CDataExchange* pDX); // DDX/DDV support
+ //}}AFX_VIRTUAL
+
+// Implementation
+protected:
+ //{{AFX_MSG(CAboutDlg)
+ //}}AFX_MSG
+ DECLARE_MESSAGE_MAP()
+};
+
+CAboutDlg::CAboutDlg() : CDialog(CAboutDlg::IDD)
+{
+ //{{AFX_DATA_INIT(CAboutDlg)
+ //}}AFX_DATA_INIT
+}
+
+void CAboutDlg::DoDataExchange(CDataExchange* pDX)
+{
+ CDialog::DoDataExchange(pDX);
+ //{{AFX_DATA_MAP(CAboutDlg)
+ //}}AFX_DATA_MAP
+}
+
+BEGIN_MESSAGE_MAP(CAboutDlg, CDialog)
+ //{{AFX_MSG_MAP(CAboutDlg)
+ // No message handlers
+ //}}AFX_MSG_MAP
+END_MESSAGE_MAP()
+
+/////////////////////////////////////////////////////////////////////////////
+// CUsarDlg dialog
+
+CUsarDlg::CUsarDlg(CWnd* pParent /*=NULL*/)
+ : CDialog(CUsarDlg::IDD, pParent)
+{
+ //{{AFX_DATA_INIT(CUsarDlg)
+ m_Server = _T("");
+ m_Location = _T("");
+ m_Rotation = _T("");
+ m_Time = _T("");
+ //}}AFX_DATA_INIT
+ // Note that LoadIcon does not require a subsequent DestroyIcon in Win32
+ m_hIcon = AfxGetApp()->LoadIcon(IDR_MAINFRAME);
+ m_Control = false;
+ m_arOut = NULL;
+ m_arIn = NULL;
+}
+
+void CUsarDlg::DoDataExchange(CDataExchange* pDX)
+{
+ CDialog::DoDataExchange(pDX);
+ //{{AFX_DATA_MAP(CUsarDlg)
+ DDX_Control(pDX, IDC_TAB1, m_Table);
+ DDX_Control(pDX, IDC_COMBO1, m_Command);
+ DDX_Control(pDX, IDC_BUTTON2, m_Send);
+ DDX_Control(pDX, IDC_BUTTON1, m_Connect);
+ DDX_Control(pDX, IDC_LIST1, m_Msg);
+ DDX_Text(pDX, IDC_EDIT1, m_Server);
+ DDX_Text(pDX, IDC_EDIT2, m_Location);
+ DDX_Text(pDX, IDC_EDIT3, m_Rotation);
+ DDX_Text(pDX, IDC_EDIT4, m_Time);
+ //}}AFX_DATA_MAP
+}
+
+BEGIN_MESSAGE_MAP(CUsarDlg, CDialog)
+ //{{AFX_MSG_MAP(CUsarDlg)
+ ON_WM_SYSCOMMAND()
+ ON_WM_PAINT()
+ ON_WM_QUERYDRAGICON()
+ ON_BN_CLICKED(IDC_BUTTON1, OnConnect)
+ ON_BN_CLICKED(IDC_BUTTON2, OnSend)
+ ON_CBN_SELCHANGE(IDC_COMBO1, OnSelchangeCombo1)
+ ON_BN_CLICKED(IDC_BUTTON3, OnControl)
+ ON_BN_CLICKED(IDC_BUTTON4, OnZoomIn)
+ ON_BN_CLICKED(IDC_BUTTON5, OnZoomOut)
+ ON_BN_CLICKED(IDC_BUTTON7, OnOriginal)
+ ON_BN_CLICKED(IDC_BUTTON6, OnClear)
+ ON_LBN_DBLCLK(IDC_LIST1, OnDblclkList1)
+ //}}AFX_MSG_MAP
+END_MESSAGE_MAP()
+
+/////////////////////////////////////////////////////////////////////////////
+// CUsarDlg message handlers
+
+BOOL CUsarDlg::OnInitDialog()
+{
+ CDialog::OnInitDialog();
+
+ // Add "About..." menu item to system menu.
+
+ // IDM_ABOUTBOX must be in the system command range.
+ ASSERT((IDM_ABOUTBOX & 0xFFF0) == IDM_ABOUTBOX);
+ ASSERT(IDM_ABOUTBOX < 0xF000);
+
+ CMenu* pSysMenu = GetSystemMenu(FALSE);
+ if (pSysMenu != NULL)
+ {
+ CString strAboutMenu;
+ strAboutMenu.LoadString(IDS_ABOUTBOX);
+ if (!strAboutMenu.IsEmpty())
+ {
+ pSysMenu->AppendMenu(MF_SEPARATOR);
+ pSysMenu->AppendMenu(MF_STRING, IDM_ABOUTBOX, strAboutMenu);
+ }
+ }
+
+ // Set the icon for this dialog. The framework does this automatically
+ // when the application's main window is not a dialog
+ SetIcon(m_hIcon, TRUE); // Set big icon
+ SetIcon(m_hIcon, FALSE); // Set small icon
+
+ // TODO: Add extra initialization here
+ m_Server = "localhost";
+ m_Command.LimitText(128);
+ //m_arIn = NULL;
+ //m_arOut = NULL;
+ m_Socket = new USARSocket(this);
+
+ //m_Control = false;
+
+ m_CachedMove.vx=0.001f;
+ m_CachedMove.vy=0.001f;
+ m_CachedMove.rx=-1;
+ m_CachedMove.cx=0.001f;
+ m_CachedMove.cy=0.001f;
+ m_CachedMove.cz=0.001f;
+
+ memset(&m_Joyinfo,0,sizeof(JOYINFOEX));
+ m_Joyinfo.dwSize = sizeof(JOYINFOEX);
+ m_Joyinfo.dwFlags = JOY_RETURNPOV | JOY_RETURNX | JOY_RETURNY | JOY_RETURNZ | JOY_RETURNR;
+
+ m_Table.Init();
+ m_finishTime = clock();
+
+ UpdateData(false);
+ return TRUE; // return TRUE unless you set the focus to a control
+}
+
+void CUsarDlg::OnSysCommand(UINT nID, LPARAM lParam)
+{
+ if ((nID & 0xFFF0) == IDM_ABOUTBOX)
+ {
+ CAboutDlg dlgAbout;
+ dlgAbout.DoModal();
+ }
+ else if ((nID & 0xFFF0) == SC_CLOSE)
+ {
+ EndDialog(IDOK);
+ }
+ else
+ {
+ CDialog::OnSysCommand(nID, lParam);
+ }
+}
+
+// If you add a minimize button to your dialog, you will need the code below
+// to draw the icon. For MFC applications using the document/view model,
+// this is automatically done for you by the framework.
+
+void CUsarDlg::OnPaint()
+{
+ if (IsIconic())
+ {
+ CPaintDC dc(this); // device context for painting
+
+ SendMessage(WM_ICONERASEBKGND, (WPARAM) dc.GetSafeHdc(), 0);
+
+ // Center icon in client rectangle
+ int cxIcon = GetSystemMetrics(SM_CXICON);
+ int cyIcon = GetSystemMetrics(SM_CYICON);
+ CRect rect;
+ GetClientRect(&rect);
+ int x = (rect.Width() - cxIcon + 1) / 2;
+ int y = (rect.Height() - cyIcon + 1) / 2;
+
+ // Draw the icon
+ dc.DrawIcon(x, y, m_hIcon);
+ }
+ else
+ {
+ CDialog::OnPaint();
+ }
+}
+
+// The system calls this to obtain the cursor to display while the user drags
+// the minimized window.
+HCURSOR CUsarDlg::OnQueryDragIcon()
+{
+ return (HCURSOR) m_hIcon;
+}
+
+void CUsarDlg::OnConnect()
+{
+ // TODO: Add your control notification handler code here
+ UpdateData();
+ if (m_arOut==NULL) {
+ if (!m_Socket->Create()) {
+ MessageBox("Can't create socket","Socket",MB_OK);
+ return;
+ }
+ if (!m_Socket->Connect(m_Server,PORTNUM)) {
+ MessageBox("Can't connect to server","Connect",MB_OK);
+ m_Socket->Close();
+ return;
+ }
+ m_File = new CSocketFile(m_Socket);
+ m_arIn = new CArchive(m_File, CArchive::load);
+ m_arOut = new CArchive(m_File, CArchive::store);
+ m_Connect.SetWindowText("Disconnect");
+ InitZoom();
+ m_Send.EnableWindow(true);
+ //if (m_HasJoystick)
+ GetDlgItem(IDC_BUTTON3)->EnableWindow(true);
+ //clear data
+ m_Movement.raw.RemoveAll();
+ m_Movement.points.RemoveAll();
+ //CString str;
+ //m_arIn->ReadString(str);
+ //m_Msg.AddString(str);
+ }
+ else {
+ if (m_arIn!=NULL) {
+ delete m_arIn;
+ m_arIn=NULL;
+ }
+ delete m_arOut;
+ m_arOut=NULL;
+ delete m_File;
+ m_File=NULL;
+ m_Socket->Close();
+ m_Connect.SetWindowText("Connect");
+ m_Send.EnableWindow(false);
+ GetDlgItem(IDC_BUTTON3)->EnableWindow(false);
+ }
+}
+
+void CUsarDlg::OnSend()
+{
+ // TODO: Add your control notification handler code here
+ CString str;
+ if (m_arOut==NULL) return;
+ m_Command.GetWindowText(str);
+ m_Command.InsertString(0,str);
+ try {
+ m_arOut->WriteString(str);
+ m_arOut->WriteString("\r\n");
+ m_arOut->Flush();
+ }catch (CException* e) {
+ e->Delete();
+ MessageBox("Loss connection. Exit!","Error",MB_OK|MB_ICONSTOP);
+ exit(1);
+ }
+}
+
+void CUsarDlg::OnSelchangeCombo1()
+{
+ // TODO: Add your control notification handler code here
+ CString str;
+ int i = m_Command.GetCurSel();
+ m_Command.GetLBText(i,str);
+ m_Command.SetWindowText(str);
+}
+
+void CUsarDlg::ProcessPendingRead()
+{
+ // TODO: Add your message handler code here and/or call default
+ CString str;
+ int tmp,process=1;
+
+ do {
+ m_arIn->ReadString(str);
+ m_Msg.InsertString(0,str);
+ if (m_Msg.GetCount()>=MSGLINES)
+ m_Msg.DeleteString(MSGLINES);
+ tmp = str.GetLength()*6;
+ if (tmp>MaxMsg) {
+ MaxMsg = tmp;
+ m_Msg.SetHorizontalExtent(tmp);
+ }
+ // If we get more than one STA message, we possibly have heavy traffic.
+ // So we discard all the messages after the second STA message to
+ // empty the queue.
+ if (str.Find("STA")==0) {
+ if (process==1) process=2;
+ else if (process==2) process=0;
+ }
+ if (process) ProcessMessage(str);
+
+ }while(!m_arIn->IsBufferEmpty());
+
+ UpdateData(false);
+ Sleep(5);
+}
+
+void CUsarDlg::ProcessMessage(CString str)
+{
+ int p1,p2;
+ //Robot state
+ if (str.Find("STA")==0 || str.Find("{Type GroundTruth}")>0) {
+ p1 = str.Find("{Time");
+ if (p1>0) {
+ p1 += 5;
+ p2 = str.Find("}",p1);
+ m_Time = str.Mid(p1,p2-p1);
+ }
+ p1 = str.Find("{Location",p2);
+ if (p1>0) {
+ p1 += 9;
+ p2 = str.Find("}",p1);
+ m_Location = str.Mid(p1,p2-p1);
+ }
+ p1 = str.Find("{Orientation",p2);
+ if (p1>0) {
+ p1 += 12;
+ p2 = str.Find("}",p1);
+ m_Rotation = str.Mid(p1,p2-p1);
+ }
+ AddPoint(m_Location,m_Rotation);
+ return;
+ }
+}
+
+void CUsarDlg::OnControl()
+{
+ // TODO: Add your control notification handler code here
+ if (!m_Control) {
+ GetDlgItem(IDC_BUTTON3)->SetWindowText("&Control");
+ SetCapture();
+ m_Control=true;
+ int srcWidth = GetSystemMetrics(SM_CXSCREEN)-25;
+ int srcHeight = GetSystemMetrics(SM_CYSCREEN)-25;
+ GetWindowRect(&m_winPos);
+ RECT tmp;
+ tmp.left = m_winPos.left>25?m_winPos.left:25;
+ tmp.right = m_winPos.right<srcWidth?m_winPos.right:srcWidth;
+ tmp.top = m_winPos.top>25?m_winPos.top:25;
+ tmp.bottom = m_winPos.bottom<srcHeight?m_winPos.bottom:srcHeight;
+ m_winRange.left=tmp.left-m_winPos.left;
+ m_winRange.right=tmp.right-m_winPos.left-5;
+ m_winRange.top=tmp.top-m_winPos.top;
+ m_winRange.bottom=tmp.bottom-m_winPos.top-50;
+ m_moveAmount=0.0;
+ m_turnAmount=0.0;
+ m_pitchAmount=0;
+ m_yawAmount=0;
+ m_oldMX=-1;
+ m_oldMY=-1;
+ }
+ else {
+ GetDlgItem(IDC_BUTTON3)->SetWindowText("&Command");
+ m_Control=false;
+ ReleaseCapture();
+ }
+}
+
+LRESULT CUsarDlg::WindowProc(UINT message, WPARAM wParam, LPARAM lParam)
+{
+ // TODO: Add your specialized code here and/or call the base class
+ switch(message)
+ {
+ case WM_CREATE:
+ /* Capture the joystick. If this fails, beep and display
+ * error.
+ */
+ if(joySetCapture(m_hWnd, JOYSTICKID1, 0, FALSE))
+ {
+ MessageBeep(MB_ICONEXCLAMATION);
+ MessageBox("Couldn't capture the joystick", NULL, MB_OK | MB_ICONEXCLAMATION);
+ m_HasJoystick = false;
+ //return -1;
+ }
+ else m_HasJoystick = true;
+ break;
+
+ case MM_JOY1MOVE :
+ //if (m_Control) Rotate(lParam);
+ /*if (m_Control)*/ Move();
+ break;
+ case WM_RBUTTONDOWN:
+ if (m_arOut!=NULL) OnControl();
+ break;
+ case WM_ACTIVATE:
+ if (LOWORD(wParam)==WA_INACTIVE)
+ ReleaseCapture();
+ else if (m_Control && m_arOut!=NULL)
+ SetCapture();
+ break;
+ case WM_DESTROY:
+ /* We're shutting down. Release capture on the joystick,
+ * make sure any sounds that are playing are stopped.
+ */
+ if (m_HasJoystick) joyReleaseCapture(JOYSTICKID1);
+ PostQuitMessage(0);
+ break;
+ }
+ return CDialog::WindowProc(message, wParam, lParam);
+}
+
+BOOL CUsarDlg::PreTranslateMessage(MSG* pMsg)
+{
+ // TODO: Add your specialized code here and/or call the base class
+ int processed;
+ if (!m_Control) return CDialog::PreTranslateMessage(pMsg);
+ switch(pMsg->message) {
+ case WM_KEYDOWN:
+ processed=KMove(pMsg->wParam,pMsg->lParam,1);
+ break;
+ case WM_KEYUP:
+ processed=KMove(pMsg->wParam,pMsg->lParam,0);
+ break;
+ case WM_MOUSEMOVE:
+ processed=KMove(pMsg->wParam,pMsg->lParam,2);
+ break;
+ default:
+ processed=0;
+ }
+ if (processed) return true;
+ else {
+ if (pMsg->message!=WM_MOUSEMOVE&&(m_pitchAmount!=0||m_yawAmount!=0)) {
+ SYSTEMTIME systime;
+ GetSystemTime(&systime);
+ if ((systime.wMilliseconds-m_systime.wMilliseconds)>0.1) {
+ m_pitchAmount=0;
+ m_yawAmount=0;
+ CString str="CAMERA {Rotation 0,0,0}\r\n";
+ //m_Msg.InsertString(0,str);
+ if (m_arOut!=NULL) {
+ try {
+ m_arOut->WriteString(str);
+ m_arOut->Flush();
+ }catch (CException* e) {
+ e->Delete();
+ MessageBox("Loss connection. Exit!","Error",MB_OK|MB_ICONSTOP);
+ exit(1);
+ }
+ }
+ Sleep(50);
+ }
+ }
+ return CDialog::PreTranslateMessage(pMsg);
+ }
+}
+
+int CUsarDlg::KMove(WPARAM wParam, LPARAM lParam, int type)
+{
+ CString str;
+ int processed=1;
+ int x,y;
+ switch(wParam) {
+ case VK_LEFT:
+ m_turnAmount=type?m_turnAmount+0.2f:0.0f;
+ m_turnAmount=(m_turnAmount>20.0f)?20.0f:m_turnAmount;
+ str.Format("DRIVE {Left %f} {Right %f} {Normalized true}\r\n",-m_turnAmount,m_turnAmount);
+ break;
+ case VK_RIGHT:
+ m_turnAmount=type?m_turnAmount+0.2f:0.0f;
+ m_turnAmount=(m_turnAmount>20.0f)?20.0f:m_turnAmount;
+ str.Format("DRIVE {Left %f} {Right %f} {Normalized true}\r\n",m_turnAmount,-m_turnAmount);
+ break;
+ case VK_UP:
+ m_moveAmount=type?m_moveAmount+0.2f:0.0f;
+ m_moveAmount=(m_moveAmount>20.0f)?20.0f:m_moveAmount;
+ str.Format("DRIVE {Left %f} {Right %f} {Normalized true}\r\n",m_moveAmount,m_moveAmount);
+ break;
+ case VK_DOWN:
+ m_moveAmount=type?m_moveAmount+0.2f:0.0f;
+ m_moveAmount=(m_moveAmount>20.0f)?20.0f:m_moveAmount;
+ str.Format("DRIVE {Left %f} {Right %f} {Normalized true}\r\n",-m_moveAmount,-m_moveAmount);
+ break;
+ case VK_RETURN:
+ case VK_ESCAPE:
+ break;
+ default:
+ processed=0;
+ }
+ if (m_arOut!=NULL&&str.GetLength()>1) {
+ try {
+ m_arOut->WriteString(str);
+ m_arOut->Flush();
+ }catch (CException* e) {
+ e->Delete();
+ MessageBox("Loss connection. Exit!","Error",MB_OK|MB_ICONSTOP);
+ exit(1);
+ }
+ }
+
+ if (type==2) {
+ x=LOWORD(lParam);
+ y=HIWORD(lParam);
+ //str.Format("Mouse x=%d y=%d W=%d H=%d",x,y,m_winWidth,m_winHeight);
+ //m_Msg.InsertString(0,str);
+ if ((x>m_winRange.left)&&(x<m_winRange.right)&&
+ (y>m_winRange.top)&&(y<m_winRange.bottom)) {
+ if (m_oldMX<0) m_oldMX=x;
+ if (m_oldMY<0) m_oldMY=y;
+ m_pitchAmount=(m_oldMY-y)*0.02f;
+ if (m_pitchAmount>0.08f) m_pitchAmount=0.08f;
+ if (m_pitchAmount<-0.08f) m_pitchAmount=-0.08f;
+ m_yawAmount=(x-m_oldMX)*0.02f;
+ if (m_yawAmount>0.08f) m_yawAmount=0.08f;
+ if (m_yawAmount<-0.08f) m_yawAmount=-0.08f;
+ m_oldMX=x;
+ m_oldMY=y;
+ str.Format("CAMERA {Rotation 0,%f,%f}\r\n",m_pitchAmount,m_yawAmount);
+ if (m_arOut!=NULL) {
+ try {
+ m_arOut->WriteString(str);
+ m_arOut->Flush();
+ }catch (CException* e) {
+ e->Delete();
+ MessageBox("Loss connection. Exit!","Error",MB_OK|MB_ICONSTOP);
+ exit(1);
+ }
+ }
+ GetSystemTime(&m_systime);
+ }
+ else
+ SetCursorPos((m_winPos.left+m_winPos.right)/2,(m_winPos.top+m_winPos.bottom)/2);
+
+ }
+ return processed;
+}
+
+void CUsarDlg::Move()
+{
+ CString str,tmp;
+ WORD x,y,pov;
+ float rx,ry,rz,d;
+ float vx,vy,vz;
+
+ rx = 0; ry = 0; rz = 0;
+ //ry = m_Movement.c_Rotation.y;
+ vx =0; vy = 0; vz = 0;
+ d = 0;
+
+ joyGetPosEx(JOYSTICKID1, &m_Joyinfo);
+
+ // Trun left/right
+ x = LOWORD(m_Joyinfo.dwXpos) >> 11;
+ if (x <= 11) vx = (x - 12)/0.6f;
+ else if (x >= 20) vx = (x - 19)/0.6f;
+
+ // Move forward/backward
+ y = LOWORD(m_Joyinfo.dwYpos) >> 11;
+ if (y <= 11) vy = (y - 12)/0.6f;
+ else if (y >= 20) vy = (y - 19)/0.6f;
+
+ if (vx!=m_CachedMove.vx||vy!=m_CachedMove.vy) {
+ m_CachedMove.vx = vx;
+ m_CachedMove.vy = vy;
+ str.Format("DRIVE {Left %f} {Right %f} {Normalized true}\r\n",vx-vy,-vy-vx);
+ //m_Msg.InsertString(0,str);
+ }
+
+ // View pitch & yaw
+ pov = LOWORD(m_Joyinfo.dwPOV);
+ rx=0;ry=0;rz=0;
+ if (pov<36000) {
+ d = pov*3.1415926f/18000;
+ ry=(float)(0.006*cos(d));
+ rz=(float)(0.006*sin(d));
+ }
+ rx=0;
+
+ if (rx!=m_CachedMove.cx || m_CachedMove.cx!=0 ||
+ ry!=m_CachedMove.cy || m_CachedMove.cy!=0 ||
+ rz!=m_CachedMove.cz || m_CachedMove.cy!=0) {
+ m_CachedMove.cx = rx;
+ m_CachedMove.cy = ry;
+ m_CachedMove.cz = rz;
+ tmp.Format("CAMERA {Rotation %f,%f,%f}\r\n",rx,ry,rz);
+ //m_Msg.InsertString(0,tmp);
+ str+=tmp;
+ }
+
+ if (m_arOut!=NULL&&str.GetLength()>1) {
+ try {
+ m_arOut->WriteString(str);
+ m_arOut->Flush();
+ }catch (CException* e) {
+ e->Delete();
+ MessageBox("Loss connection. Exit!","Error",MB_OK|MB_ICONSTOP);
+ exit(1);
+ }
+ }
+ /*
+ str.Format("X=%d %d Y=%d %d Z=%d %d R=%d POV=%d %d",
+ m_Joyinfo.dwXpos,x,
+ m_Joyinfo.dwYpos,y,
+ m_Joyinfo.dwZpos,0,
+ m_Joyinfo.dwRpos,
+ m_Joyinfo.dwPOV,pov);
+
+ m_Msg.InsertString(0,str);
+ */
+}
+
+void CUsarDlg::AddPoint(CString Location, CString Rotation)
+{
+ int x0,y0,z0;
+ int x,y,z;
+ int p1,p2;
+
+ if (bLOCK) return;
+ p1 = Location.Find(',');
+ if (p1==-1) return;
+ p2 = Location.Find(',',p1+1);
+ if (p2==-1) return;
+ x0 = (int)(-atof((LPCSTR)Location.Left(p1))*500);
+ x = (int)((float)x0*m_Zoom.scaleX+m_Zoom.offsetX);
+ y0 = (int)(-atof((LPCSTR)Location.Mid(p1+1,p2-p1))*500);
+ y = (int)((float)y0*m_Zoom.scaleY+m_Zoom.offsetY);
+ z0 = (int)(atof((LPCSTR)Location.Mid(p2+1))*500);
+ if (m_Movement.c_Location.x!=x0||m_Movement.c_Location.y!=y0||m_Movement.points.GetSize()==0) {
+ m_Movement.c_Location.x=x;
+ m_Movement.c_Location.y=y;
+ m_Movement.points.Add(m_Movement.c_Location);
+ m_Movement.c_Location.x=x0;
+ m_Movement.c_Location.y=y0;
+ m_Movement.raw.Add(m_Movement.c_Location);
+ m_Movement.z = z0;
+ m_Table.DrawPoint(&m_Movement);
+ }
+
+ p1 = Rotation.Find(',');
+ if (p1==-1) return;
+ p2 = Rotation.Find(',',p1+1);
+ if (p2==-1) return;
+ z = (int)(atof((LPCSTR)Rotation.Left(p1))*10430.37835);
+ x = (int)(atof((LPCSTR)Rotation.Mid(p1+1,p2-p1))*10430.37835);
+ y = (int)(atof((LPCSTR)Rotation.Mid(p2+1))*10430.37835);
+ if (m_Movement.c_Rotation.x!=x||m_Movement.c_Rotation.y!=y||m_Movement.points.GetSize()==0) {
+ m_Movement.c_Rotation.x=x;
+ m_Movement.c_Rotation.y=y;
+ m_Table.DrawPoint(&m_Movement);
+ }
+ if (m_Movement.points.GetSize()>=POINTSNUM) m_Movement.points.RemoveAt(0);
+ if (m_Movement.raw.GetSize()>=POINTSNUM) m_Movement.raw.RemoveAt(0);
+}
+
+void CUsarDlg::InitZoom()
+{
+ USARRoute * ur;
+ ur = ((USARRoute *)m_Table.m_tabPages[m_Table.m_tabCurrent]);
+ m_Zoom.offsetX = ur->m_OffsetX;
+ m_Zoom.offsetY = ur->m_OffsetY;
+ m_Zoom.scaleX = ur->m_ScaleX;
+ m_Zoom.scaleY = ur->m_ScaleY;
+}
+
+
+void CUsarDlg::UpdatePoints()
+{
+ POINT p;
+ int n = m_Movement.points.GetSize();
+ for (int i=0;i<n;i++) {
+ p = m_Movement.raw.GetAt(i);
+ p.x = (int)(p.x*m_Zoom.scaleX+m_Zoom.offsetX);
+ p.y = (int)(p.y*m_Zoom.scaleY+m_Zoom.offsetY);
+ m_Movement.points.SetAt(i,p);
+ }
+}
+
+void CUsarDlg::OnZoomIn()
+{
+ // TODO: Add your control notification handler code here
+ bLOCK = true;
+ m_Zoom.scaleX *= 2.0;
+ m_Zoom.scaleY *= 2.0;
+ UpdatePoints();
+ bLOCK = false;
+ m_Table.DrawPoint(&m_Movement);
+}
+
+
+void CUsarDlg::OnZoomOut()
+{
+ // TODO: Add your control notification handler code here
+ bLOCK = true;
+ m_Zoom.scaleX /= 2.0;
+ m_Zoom.scaleY /= 2.0;
+ UpdatePoints();
+ bLOCK = false;
+ m_Table.DrawPoint(&m_Movement);
+}
+
+void CUsarDlg::OnOriginal()
+{
+ // TODO: Add your control notification handler code here
+ bLOCK = true;
+ m_Zoom.scaleX = 0.2f;
+ m_Zoom.scaleY = 0.2f;
+ UpdatePoints();
+ bLOCK = false;
+ m_Table.DrawPoint(&m_Movement);
+}
+
+void CUsarDlg::OnClear()
+{
+ // TODO: Add your control notification handler code here
+ POINT p;
+ if (m_Movement.raw.GetSize()<1) return;
+ bLOCK = true;
+ p = m_Movement.raw.GetAt(m_Movement.raw.GetSize()-1);
+ m_Movement.raw.RemoveAll();
+ m_Movement.raw.Add(p);
+ p = m_Movement.points.GetAt(m_Movement.points.GetSize()-1);
+ m_Movement.points.RemoveAll();
+ m_Movement.points.Add(p);
+ bLOCK = false;
+ m_Table.DrawPoint(&m_Movement);
+}
+
+void CUsarDlg::OnDblclkList1()
+{
+ // TODO: Add your control notification handler code here
+ CString str;
+ m_Msg.GetText(m_Msg.GetCurSel(),str);
+ //MessageBox(str,"Message",MB_OK);
+ CMessagePanel msg = new CMessagePanel();
+ msg.SetMessage(str);
+ msg.DoModal();
+}
+
+void CUsarDlg::OnOK()
+{
+}
+
+void CUsarDlg::OnCancel()
+{
+}
Modified: usarsim/Tools/Usar_UI/UsarDlg.h
===================================================================
--- usarsim/Tools/Usar_UI/UsarDlg.h 2007-07-10 00:40:26 UTC (rev 648)
+++ usarsim/Tools/Usar_UI/UsarDlg.h 2007-07-11 16:23:30 UTC (rev 649)
@@ -102,6 +102,9 @@
DECLARE_MESSAGE_MAP()
private:
clock_t m_finishTime;
+protected:
+ virtual void OnOK();
+ virtual void OnCancel();
};
//{{AFX_INSERT_LOCATION}}
Modified: usarsim/Tools/player/server/drivers/usarsim/src/us_fakelocalize.cc
===================================================================
--- usarsim/Tools/player/server/drivers/usarsim/src/us_fakelocalize.cc 2007-07-10 00:40:26 UTC (rev 648)
+++ usarsim/Tools/player/server/drivers/usarsim/src/us_fakelocalize.cc 2007-07-11 16:23:30 UTC (rev 649)
@@ -23,9 +23,9 @@
}
this->bot = NULL;
- origin.px = cf->ReadTupleLength(section,"origin",0,FLT_MAX);
- origin.py = cf->ReadTupleLength(section,"origin",1,FLT_MAX);
- //origin.pa = cf->ReadTupleAngle(section,"origin",2,FLT_MAX);
+ origin.px = cf->ReadTupleLength(section,"origin",0,0);
+ origin.py = cf->ReadTupleLength(section,"origin",1,0);
+ //origin.pa = cf->ReadTupleAngle(section,"origin",2,0);
origin.pa = 0.0;
return;
Modified: usarsim/Tools/player/server/drivers/usarsim/src/us_position.cc
===================================================================
--- usarsim/Tools/player/server/drivers/usarsim/src/us_position.cc 2007-07-10 00:40:26 UTC (rev 648)
+++ usarsim/Tools/player/server/drivers/usarsim/src/us_position.cc 2007-07-11 16:23:30 UTC (rev 649)
@@ -48,7 +48,7 @@
return;
}
}
- strncpy(this->odo_name, cf->ReadString(section,"odo_name", DEFAULT_GAMEBOTS_CLASS),sizeof(this->odo_name));
+ strncpy(this->odo_name, cf->ReadString(section,"odo_name","Odometry"),sizeof(this->odo_name));
pthread_mutex_init(&posMutex, NULL);
// bot device
@@ -81,15 +81,20 @@
bot->steeringType = new char[128];
}
bot->devices |= US_CONF_ROBOT;
+ bot->devices |= US_GEOM_ROBOT;
char* cmd = new char[USBOT_MAX_CMD_LEN];
sprintf(cmd,"GETCONF {Type Robot}\r\n");
bot->AddCommand(cmd);
+ char* cmd2 = new char[USBOT_MAX_CMD_LEN];
+ sprintf(cmd2,"GETGEO {Type Robot}\r\n");
+ bot->AddCommand(cmd2);
int count =0;
- while (!bot->bConfRobot == true && count < USBOT_STARTUP_CONN_LIMIT)
+ while (!bot->bConfRobot == true && !bot->bGeoRobot == true && count < USBOT_STARTUP_CONN_LIMIT)
{
usleep(USBOT_DELAY_USEC);
count++;
}
+ setSteerType();
StartThread(); // Start the device thread
return 0;
@@ -115,35 +120,25 @@
int UsPosition::ProcessMessage(MessageQueue *resp_queue, player_msghdr *hdr, void *data)
{
if(Message::MatchMessage(hdr, PLAYER_MSGTYPE_REQ, PLAYER_POSITION2D_REQ_GET_GEOM, this->device_addr))
- {
- int count = 0;
- bot->devices |= US_GEOM_ROBOT;
+ {
PLAYER_MSG0(3,"POSITION REQ GEO\n");
- char* cmd = new char[USBOT_MAX_CMD_LEN];
- sprintf(cmd,"GETGEO {Type Robot}\r\n");
- bot->AddCommand(cmd);
-
- while (!bot->bGeoRobot == true && count <USBOT_STARTUP_CONN_LIMIT)
- {
- usleep(USBOT_DELAY_USEC);
- count++;
- }
if (!bot->bGeoRobot == true)
{
PLAYER_MSG0(3,"POSITION REQ GEO NACK\n");
this->Publish(this->device_addr,resp_queue,
- PLAYER_MSGTYPE_RESP_NACK,
- PLAYER_POSITION2D_REQ_GET_GEOM,
- (void*)bot->robotGeom,
- sizeof(player_position2d_geom_t),NULL);
+ PLAYER_MSGTYPE_RESP_NACK,
+ PLAYER_POSITION2D_REQ_GET_GEOM,
+ (void*)bot->robotGeom,
+ sizeof(player_position2d_geom_t),NULL);
return -1;
}
PLAYER_MSG0(3,"POSITION REQ GEO ACK\n");
- setSteerType();
this->Publish(this->device_addr,resp_queue,
- PLAYER_MSGTYPE_RESP_ACK,PLAYER_POSITION2D_REQ_GET_GEOM,
- (void*)bot->robotGeom, sizeof(player_position2d_geom_t),NULL);
+ PLAYER_MSGTYPE_RESP_ACK,
+ PLAYER_POSITION2D_REQ_GET_GEOM,
+ (void*)bot->robotGeom,
+ sizeof(player_position2d_geom_t),NULL);
return 0;
}
else if (Message::MatchMessage(hdr, PLAYER_MSGTYPE_REQ,
@@ -194,8 +189,8 @@
else
{//will only work if robot is stopped while turning
sprintf(cmd,"DRIVE {Left %f} {Right %f}\r\n",
- (trans - bot->maxWheelSeparation * rotate) / bot->wheelRadius,
- (trans + bot->maxWheelSeparation * rotate) / bot->wheelRadius);
+ (trans - 100.0 * bot->maxWheelSeparation * rotate) / bot->wheelRadius,
+ (trans + 100.0 * bot->maxWheelSeparation * rotate) / bot->wheelRadius);
}
}
else if(steer_type == ACKERMANNSTEERED)
Added: usarsim/TreasureHunt/Classes/TreasureHuntGame.uc
===================================================================
--- usarsim/TreasureHunt/Classes/TreasureHuntGame.uc (rev 0)
+++ usarsim/TreasureHunt/Classes/TreasureHuntGame.uc 2007-07-11 16:23:30 UTC (rev 649)
@@ -0,0 +1,99 @@
+class TreasureHuntGame extends USARDeathMatch;
+
+//
+// Restart a player. Since we want to use GameInfo.RestartPlayer
+// but this is overridden by BotDeathMatch.RestartPlayer, we need
+// to copy all of the GameInfo.RestartPlayer code, which is below.
+//
+function RestartPlayer( Controller aPlayer )
+{
+ local NavigationPoint startSpot;
+ local int TeamNum;
+ local class<Pawn> DefaultPlayerClass;
+ local Vehicle V, Best;
+ local vector ViewDir;
+ local float BestDist, Dist;
+
+ if(aPlayer.IsA('RemoteBot') || aPlayer.IsA('Player')) {
+ Super.RestartPlayer(aPlayer);
+ return;
+ }
+
+ log("RESTARTSOMETHING"@aPlayer);
+
+ if( bRestartLevel && Level.NetMode!=NM_DedicatedServer && Level.NetMode!=NM_ListenServer )
+ return;
+
+ if ( (aPlayer.PlayerReplicationInfo == None) || (aPlayer.PlayerReplicationInfo.Team == None) )
+ TeamNum = 255;
+ else
+ TeamNum = aPlayer.PlayerReplicationInfo.Team.TeamIndex;
+
+ startSpot = FindPlayerStart(aPlayer, TeamNum);
+ if( startSpot == None )
+ {
+ log(" Player start not found!!!");
+ return;
+ }
+
+ if (aPlayer.PreviousPawnClass!=None && aPlayer.PawnClass != aPlayer.PreviousPawnClass)
+ BaseMutator.PlayerChangedClass(aPlayer);
+
+ if ( aPlayer.PawnClass != None )
+ aPlayer.Pawn = Spawn(aPlayer.PawnClass,,,StartSpot.Location,StartSpot.Rotation);
+
+ if( aPlayer.Pawn==None )
+ {
+ DefaultPlayerClass = GetDefaultPlayerClass(aPlayer);
+ aPlayer.Pawn = Spawn(DefaultPlayerClass,,,StartSpot.Location,StartSpot.Rotation);
+ }
+ if ( aPlayer.Pawn == None )
+ {
+ log("Couldn't spawn player of type "$aPlayer.PawnClass$" at "$StartSpot);
+ aPlayer.GotoState('Dead');
+ if ( PlayerController(aPlayer) != None )
+ PlayerController(aPlayer).ClientGotoState('Dead','Begin');
+ return;
+ }
+ if ( PlayerController(aPlayer) != None )
+ PlayerController(aPlayer).TimeMargin = -0.1;
+ aPlayer.Pawn.Anchor = startSpot;
+ aPlayer.Pawn.LastStartSpot = PlayerStart(startSpot);
+ aPlayer.Pawn.LastStartTime = Level.TimeSeconds;
+ aPlayer.PreviousPawnClass = aPlayer.Pawn.Class;
+
+ aPlayer.Possess(aPlayer.Pawn);
+ aPlayer.PawnClass = aPlayer.Pawn.Class;
+
+ aPlayer.Pawn.PlayTeleportEffect(true, true);
+ aPlayer.ClientSetRotation(aPlayer.Pawn.Rotation);
+ AddDefaultInventory(aPlayer.Pawn);
+ TriggerEvent( StartSpot.Event, StartSpot, aPlayer.Pawn);
+
+ if ( bAllowVehicles && (Level.NetMode == NM_Standalone) && (PlayerController(aPlayer) != None) )
+ {
+ // tell bots not to get into nearby vehicles for a little while
+ BestDist = 2000;
+ ViewDir = vector(aPlayer.Pawn.Rotation);
+ for ( V=VehicleList; V!=None; V=V.NextVehicle )
+ if ( V.bTeamLocked && (aPlayer.GetTeamNum() == V.Team) )
+ {
+ Dist = VSize(V.Location - aPlayer.Pawn.Location);
+ if ( (ViewDir Dot (V.Location - aPlayer.Pawn.Location)) < 0 )
+ Dist *= 2;
+ if ( Dist < BestDist )
+ {
+ Best = V;
+ BestDist = Dist;
+ }
+ }
+
+ if ( Best != None )
+ Best.PlayerStartTime = Level.TimeSeconds + 8;
+ }
+}
+
+defaultproperties
+{
+}
+
\ No newline at end of file
Modified: usarsim/USARBot/Classes/AerialVehicle.uc
===================================================================
--- usarsim/USARBot/Classes/AerialVehicle.uc 2007-07-10 00:40:26 UTC (rev 648)
+++ usarsim/USARBot/Classes/AerialVehicle.uc 2007-07-11 16:23:30 UTC (rev 649)
@@ -25,16 +25,19 @@
local float time;
Super.timer();
+
+ if(!USARRemoteBot(Controller).emptyBattery) // If the battery is not empty, we can send the message
+ {
+ time = Level.TimeSeconds;
- time = Level.TimeSeconds;
+ outstring = "STA {Type AerialVehicle} {Time "$time$"}"$
+ " {LightToggle "$bHeadlightOn$"}"$
+ " {LightIntensity "$HeadlightItensity$"}"$
+ " {Battery "$(batteryLife-myLife)$"}"$
+ " {View "$ViewNum$"}";
- outstring = "STA {Type AerialVehicle} {Time "$time$"}"$
- " {LightToggle "$bHeadlightOn$"}"$
- " {LightIntensity "$HeadlightItensity$"}"$
- " {Battery "$(batteryLife-myLife)$"}"$
- " {View "$ViewNum$"}";
-
- USARRemoteBot(Controller).myConnection.SendLine(outstring);
+ USARRemoteBot(Controller).myConnection.SendLine(outstring);
+ }
}
function string getRobotGeo()
Modified: usarsim/USARBot/Classes/BallHSensor.uc
===================================================================
--- usarsim/USARBot/Classes/BallHSensor.uc 2007-07-10 00:40:26 UTC (rev 648)
+++ usarsim/USARBot/Classes/BallHSensor.uc 2007-07-11 16:23:30 UTC (rev 649)
@@ -109,7 +109,7 @@
halfResY = CameraYres/2;
//Computes perspective transformation constant
- K = float(halfResX)/(Tan(KRobot(Platform).CameraZoom[0]/(2*RAD2DEG)));
+ K = float(halfResX)/(Tan(KRobot(Platform).CamList[0].CameraFov/(2*RAD2DEG)));
K1= K / BallCamPos.X;
//Make perspective transformation
x2dMod = int(K1 * BallCamPos.Y);
Modified: usarsim/USARBot/Classes/GroundVehicle.uc
===================================================================
--- usarsim/USARBot/Classes/GroundVehicle.uc 2007-07-10 00:40:26 UTC (rev 648)
+++ usarsim/USARBot/Classes/GroundVehicle.uc 2007-07-11 16:23:30 UTC (rev 649)
@@ -35,41 +35,44 @@
Super.timer();
- time = Level.TimeSeconds;
+ if(!USARRemoteBot(Controller).emptyBattery) // If the battery is not empty, we can send the message
+ {
+ time = Level.TimeSeconds;
- // Front Steer and Rear Steer Angles are 0.00 by default
- FrontSteerAngle = "0.0000";
- RearSteerAngle = "0.0000";
+ // Front Steer and Rear Steer Angles are 0.00 by default
+ FrontSteerAngle = "0.0000";
+ RearSteerAngle = "0.0000";
- // Get the current front steer angle
- for(i=0; i<Wheels.Length; i++)
- {
- if(Wheels[i].SteerType == Front_Steered)
- {
- FrontSteerAngle = Converter.Str_AngleFromUU(utils.getSteerAngleOfKCarWheelJoint(KCarWheelJoint(Joints[Wheels[i].Number])));
- break;
- }
- }
+ // Get the current front steer angle
+ for(i=0; i<Wheels.Length; i++)
+ {
+ if(Wheels[i].SteerType == Front_Steered)
+ {
+ FrontSteerAngle = Converter.Str_AngleFromUU(utils.getSteerAngleOfKCarWheelJoint(KCarWheelJoint(Joints[Wheels[i].Number])));
+ break;
+ }
+ }
- // Get the current rear steer angle
- for(i=0; i<Wheels.Length; i++)
- {
- if(Wheels[i].SteerType == Rear_Steered)
- {
- RearSteerAngle = Converter.Str_AngleFromUU(utils.getSteerAngleOfKCarWheelJoint(KCarWheelJoint(Joints[Wheels[i].Number])));
- break;
- }
- }
+ // Get the current rear steer angle
+ for(i=0; i<Wheels.Length; i++)
+ {
+ if(Wheels[i].SteerType == Rear_Steered)
+ {
+ RearSteerAngle = Converter.Str_AngleFromUU(utils.getSteerAngleOfKCarWheelJoint(KCarWheelJoint(Joints[Wheels[i].Number])));
+ break;
+ }
+ }
- outstring = "STA {Type GroundVehicle} {Time "$time$"}"$
- " {FrontSteer "$FrontSteerAngle$"}"$
- " {RearSteer "$RearSteerAngle$"}"$
- " {LightToggle "$bHeadlightOn$"}"$
- " {LightIntensity "$HeadlightItensity$"}"$
- " {Battery "$(batteryLife-myLife)$"}"$
- " {View "$ViewNum$"}";
+ outstring = "STA {Type GroundVehicle} {Time "$time$"}"$
+ " {FrontSteer "$FrontSteerAngle$"}"$
+ " {RearSteer "$RearSteerAngle$"}"$
+ " {LightToggle "$bHeadlightOn$"}"$
+ " {LightIntensity "$HeadlightItensity$"}"$
+ " {Battery "$(batteryLife-myLife)$"}"$
+ " {View "$ViewNum$"}";
- USARRemoteBot(Controller).myConnection.SendLine(outstring);
+ USARRemoteBot(Controller).myConnection.SendLine(outstring);
+ }
}
function string getRobotGeo()
Modified: usarsim/USARBot/Classes/INSSensor.uc
===================================================================
--- usarsim/USARBot/Classes/INSSensor.uc 2007-07-10 00:40:26 UTC (rev 648)
+++ usarsim/USARBot/Classes/INSSensor.uc 2007-07-11 16:23:30 UTC (rev 649)
@@ -57,6 +57,7 @@
local Vector xyzTrue;
local Vector rotRate;
local float dist;
+ local Vector deltaLoc;
// Get rate of change from ground truth
xyzTrue = converter.LengthVectorFromUU(base.Location);
@@ -77,16 +78,22 @@
rotEst.y = converter.normRad_ZeroTo2PI(rotEst.y);
rotEst.z = converter.normRad_ZeroTo2PI(rotEst.z);
+ deltaLoc.x = xyzTrue.x-xyzPrev.x;
+ deltaLoc.y = xyzTrue.y-xyzPrev.y;
+ deltaLoc.z = xyzTrue.z-xyzPrev.z;
+ dist = sqrt( (deltaLoc.x * deltaLoc.x) +
+ (deltaLoc.y * deltaLoc.y) +
+ (deltaLoc.z * deltaLoc.z) );
+ xyzEst.x += deltaLoc.x + dist*utils.gaussRand(Mean,Sigma);
+ xyzEst.y += deltaLoc.y + dist*utils.gaussRand(Mean,Sigma);
+ xyzEst.z += deltaLoc.z + dist*utils.gaussRand(Mean,Sigma);
// Calculate total distance traveled in one time step
- dist = sqrt( (xyzTrue.x-xyzPrev.x) * (xyzTrue.x-xyzPrev.x) +
- (xyzTrue.y-xyzPrev.y) * (xyzTrue.y-xyzPrev.y) +
- (xyzTrue.z-xyzPrev.z) * (xyzTrue.z-xyzPrev.z) );
// Add Gaussian noise
- dist += dist * utils.gaussRand(Mean,Sigma);
+ // dist += dist * utils.gaussRand(Mean,Sigma);
// Update location estimate
- xyzEst.x = xyzEst.x + dist*Cos(rotEst.z)*Cos(rotEst.y);
- xyzEst.y = xyzEst.y + dist*Sin(rotEst.z)*Cos(rotEst.y);
- xyzEst.z = xyzEst.z + dist*Sin(rotEst.y);
+ // xyzEst.x = xyzEst.x + dist*Cos(rotEst.z)*Cos(rotEst.y);
+ // xyzEst.y = xyzEst.y + dist*Sin(rotEst.z)*Cos(rotEst.y);
@@ Diff output truncated at 60000 characters. @@
More information about the TeamTalk-developers
mailing list