00001 00016 #include <controllers/positionControllers/defaultPositionController.h> 00017 00018 namespace srAlmende { 00019 00020 /* 00021 * This function is used to reset the robot to a new position during training 00022 * For some applications it is a random position, and some a fixed position 00023 * Set the object to be viewed on location (0,0) in the scenario xml 00024 * Set the robot to position (0,-10) in the scenario xml 00025 */ 00026 void DefaultPositionController::resetRobot() { 00027 00028 /* 00029 resetRobotFlag = false; 00030 resetTimer = time(NULL); 00031 srand( time(NULL) ); 00032 osg::Vec3 trans = getRobotPosition(); 00033 if(trans[2] > 1) 00034 { 00035 std::cout << "not on the ground" << std::endl; 00036 return; 00037 } 00038 00039 // If the robot is not learning reset it to (x,y) x and y are [-20,20] 00040 if(!learnToDrive && !learnBL) 00041 { 00042 trans[0] = (rand() % 40)-20; 00043 trans[1] = (rand() % 40)-20; 00044 } 00045 else 00046 { 00047 trans[0] = 0; 00048 trans[1] = -10; 00049 // place on a different distance from the source 00050 if(learnToDrive) 00051 trans[1] = (rand() % 15)-20; 00052 } 00053 // Randomly rotate the robot between -120 and -60 degrees 00054 osg::Vec3 rot = getRobotRotation(); 00055 rot[0] = (-90-rot[0]); 00056 int rotVal = (rand() % 60)-30; 00057 rot[0] += rotVal; 00058 00059 00060 setRobotRotation(rot); 00061 setRobotTranslation(trans); 00062 */ 00063 } 00064 00065 00066 }
1.6.1