Пример #1
0
/*
main(...)
This just sets up all the ROS stuff and serves as the primary top level menu
*/
int main(int argc, char **argv)
{
    //Standard ROS startup
    ros::init(argc, argv, "GUIInterfacer");
    ros::NodeHandle n;

    //advertise service - New - JC
    ros::ServiceServer fileNameService = n.advertiseService("send_file_path", setFileName);

    //setup client services
    createSimulatedPlaneClient = n.serviceClient<AU_UAV_ROS::CreateSimulatedPlane>("create_simulated_plane");
    deleteSimulatedPlaneClient = n.serviceClient<AU_UAV_ROS::DeleteSimulatedPlane>("delete_simulated_plane");
    requestPlaneIDClient = n.serviceClient<AU_UAV_ROS::RequestPlaneID>("request_plane_ID");
    goToWaypointClient = n.serviceClient<AU_UAV_ROS::GoToWaypoint>("go_to_waypoint");
    loadPathClient = n.serviceClient<AU_UAV_ROS::LoadPath>("load_path");
    loadCourseClient = n.serviceClient<AU_UAV_ROS::LoadCourse>("load_course");
    initiateCoordinator = n.serviceClient<AU_UAV_ROS::StartCoordinator>("start_coordinator");
    initiateCollisionAvoidance = n.serviceClient<AU_UAV_ROS::StartCollisionAvoidance>("start_collision_avoidance");
    initiateSimulator = n.serviceClient<AU_UAV_ROS::StartSimulator>("start_simulator");
    initiateXbeeIO = n.serviceClient<AU_UAV_ROS::StartXbeeIO>("start_xbeeio");
    //initiateEvaluator = n.serviceClient<AU_UAV_ROS::StartEvaluator>("start_evaluator");

    //make sure all other nodes have time to activate
    sleep(1);

    //new - JC - We cannot spin() because it will never stop, but we need to get our service callbacks so let's spin until we get the service call.
        ros::Rate r(10); // 10 hz
        while (!fileNameLoaded)
        {
        ros::spinOnce();
        r.sleep();
        }

    startNodes();
    //make sure all other nodes have time to activate
    sleep(1);

//send service call to next node in line - in that node have a blocking call in main that just does the above and make the boolean true when the service is called 
    initiateTest();

    return 0;
}
void RequestGenerator::wakeup()
{
  DEBUG_EXPR(TESTER_COMP, MedPrio, m_node);
  DEBUG_EXPR(TESTER_COMP, MedPrio, m_status);

  if (m_status == RequestGeneratorStatus_Thinking) {
    m_status = RequestGeneratorStatus_Test_Pending;
    m_last_transition = g_eventQueue_ptr->getTime();
    initiateTest();  // Test
  } else if (m_status == RequestGeneratorStatus_Holding) {
    m_status = RequestGeneratorStatus_Release_Pending;
    m_last_transition = g_eventQueue_ptr->getTime();
    initiateRelease();  // Release
  } else if (m_status == RequestGeneratorStatus_Before_Swap) {
    m_status = RequestGeneratorStatus_Swap_Pending;
    m_last_transition = g_eventQueue_ptr->getTime();
    initiateSwap();
  } else {
    WARN_EXPR(m_status);
    ERROR_MSG("Invalid status");
  }
}
Пример #3
0
/*
main(...)
This just sets up all the ROS stuff and serves as the primary top level menu
*/
int main(int argc, char **argv)
{
	//Standard ROS startup
	ros::init(argc, argv, "ControlsMenu");
	ros::NodeHandle n;
	
	//setup client services
	createSimulatedPlaneClient = n.serviceClient<AU_UAV_ROS::CreateSimulatedPlane>("create_simulated_plane");
	deleteSimulatedPlaneClient = n.serviceClient<AU_UAV_ROS::DeleteSimulatedPlane>("delete_simulated_plane");
	requestPlaneIDClient = n.serviceClient<AU_UAV_ROS::RequestPlaneID>("request_plane_ID");
	goToWaypointClient = n.serviceClient<AU_UAV_ROS::GoToWaypoint>("go_to_waypoint");
	loadPathClient = n.serviceClient<AU_UAV_ROS::LoadPath>("load_path");
	loadCourseClient = n.serviceClient<AU_UAV_ROS::LoadCourse>("load_course");
	saveFlightDataClient = n.serviceClient<AU_UAV_ROS::SaveFlightData>("save_flight_data");
	
	//set up the menu
	int choice = 0;
	
	//loop until the user asks to quit
	while(choice != 5)
	{
		printf("\nStandard Controller Menu:\n");
		printf("1-Simulator Controls\n");
		printf("2-Path Planning\n");
		printf("3-Save all data\n");
		printf("4-Initiate test flight\n");
		printf("5-Exit Program\n");
		printf("Choice:");
		scanf("%d", &choice);
		system("clear");
		
		switch(choice)
		{
			case 1:
			{
				simulatorMenu();
				break;
			}
			case 2:
			{
				pathMenu();
				break;
			}
			case 3:
			{
				char filename[256];
				printf("\nEnter the filename to save to:");
				scanf("%s", filename);
				
				AU_UAV_ROS::SaveFlightData srv;
				srv.request.filename = filename;
				
				if(saveFlightDataClient.call(srv))
				{
					printf("Flight data saved successfully!\n");
				}
				else
				{
					ROS_ERROR("Error saving flight data");
				}
				
				break;
			}
			case 4:
			{
				initiateTest();
				break;
			}
			case 5:
			{
				//nothing to do but leave
				break;
			}
			default:
			{
				printf("Invalid choice.\n");
				break;
			}
		}
	}
	
	return 0;
}