int
NdbRestarter::rollingRestart(Uint32 flags)
{
  if (getStatus() != 0)
    return -1;
  
  NdbNodeBitmask ng_mask;
  NdbNodeBitmask restart_nodes;
  Vector<int> nodes;
  for(unsigned i = 0; i < ndbNodes.size(); i++)
  { 
    if (ng_mask.get(ndbNodes[i].node_group) == false)
    {
      ng_mask.set(ndbNodes[i].node_group);
      nodes.push_back(ndbNodes[i].node_id);
      restart_nodes.set(ndbNodes[i].node_id);
    }
  }

loop:  
  if (ndb_mgm_restart2(handle, nodes.size(), nodes.getBase(),
                       (flags & NRRF_INITIAL) != 0, 
                       (flags & NRRF_NOSTART) != 0,
                       (flags & NRRF_ABORT) != 0 || true) <= 0)
  {
    return -1;
  }
  
  if (waitNodesNoStart(nodes.getBase(), nodes.size()))
    return -1;

  if (startNodes(nodes.getBase(), nodes.size()))
    return -1;

  if (waitClusterStarted())
    return -1;

  nodes.clear();
  for (Uint32 i = 0; i<ndbNodes.size(); i++)
  {
    if (restart_nodes.get(ndbNodes[i].node_id) == false)
    {
      nodes.push_back(ndbNodes[i].node_id);
      restart_nodes.set(ndbNodes[i].node_id);
    }
  }
  if (nodes.size())
    goto loop;
  
  return 0;
}
Пример #2
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;
}
Пример #3
0
int main(int argc, char **argv)
{
	//Standard ROS startup
	ros::init(argc, argv, "evaluator");
	ros::NodeHandle n;
	
	//set up ROS messages
	ros::Subscriber sub = n.subscribe("telemetry", 1000, telemetryCallback);
	
	//set up ROS services
	AU_UAV_ROS::LoadCourse srv;
	createSimulatedPlaneClient = n.serviceClient<AU_UAV_ROS::CreateSimulatedPlane>("create_simulated_plane");
	deleteSimulatedPlaneClient = n.serviceClient<AU_UAV_ROS::DeleteSimulatedPlane>("delete_simulated_plane");
	loadCourseClient = n.serviceClient<AU_UAV_ROS::LoadCourse>("load_course");
	saveFlightDataClient = n.serviceClient<AU_UAV_ROS::SaveFlightData>("save_flight_data");

	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");
	
	//make sure all other nodes have time to activate
	sleep(1);
	system("clear");
	
	//get the file input
	char filename[256];
	printf("\nEnter the filename of the course to load 22:");
	scanf("%s", filename);
	
	printf("\nEnter the filename for output:");
	scanf("%s", scoresheetFilename);

	printf("Enter the length of simulation in seconds: ");
	scanf("%d",&TIME_LIMIT);

	sleep(1);
	startNodes();
	sleep(1);

	//create all our UAVs
	if(createCourseUAVs(filename))
	{
		//nothing bad happened
	}
	else
	{
		ROS_ERROR("Error creating UAVs");
		return 1;
	}
	
	srv.request.filename = (ros::package::getPath("AU_UAV_ROS")+"/courses/"+filename).c_str();

	//countdown to success
	system("clear");
	printf("\n");
	printf("Last Plane ID: %d\n", lastPlaneID);
	printf("KML File: %s.kml\n", scoresheetFilename);
	printf("Score File: %s.score\n", scoresheetFilename);
	printf("Loading course into coordinator in...\n3...\n");
	ros::Duration(1.0).sleep();
	printf("2...\n");
	ros::Duration(1.0).sleep();
	printf("1...\n");
	ros::Duration(1.0).sleep();

	
	
	//call the load course function on the coordinator
	if(loadCourseClient.call(srv))
	{
		printf("Course loaded successfully!\n");
	}
	else
	{
		ROS_ERROR("Error loading course");
	}
	
	//set the start time to now
	startTime = ros::Time::now();
	
	//planes are created, lets spin for telemetry updates
	ros::spin();
}