Ejemplo n.º 1
0
int main()
{
	int numPlaneLength = sizeof(numPlanes) / sizeof(int);
	int fieldSizesLength = sizeof(fieldSizes) / sizeof(int);
	
	srand(seed);

	printf("\nSettings:\n");
	printf("Output directory: %s\n", OUTPUT_DIRECTORY);
	printf("Course Corner: (%lf, %lf)\n", NORTH_MOST_LATITUDE, WEST_MOST_LONGITUDE);
	printf("Number of courses per setting: %d\n", COURSES_PER_SETTING);
	printf("Plane buffer space: %lf meters\n", BUFFER_SPACE);
	printf("Number of planes list: {");
	for(int i = 0; i < numPlaneLength; i++)
	{
		printf("%d", numPlanes[i]);
		if(i+1 != numPlaneLength) printf(", ");
		else printf("}\n");
	}
	printf("Field sizes list: {");
	for(int i = 0; i < fieldSizesLength; i++)
	{
		printf("%d", fieldSizes[i]);
		if(i+1 != fieldSizesLength) printf(", ");
		else printf("}\n");
	}
	
	printf("Generating...");
	for(int numPlaneIndex = 0; numPlaneIndex < numPlaneLength; numPlaneIndex++)
	{
		for(int fieldSizesIndex = 0; fieldSizesIndex < fieldSizesLength; fieldSizesIndex++)
		{
			for(int courseNum = 0; courseNum < COURSES_PER_SETTING; courseNum++)
			{
				generateCourse(numPlanes[numPlaneIndex], fieldSizes[fieldSizesIndex], courseNum+1);
			}
			//printf("\n");
		}
	}
	printf("Done!\n\n");
	
	return 0;
}
Ejemplo n.º 2
0
int main()
{

	//changed

	std::string input;
	std::stringstream ss1;
	int numSims;
	bool prompt = false;

	//get the number of courses to generate, put it in numSims,
	//and make sure the user enters a number
	do{
		std::cout << "Enter the number of courses to generate: ";
	}while(!getInt(&numSims,'\n'));
	

	//only ask certain questions if more than 3 courses are being made
	if(numSims > 3){prompt = true;}

	//these hold one value for each simulation
	int allPlanes [numSims]; //holds the number of planes for each sim
	int allWayPoints[numSims];	//the number of waypoints for each sim
	int allFields [numSims];	//length of the square field for each sim

	//these will potentially hold values that are common for all simulations
	//if they exists
	int nPlanes = -1;		
	int nWayPoints = -1;
	int nFields = -1;

	//other
	int count = 0;	//iteration variable
	char yn = '\0';	//for response to a yes no question

	
	//see if there is a number of planes for all sims, otherwise prompt for all values
	if(prompt && needOne("planes",&nPlanes)){}//do nothing else
	else{
		std::cout << "Enter number of planes for each simulation separated by a space:\n\n ";
		while(count<numSims-1){
			//std::cin >> allPlanes[count++];
			getInt(&(allPlanes[count++]),' ');
		}
		//get the last one, delim on the newline
		getInt(&(allPlanes[count]),'\n');
		count = 0;
	}
	//std::cin.clear();


	//same thing as with the planes but with waypoints
	if(prompt && needOne("wayPoints",&nWayPoints)){}
	else{
		std::cout << "Enter number of wayPoints for each plane in each simulation separated by a space:\n ";
		std::cout << "(The number of wayPoints in a given simulation is constant fo every plane.)\n";
		while(count<numSims-1){
			getInt(&(allWayPoints[count++]),' ');
		}
		getInt(&(allWayPoints[count++]),'\n');
		count = 0;
	}

	

	//same thing with field length
	if(prompt && needOne("field length",&nFields)){}
	else{
		std::cout << "Enter length of the field for each simulation separated by a space:\n\n ";
		while(count<numSims-1){
			getInt(&(allFields[count++]),' ');
		}
		getInt(&(allFields[count++]),'\n');
		count = 0;
	}

	std::string fn;
	std::cout << "\nEnter the base name for all files: ";
	//std::cout << "(the number of planes, and size of field will be added to the name, as well as a counter)\n";
	std::getline(std::cin,fn);
	
	fileName = fn.c_str();


	char autoPathName [1000];
	sprintf(autoPathName,"%s/%s%s",OUTPUT_DIRECTORY,fileName,AUTO_EXTENSION);
	//sprintf(autoPathName,"%s/%s%s",(ros::package::getPath("AU_UAV_ROS")+"/courses/"+autoFile+AUTOEXTENSION).c_str());
	autoFP = fopen(autoPathName,"w");



	//if a common value was entered, put that value in each position of the array
	if(nPlanes > 0){
		populateArray(allPlanes,nPlanes,numSims);
	}

	if(nWayPoints > 0){
		populateArray(allWayPoints,nWayPoints,numSims);
	}

	if(nFields > 0){
		populateArray(allFields,nFields,numSims);
	}


	//these are the predefined constants
	std::cout << "\nSettings:\n";
	std::cout << "OUTPUT DIRECTORY: " << OUTPUT_DIRECTORY <<"\n";
	std::cout << "Northwest Corner: ("<<NORTH_MOST_LATITUDE<<","<<WEST_MOST_LONGITUDE<<")\n";
	std::cout << "Plane buffer space: " << BUFFER_SPACE <<"\n";
	std::cout << "Generating...";


	//generate all the course files
	count =0;
	while(count<numSims){
		generateCourse(allPlanes[count],allWayPoints[count],allFields[count],count);
		count = count + 1;
	}


	fclose(autoFP);

}//end of main