📄 debugdlg.cpp
字号:
/*
void CDebugDlg::OnEAPFMove()
{
// TODO: Add your control notification handler code here
MSG lpMsg;
while(1)
{
PeekMessage(&lpMsg,NULL,0,0,PM_REMOVE);
if((GetKeyState(VK_RSHIFT) &0x80) == 0x80)
{
g_MyTeam[1].BasicAct(0,0,0,0);
break;
}
CVideoDlg::m_pVideoDlg->OnRead();
CVideoDlg::m_pVideoDlg->SearchObject();
// g_MyTeam[1].EAPFMove( g_Ball.Get_vPos() );
// g_MyTeam[1].SmartMove( g_Ball.Get_vPos(), 30 );
}
}
*/
/*
void CDebugDlg::OnRunmmtimer()
{
// TODO: Add your control notification handler code here
UpdateData(1);
CVideoDlg::m_pVideoDlg->OnRead();
CVideoDlg::m_pVideoDlg->SearchObject();
FILE* pFile=fopen("velocity.txt","a+");
int k=m_team*5+m_number-1;
fprintf(pFile,"g_MyTeam[%d]=(%f,%f),Angle=%f\n",k,g_MyTeam[k].Get_vPos().x,g_MyTeam[k].Get_vPos().y,g_MyTeam[k].Get_m_Angle());
m_xPos=g_MyTeam[k].Get_vPos().x;
m_yPos=g_MyTeam[k].Get_vPos().y;
UpdateData(0);
g_MyTeam[0].BasicAct(0,0,1,m_velocity*MAX_VELOCITY/256);
// Sleep(100);
// g_MyTeam[0].BasicAct(0,0,0,0);
g_MyTeam[0].SetMMTimer(m_times,DWORD(& g_MyTeam[0]),MMProc_Stop);
}
*/
void CDebugDlg::OnTry()
{
UpdateData(1);
// TODO: Add your control notification handler code here
//依次为1、2、3、4、5号
unsigned char m_PlayerNum = 0x00 ;
unsigned int m_NumBuffer ;
m_NumBuffer = ( m_Num == 5 ) ? 0 :( m_Num );
m_PlayerNum = m_NumBuffer << 5 | 30 ;
Player::SendSingleCommand( m_PlayerNum , m_RightForword , m_LeftForword ) ;
}
void CDebugDlg::OnSimpleact()
{
// TODO: Add your control notification handler code here
UpdateData(1);
g_MyTeam[m_Num].Set_vL( m_vl ) ;
g_MyTeam[m_Num].Set_vR( m_vr ) ;
g_MyTeam[m_Num].SendCommand( 300 ) ;
}
void CDebugDlg::OnRadio1()
{
// TODO: Add your control notification handler code here
m_LeftForword = 0x7f ;
}
void CDebugDlg::OnRadio2()
{
// TODO: Add your control notification handler code here
m_RightForword = 0x7f ;
}
void CDebugDlg::OnRadio3()
{
// TODO: Add your control notification handler code here
m_LeftForword = 0xff ;
}
void CDebugDlg::OnRadio4()
{
// TODO: Add your control notification handler code here
m_RightForword = 0xff ;
}
void CDebugDlg::OnTurnAndMoveTest()
{
// TODO: Add your control notification handler code here
//1、直接转弯
pDThread2->NewRound3();
//3、直接利用视觉和底层测速进行转角度和走直线
}
void CDebugDlg::OnTurnTo()
{
// TODO: Add your control notification handler code here
// g_MyTeam[m_Num].TurnTo( g_Ball.Get_vPos() ) ;
if ( m_pInfoDlg != NULL )
delete m_pInfoDlg ;
m_pInfoDlg = NULL ;
m_pInfoDlg = new CInfoDlg();
m_pInfoDlg->Create(IDD_INFO_DIALOG );//,(CMainFrame*)AfxGetMainWnd()
m_pInfoDlg->ShowWindow(SW_SHOW);
}
void CDebugDlg::OnTurnTest()
{
// TODO: Add your control notification handler code here
//2、产生新的对话框查看底层测速
if ( m_pControlDlg != NULL )
delete m_pControlDlg ;
m_pControlDlg = NULL ;
m_pControlDlg = new CControlDlg();
m_pControlDlg->Create(IDD_CONTROL_DIALOG );//,(CMainFrame*)AfxGetMainWnd()
m_pControlDlg->ShowWindow(SW_SHOW);
}
void CDebugDlg::OnBotelv()
{
// TODO: Add your control notification handler code here
Player::InitComm(1,9600);//初始化串口
}
void CDebugDlg::OnBotelv2()
{
// TODO: Add your control notification handler code here
Player::InitComm(1,19200);//初始化串口
}
void CDebugDlg::OnButton3()
{
// TODO: Add your control notification handler code here
pDThread->NewRound2();
}
#define findball1 1
#define findball2 4
#define defenceball1 3
#define defenceball2 2
#define goalieball 5
void CDebugDlg::OnButton4()
{
// TODO: Add your control notification handler code here
while(1)
{
if((GetKeyState(VK_RSHIFT) &0x80) == 0x80)
{
g_MyTeam[1].BasicAct(0,0,0,0);
g_MyTeam[2].BasicAct(0,0,0,0);
g_MyTeam[3].BasicAct(0,0,0,0);
g_MyTeam[4].BasicAct(0,0,0,0);
g_MyTeam[5].BasicAct(0,0,0,0);
return ;
}
switch(monitor.playmode)
{
case 'H':case 'S':case 'k':case'K':case 'p':case 'P':case 'f':case'F':case 'i':case'I':case't':case 'T':case '':case 'z':case 'Z':case 'g':case 'G':case 'd':case 'D':case 'y':case 'Y':case 'r':case 'R':case 'c'
{
Player::AllStop();
break;
}
case 's':case '1':case 'h':case '2':case 'o':case 'O':case 'a':
{
pDThread->VisualProc();
//FindBall决策
if(isScanBall)
{
if(isScanMyteam[findball1-1])//采用FindBall决策的机器人编号1
{
g_MyTeam[findball1].losttime=0;
g_Deci[findball1].Boundary(g_MyTeam[findball1]);
if (!g_Deci[findball1].isboundary)
{
g_Deci[findball1].FindBall(g_MyTeam[findball1]);
}
}
else
{
g_MyTeam[findball1].losttime++;
g_Deci[findball1].LostObject(g_MyTeam[findball1]);
}
if(isScanMyteam[findball2-1])//采用FindBall决策的机器人编号2
{
g_MyTeam[findball2].losttime=0;
g_Deci[findball2].Boundary(g_MyTeam[findball2]);
if (!g_Deci[findball2].isboundary)
{
g_Deci[findball2].FindBall(g_MyTeam[findball2]);
}
}
else
{
g_MyTeam[findball2].losttime++;
g_Deci[findball2].LostObject(g_MyTeam[findball2]);
}
////////////////////////////////////////////////////////////////////////////////////
if(isScanMyteam[defenceball1-1])//采用DefenceBall决策的机器人编号
{
g_MyTeam[defenceball1].losttime=0;
g_Deci[defenceball1].Boundary(g_MyTeam[defenceball1]);
if (!g_Deci[defenceball1].isboundary)
{
if(g_Ball.Get_vPos().x <=abs(Player::FieldStruct.m_Field.Width()*3/8))
{
g_Deci[defenceball1].FindBall(g_MyTeam[defenceball1]);
}
}
}
else
{
g_MyTeam[defenceball1].losttime++;
if(g_MyTeam[defenceball1].losttime>30)
{
g_Deci[defenceball1].LostObject(g_MyTeam[defenceball1]);
}
}
if(isScanMyteam[defenceball2-1])//采用DefenceBall决策的机器人编号
{
g_MyTeam[defenceball2].losttime=0;
g_Deci[defenceball2].Boundary(g_MyTeam[defenceball2]);
if (!g_Deci[defenceball2].isboundary)
{
if(g_Ball.Get_vPos().x <=abs(Player::FieldStruct.m_Field.Width()*3/8))
{
g_Deci[defenceball2].FindBall(g_MyTeam[defenceball2]);
}
}
}
else
{
g_MyTeam[defenceball2].losttime++;
if(g_MyTeam[defenceball1].losttime>30)
{
g_Deci[defenceball2].LostObject(g_MyTeam[defenceball1]);
}
}
////////////////////////////////////////////////////////////////////////////////////////////////
if(isScanMyteam[goalieball-1])//采用GoalieBall决策的机器人编号
{
g_MyTeam[goalieball].losttime=0;
g_Deci[goalieball].Boundary(g_MyTeam[defenceball2]);
if (!g_Deci[goalieball].isboundary)
{
if(g_Ball.Get_vPos().x <=abs(Player::FieldStruct.m_Field.Width()/6))
{
g_Deci[goalieball].FindBall(g_MyTeam[goalieball]);
}
}
}
else
{
g_MyTeam[goalieball].losttime++;
if(g_MyTeam[goalieball].losttime>30)
{
g_Deci[goalieball].LostObject(g_MyTeam[goalieball]);
}
}
}
}
}
}
void CDebugDlg::OnButton6()
{
// TODO: Add your control notification handler code here
while(1)
{
if((GetKeyState(VK_RSHIFT) &0x80) == 0x80)
{
g_MyTeam[1].BasicAct(0,0,0,0);
g_MyTeam[2].BasicAct(0,0,0,0);
g_MyTeam[3].BasicAct(0,0,0,0);
g_MyTeam[4].BasicAct(0,0,0,0);
g_MyTeam[5].BasicAct(0,0,0,0);
return ;
}
switch(monitor.playmode)
{
case 'H':case 'S':case 'k':case'K':case 'p':case 'P':case 'f':case'F':case 'i':case'I':case't':case 'T':case '':case 'z':case 'Z':case 'g':case 'G':case 'd':case 'D':case 'y':case 'Y':case 'r':case 'R':case 'c'
{
Player::AllStop();
break;
}
case 's':case '1':case 'h':case '2':case 'o':case 'O':case 'a':
{
pDThread->TransVisualProc();
//FindBall决策
if(isScanBall)
{
if(isScanMyteam[findball1-1])//采用FindBall决策的机器人编号1
{
g_MyTeam[findball1].losttime=0;
g_Deci[findball1].Boundary(g_MyTeam[findball1]);
if (!g_Deci[findball1].isboundary)
{
g_Deci[findball1].FindBall(g_MyTeam[findball1]);
}
}
else
{
g_MyTeam[findball1].losttime++;
g_Deci[findball1].LostObject(g_MyTeam[findball1]);
}
if(isScanMyteam[findball2-1])//采用FindBall决策的机器人编号2
{
g_MyTeam[findball2].losttime=0;
g_Deci[findball2].Boundary(g_MyTeam[findball2]);
if (!g_Deci[findball2].isboundary)
{
g_Deci[findball2].FindBall(g_MyTeam[findball2]);
}
}
else
{
g_MyTeam[findball2].losttime++;
g_Deci[findball2].LostObject(g_MyTeam[findball2]);
}
////////////////////////////////////////////////////////////////////////////////////
if(isScanMyteam[defenceball1-1])//采用DefenceBall决策的机器人编号
{
g_MyTeam[defenceball1].losttime=0;
g_Deci[defenceball1].Boundary(g_MyTeam[defenceball1]);
if (!g_Deci[defenceball1].isboundary)
{
if(g_Ball.Get_vPos().x <=abs(Player::FieldStruct.m_Field.Width()*3/8))
{
g_Deci[defenceball1].FindBall(g_MyTeam[defenceball1]);
}
}
}
else
{
g_MyTeam[defenceball1].losttime++;
if(g_MyTeam[defenceball1].losttime>30)
{
g_Deci[defenceball1].LostObject(g_MyTeam[defenceball1]);
}
}
if(isScanMyteam[defenceball2-1])//采用DefenceBall决策的机器人编号
{
g_MyTeam[defenceball2].losttime=0;
g_Deci[defenceball2].Boundary(g_MyTeam[defenceball2]);
if (!g_Deci[defenceball2].isboundary)
{
if(g_Ball.Get_vPos().x <=abs(Player::FieldStruct.m_Field.Width()*3/8))
{
g_Deci[defenceball2].FindBall(g_MyTeam[defenceball2]);
}
}
}
else
{
g_MyTeam[defenceball2].losttime++;
if(g_MyTeam[defenceball1].losttime>30)
{
g_Deci[defenceball2].LostObject(g_MyTeam[defenceball1]);
}
}
////////////////////////////////////////////////////////////////////////////////////////////////
if(isScanMyteam[goalieball-1])//采用GoalieBall决策的机器人编号
{
g_MyTeam[goalieball].losttime=0;
g_Deci[goalieball].Boundary(g_MyTeam[defenceball2]);
if (!g_Deci[goalieball].isboundary)
{
if(g_Ball.Get_vPos().x <=abs(Player::FieldStruct.m_Field.Width()/6))
{
g_Deci[goalieball].FindBall(g_MyTeam[goalieball]);
}
}
}
else
{
g_MyTeam[goalieball].losttime++;
if(g_MyTeam[goalieball].losttime>30)
{
g_Deci[goalieball].LostObject(g_MyTeam[goalieball]);
}
}
}
}
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -