hi all
i am using mfc dialo based application vc++ 6 for my software development. i a button on box, connect and placed my code under connect buton tab. when i run the application and press connect buton dialog box frezez and i cant even cancel that. so please help me in these regards so that i can control that process from other tabs, the code is given below,
void CGoto2Dlg::OnConnect()
{
// TODO: Add your control notification handler code here
ArSerialConnection serConn;
ArTcpConnection tcpConn;
// robot
ArRobot robot;
ArActionGoto first("goto", ArPose(3000,000));
ArActionGoto second("goto", ArPose(3500,1000));
ArActionGoto third("goto", ArPose(300,1000));
ArActionGoto fourth("goto", ArPose(300,200));
// mandatory init
Aria::init();
// First we see if we can open the tcp connection, if we can we'll
// assume we're connecting to the sim, and just go on... if we
// can't open the tcp it means the sim isn't there, so just try the
// robot
tcpConn.setPort();
// see if we can get to the simulator (true is success)
if (tcpConn.openSimple())
{
// we could get to the sim, so set the robots device connection to the sim
printf("Connecting to simulator through tcp.\n");
robot.setDeviceConnection(&tcpConn);
}
else
{
// we couldn't get to the sim, so set the port on the serial
// connection and then set the serial connection as the robots
// device
// modify the next line if you're not using the first serial port
// to talk to your robot
serConn.setPort();
printf(
"Could not connect to simulator, connecting to robot through serial.\n");
robot.setDeviceConnection(&serConn);
}
// add the sonar to the robot
robot.addRangeDevice(&sonar);
// try to connect, if we fail exit
if (!robot.blockingConnect())
{
printf("Could not connect to robot... exiting\n");
Aria::shutdown();
// return 1;
}
// turn on the motors, turn off amigobot sounds
robot.comInt(ArCommands::ENABLE, 1);
// add the actions
robot.addAction(&tableLimiter, 100);
robot.addAction(&limiter, 95);
robot.addAction(&limiterFar, 90);
robot.addAction(&bump, 80);
robot.addAction(&first, 20);
robot.addAction(&second, 19);
robot.addAction(&third, 18);
robot.addAction(&fourth, 17);
//robot.addAction(&fifth, 16);
//robot.addAction(&sixth, 15);
//robot.addAction(&seventh, 14);
// start the robot running, true so that if we lose connection the run stops
robot.run(true);
// now exit
Aria::shutdown();
}