Esempio n. 1
0
int main()
{	
	camera_open();
	ssp(SORT_SERVO,START);
	ssp(RED_SERVO,RED_START);
	ssp(GREEN_SERVO,GREEN_START);
	
	wait_for_light(0);
	start();
	shut_down_in(119);
	
	enable_servos();
	msleep(5000);
	reset();
	
	right(47,0);
	forward(35);
	right(10,0);
	backward(46);
	full_sort();
	other_side();
	ssp(GREEN_SERVO,GREEN_DUMP);
	msleep(1000);
	ssp(GREEN_SERVO,GREEN_START);
	msleep(250);
	now();
	ao();
	disable_servos();
}
Esempio n. 2
0
void shake() {
	off(REVOLVE_MOTOR);
	ao();
	enable_servos();
	int i;
	for(i=0; i<20; i++){
		ssp(0,1333);
		msleep(170);
		ssp(0,1260);
		msleep(170);
	}
	disable_servos();
	motor(REVOLVE_MOTOR, 100);

}
Esempio n. 3
0
static void load_mmls(const Plugin& plugin, XML_Loader_SDL& loader)
{
  ScopedSearchPath ssp(plugin.directory);
  for (std::vector<std::string>::const_iterator it = plugin.mmls.begin();
       it != plugin.mmls.end(); ++it)
  {
    FileSpecifier file;
    file.SetNameWithPath(it->c_str());
    loader.ParseFile(file);
  }
}
Esempio n. 4
0
void dance(){
	int i=0;
	enable_servos();
	while(1){
		if(i%6<3){
			motor(MOT_LEFT, 40);
			motor(MOT_RIGHT, 30);
		}else{
			motor(MOT_LEFT, -40);
			motor(MOT_RIGHT, -30);
		}
		ssp(0,1133);
		msleep(200);
		ssp(0,1060);
		msleep(200);
		now();
		i++;
	}
	disable_servos();
}
Esempio n. 5
0
	Item::this_type& Item::wait_state(State state, DWORD dwTimeout)
	{
		DWORD dwStartTime = ::GetTickCount();
		while (true) {
			Status ssp(get_status());
			if (ssp.dwCurrentState == (DWORD)state)
				break;
			if (::GetTickCount() - dwStartTime > dwTimeout)
				CheckApiError(WAIT_TIMEOUT);
			::Sleep(500);
		};
		return *this;
	}
Esempio n. 6
0
int CPointsCollection::EditPoint(int index, double x, double y, BOOL bRescan)
{
	if (index<0 || index>=GetSize()) return -1;
	int ret;
	SSinglePoint ssp(x, y);
	//if bSortX not specified - just replace given point
	RemovePoint(index, FALSE);
	if (!bSortX)
	{
		InsertPoint(index, ssp.x, ssp.y, bRescan);
		ret = index;
	} else
	{
		int res;
		ret = AddPoint(&ssp, bRescan, &res);
	};
	return ret;
}
Esempio n. 7
0
int CPointsCollection::InsertPoint(int index, double x, double y, BOOL bRescan)
{
	if (index<0 || index>GetSize()) return -1;
	SSinglePoint ssp(x, y);
	int res, ret;
	if (index == GetSize())
	{ //this is just append point
		ret = AddPoint(&ssp, bRescan, &res);
	} else
	{
	if (!bSortX)
	{
		points.insert(points.begin() + index, ssp);
		if (bRescan) RescanPoints();
		ret = index;
	} else
	{
		ret = AddPoint(&ssp, bRescan, &res);
	};
	};
	return ret;
}
Esempio n. 8
0
int main()
{
	clock_t startTime, endTime;
	double duration;
	startTime = clock();
	vector<int> mp = { 1,3, 4 };  //必须经过的顶点集合
	const int size = 5;
	vector<vector<int> > graph(size);
	for (int i = 0; i < size; ++i) {
		graph[i].resize(size);
	}
	for (int i = 0; i < size; ++i) {
		for (int j = 0; j < size; ++j) {
			graph[i][j] = -1;
		}
	}
	/*graph[0][1] = 2;
	graph[0][2] = 3;
	graph[0][3] = 4;
	graph[1][2] = 3;
	graph[1][5] = 2;
	graph[1][4] = 7;
	graph[2][5] = 9;
	graph[2][6] = 2;
	graph[3][6] = 2;
	graph[4][7] = 3;
	graph[4][8] = 3;
	graph[5][6] = 1;
	graph[5][8] = 3;
	graph[6][9] = 1;
	graph[6][8] = 5;
	graph[7][10] = 3;
	graph[8][10] = 2;
	graph[9][8] = 2;
	graph[9][10] = 2;*/

	graph[0][4] = 3;
	graph[4][1] = 2;
	graph[1][2] = 5;
	graph[2][4] = 6;
	graph[3][1] = 1;
	graph[1][3] = 3;

	ss_shortest_paths ssp(graph);  //10是结束顶点,起始顶点是0
	int start_node = 0, end_node = 3;
	//ssp.shortest_paths(mp, 0, 3);
	/*ssp.shortest_paths(mp, 2, 5);
	ssp.shortest_paths(mp, 5, 6);
	ssp.shortest_paths(mp, 6, 8);
	ssp.shortest_paths(mp, mp[mp.size()-1], end_node);*/

 	if (ssp.judgeNA(mp, start_node, end_node) == false)
		printf_s("NA\n");
	else
		printf_s("NO  NA\n");
	//ssp.print_spaths();
	/*计算花费的时间*/
	endTime = clock();
	duration = (double)(endTime - startTime) / CLOCKS_PER_SEC;
	cout << "times use: " << duration << endl;
	return 0;
}
Esempio n. 9
0
int CPointsCollection::AddPoint(double _x, double _y, BOOL bReScan, int* res)
{
	int index;
	//adjust max and min
	if (GetSize() == 0)
	{
		max_x = min_x = _x;
		max_y = min_y = _y;
	} else
	{
		if (max_x<_x) max_x = _x;
		if (min_x>_x) min_x = _x;
		if (max_y<_y) max_y = _y;
		if (min_y>_y) min_y = _y;
	};
	SSinglePoint ssp(_x, _y);
	SSinglePoint spoint;
	long array_size = GetSize();
	if (!bSortX)
	{//if there is no sort - just add the point to the end of array
		points.push_back(ssp);
		index = array_size;
	} else
	{
		//find the place for new element
		if (array_size == 0)
		{
			points.push_back(ssp);
			index = array_size;
		} else
		{
			//check lower bound
			GetPoint(0, &spoint);
			if (_x<spoint.x)
			{
				index = 0;
				points.insert(points.begin() + index, ssp);
			} else
			{
				//check upper bound
				GetPoint(array_size-1, &spoint);
				if (_x>spoint.x)
				{
					points.push_back(ssp);
					index = array_size;
				} else
				{
					index = 0;
					BOOL bFit = FALSE;
					for (int i=0; i<array_size; i++)
					{
						GetPoint(i, &spoint);
						if (spoint.x == _x)
						{
							index = i;
							bFit = TRUE;
							break;
						};
						if (_x<spoint.x)
						{
							index = i;
							break;
						};
					};
					if (bFit)
					{
						if (bKeepSameX)
						{
							points.insert(points.begin() + index, ssp);
						} else
						{
							RemovePoint(index, FALSE);//do not rescan right away - cause we add one more point right after
							points.insert(points.begin() + index, ssp);
							//need to recalculate extremums
							if (bReScan) RescanPoints();
						};
					} else
					{
						//just insert point before index
						points.insert(points.begin() + index, ssp);
					};
				};
			};
		};
	};
	return index;
}