📄 infodlg.cpp
字号:
// InfoDlg.cpp : implementation file
//
#include "stdafx.h"
#include "Robocup.h"
#include "InfoDlg.h"
#include "DebugDlg.h"
#include "global.h"
#include "VideoDlg.h"
#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif
/////////////////////////////////////////////////////////////////////////////
// CInfoDlg dialog
CInfoDlg::CInfoDlg(CWnd* pParent /*=NULL*/)
: CDialog(CInfoDlg::IDD, pParent)
{
//{{AFX_DATA_INIT(CInfoDlg)
m_robot_angle = 0.0;
m_robot_x_pos = 0.0;
m_robot_y_pos = 0.0;
m_ball_pos_x = 0.0;
m_ball_pos_y = 0.0;
m_robot_angle2 = 0.0;
m_robot_angle3 = 0.0;
m_robot_angle4 = 0.0;
m_robot_angle5 = 0.0;
m_robot_pos_x2 = 0.0;
m_robot_pos_x3 = 0.0;
m_robot_pos_x4 = 0.0;
m_robot_pos_x5 = 0.0;
m_robot_pos_y2 = 0.0;
m_robot_pos_y3 = 0.0;
m_robot_pos_y4 = 0.0;
m_robot_pos_y5 = 0.0;
m_robot1_vl = 0;
m_robot2_vl = 0;
m_robot3_vl = 0;
m_robot4_vl = 0;
m_robot5_vl = 0;
m_robot5_vr = 0;
m_robot4_vr = 0;
m_robot3_vr = 0;
m_robot2_vr = 0;
m_robot1_vr = 0;
m_command = 0;
m_controltime = 0;
//}}AFX_DATA_INIT
}
void CInfoDlg::DoDataExchange(CDataExchange* pDX)
{
CDialog::DoDataExchange(pDX);
//{{AFX_DATA_MAP(CInfoDlg)
DDX_Text(pDX, IDC_ROBOT_ANGLE, m_robot_angle);
DDX_Text(pDX, IDC_ROBOT_X_POS, m_robot_x_pos);
DDX_Text(pDX, IDC_ROBOT_Y_POS, m_robot_y_pos);
DDX_Text(pDX, IDC_BALL_POS_X, m_ball_pos_x);
DDX_Text(pDX, IDC_BALL_POS_Y, m_ball_pos_y);
DDX_Text(pDX, IDC_ROBOT_ANGLE2, m_robot_angle2);
DDX_Text(pDX, IDC_ROBOT_ANGLE3, m_robot_angle3);
DDX_Text(pDX, IDC_ROBOT_ANGLE4, m_robot_angle4);
DDX_Text(pDX, IDC_ROBOT_ANGLE5, m_robot_angle5);
DDX_Text(pDX, IDC_ROBOT_X_POS2, m_robot_pos_x2);
DDX_Text(pDX, IDC_ROBOT_X_POS3, m_robot_pos_x3);
DDX_Text(pDX, IDC_ROBOT_X_POS4, m_robot_pos_x4);
DDX_Text(pDX, IDC_ROBOT_X_POS5, m_robot_pos_x5);
DDX_Text(pDX, IDC_ROBOT_Y_POS2, m_robot_pos_y2);
DDX_Text(pDX, IDC_ROBOT_Y_POS3, m_robot_pos_y3);
DDX_Text(pDX, IDC_ROBOT_Y_POS4, m_robot_pos_y4);
DDX_Text(pDX, IDC_ROBOT_Y_POS5, m_robot_pos_y5);
DDX_Text(pDX, IDC_ORDER1_L, m_robot1_vl);
DDX_Text(pDX, IDC_ORDER2_L, m_robot2_vl);
DDX_Text(pDX, IDC_ORDER3_L, m_robot3_vl);
DDX_Text(pDX, IDC_ORDER4_L, m_robot4_vl);
DDX_Text(pDX, IDC_ORDER5_L, m_robot5_vl);
DDX_Text(pDX, IDC_ORDER5_R, m_robot5_vr);
DDX_Text(pDX, IDC_ORDER4_R, m_robot4_vr);
DDX_Text(pDX, IDC_ORDER3_R, m_robot3_vr);
DDX_Text(pDX, IDC_ORDER2_R, m_robot2_vr);
DDX_Text(pDX, IDC_ORDER1_R, m_robot1_vr);
DDX_Text(pDX, IDC_BINARY, m_command);
DDX_Text(pDX, IDC_CONTROLTIME, m_controltime);
DDV_MinMaxUInt(pDX, m_controltime, 0, 300);
//}}AFX_DATA_MAP
}
BEGIN_MESSAGE_MAP(CInfoDlg, CDialog)
//{{AFX_MSG_MAP(CInfoDlg)
ON_WM_CREATE()
ON_BN_CLICKED(IDC_DISPLAY, OnDisplay)
ON_BN_CLICKED(IDC_DECPROC, OnDecproc)
ON_BN_CLICKED(IDC_ONESTEP, OnOnestep)
ON_BN_CLICKED(IDC_TURNANDMOVE, OnTurnandmove)
ON_BN_CLICKED(IDC_SEND, OnSend)
ON_BN_CLICKED(IDC_BUTTON1, OnTimeControlSend)
//}}AFX_MSG_MAP
END_MESSAGE_MAP()
/////////////////////////////////////////////////////////////////////////////
// CInfoDlg message handlers
int CInfoDlg::OnCreate(LPCREATESTRUCT lpCreateStruct)
{
if (CDialog::OnCreate(lpCreateStruct) == -1)
return -1;
// TODO: Add your specialized creation code here
// UpdateData( TRUE ) ;
// m_robot_y_pos = g_MyTeam[m_pDebugDlg->m_Num].Get_vPos().y;
// m_robot_num = m_pDebugDlg->m_Num;
return 0;
}
void CInfoDlg::OnDisplay()
{
// TODO: Add your control notification handler code here
// CVideoDlg::m_pVideoDlg->OnRead();
// CVideoDlg::m_pVideoDlg->SearchObject();
//角度显示:
m_robot_angle = g_MyTeam[1].m_Angle ;
m_robot_angle2 = g_MyTeam[2].m_Angle ;
m_robot_angle3 = g_MyTeam[3].m_Angle ;
m_robot_angle4 = g_MyTeam[4].m_Angle ;
m_robot_angle5 = g_MyTeam[5].m_Angle ;
//横坐标显示:
m_robot_x_pos = g_MyTeam[1].m_vPos.x;
m_robot_pos_x2 = g_MyTeam[2].m_vPos.x;
m_robot_pos_x3 = g_MyTeam[3].m_vPos.x;
m_robot_pos_x4 = g_MyTeam[4].m_vPos.x;
m_robot_pos_x5 = g_MyTeam[5].m_vPos.x;
//纵坐标显示:
m_robot_y_pos = g_MyTeam[1].m_vPos.y;
m_robot_pos_y2 = g_MyTeam[2].m_vPos.y;
m_robot_pos_y3 = g_MyTeam[3].m_vPos.y;
m_robot_pos_y4 = g_MyTeam[4].m_vPos.y;
m_robot_pos_y5 = g_MyTeam[5].m_vPos.y;
//球的位置显示
m_ball_pos_x = g_Ball.m_vPos.x ;
m_ball_pos_y = g_Ball.m_vPos.y ;
//纪录扫描出来的数据
FILE *pFILE ;
pFILE = fopen( "Infomation of the robots.txt" , "a+" );
for ( int i = 1 ; i < 6 ; i++ )
{
fprintf( pFILE , "Robot %d--- x: %f y:%f angle:%f\n", i , g_MyTeam[i].m_vPos.x , g_MyTeam[i].m_vPos.y , g_MyTeam[i].m_Angle ) ;
if( i == 5 )
{
fprintf( pFILE , "\n\n" ) ;
}
}
fclose ( pFILE ) ;
// ASSERT( TRUE ) ;
UpdateData( FALSE ) ;
}
void CInfoDlg::OnDecproc()
{
// TODO: Add your control notification handler code here
/* int n[6];
for ( int i = 1 ; i <6 ; i++ )
{
g_Deci[i].ChooseDots( g_MyTeam[i] );
n[i] = g_Deci[i].ComputeIndex1( g_MyTeam[i] );
}
m_robot1_vl = ReturnOrder ( n[1] ).x ;
m_robot1_vr = ReturnOrder ( n[1] ).y ;
m_robot2_vl = ReturnOrder ( n[2] ).x ;
m_robot2_vr = ReturnOrder ( n[2] ).y ;
m_robot3_vl = ReturnOrder ( n[3] ).x ;
m_robot3_vr = ReturnOrder ( n[3] ).y ;
m_robot4_vl = ReturnOrder ( n[4] ).x ;
m_robot4_vr = ReturnOrder ( n[4] ).y ;
m_robot5_vl = ReturnOrder ( n[5] ).x ;
m_robot5_vr = ReturnOrder ( n[5] ).y ;
*/
g_Deci[1].ChooseDots( g_MyTeam[1] ) ;
m_order[1] = g_Deci[1].ComputeIndex1( g_MyTeam[1] );
m_robot1_vl = ReturnOrder( m_order[1] ).x ;
m_robot1_vr = ReturnOrder( m_order[1] ).y ;
UpdateData( FALSE );
}
Vector CInfoDlg::ReturnOrder( int ActionOrder )
{
switch( ActionOrder )
{
case 0:
{
return Vector( 255*MAX_VELOCITY/255 , 255*MAX_VELOCITY/255 );
}
case 1:
{
return Vector(255*MAX_VELOCITY/256 , 230*MAX_VELOCITY/256);
}
case 2:
{
return Vector (255*MAX_VELOCITY/256 , 210*MAX_VELOCITY/256);
}
case 3:
{
return Vector (255*MAX_VELOCITY/256,190*MAX_VELOCITY/256);
}
case 4:
{
return Vector (-255*MAX_VELOCITY/256 , -230*MAX_VELOCITY/256);
}
case 5:
{
return Vector (-255*MAX_VELOCITY/256 , -210*MAX_VELOCITY/256);
}
case 6:
{
return Vector (-255*MAX_VELOCITY/256 , -255*MAX_VELOCITY/256);
}
case 7:
{
return Vector(-230*MAX_VELOCITY/256 , -255*MAX_VELOCITY/256);
}
case 8:
{
return Vector(-210*MAX_VELOCITY/256 , -255*MAX_VELOCITY/256);
}
case 9:
{
return Vector(-190*MAX_VELOCITY/256 , -255*MAX_VELOCITY/256);
}
case 10:
{
return Vector(210*MAX_VELOCITY/256 , 255*MAX_VELOCITY/256);
}
case 11:
{
return Vector(230*MAX_VELOCITY/256 , 255*MAX_VELOCITY/256);
}
case 12: //向左转一个角度
{
return Vector(-255*MAX_VELOCITY/256 , 255*MAX_VELOCITY/256);
}
case 13: //左转
{
return Vector(-255*MAX_VELOCITY/256 , 255*MAX_VELOCITY/256);
}
case 14: //右转
{
return Vector(255*MAX_VELOCITY/256 , -255*MAX_VELOCITY/256);
}
case 15: //停止
{
return Vector( 0 , 0 ) ;
}
default:
return Vector( -1, -1 );
}
return Vector( -1 ,-1 );
}
void CInfoDlg::OnOnestep()
{
// TODO: Add your control notification handler code here
g_MyTeam[1].SimpleAction( m_order[1] );
}
void CInfoDlg::OnTurnandmove()
{
// TODO: Add your control notification handler code here
unsigned char command2 ;
command2 = Player::TurnToExact( g_Ball.m_vPos ) ;
m_command = command2 ;
// m_command.
UpdateData( FALSE ) ;
// Player::MoveToExact( g_Ball.m_vPos ) ;
}
void CInfoDlg::OnSend()
{
// TODO: Add your control notification handler code here
Player::SendSingleCommand2( 1 ,m_command, 1 );
}
void CInfoDlg::OnTimeControlSend()
{
// TODO: Add your control notification handler code here
//老版本,根据时间来控制角度,算法实现
g_MyTeam[1].Set_vL( -250 ) ;
g_MyTeam[1].Set_vR( 250 ) ;
g_MyTeam[1].SendCommand( m_controltime );
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -