Ejemplo n.º 1
0
void hotspot::simulation(){

    if(!enableSimulation)
    {
        tree->addParent(uav);
        tree->currentchildren(HexSamples);
        enableSimulation=true;

    }

        // compute cost and info
      MatrixXf nei(6,2),subgoal(6,2);
      VectorXf MeasurementAttribute(6);

      nei=array2Mat(HexSamples);
      subgoal=repeatMat(target);
      if(step%3==0)
          MeasurementAttribute=distance(subgoal,subgoal);
      else
          MeasurementAttribute=distance(subgoal,nei);
//
      updateMeasurement(MeasurementAttribute.data());

     // termination condition
    float near=sqrt(pow(target[0]-uav[0],2)+pow(target[1]-uav[1],2));
     ROS_INFO_STREAM("step:= "<<step<< " distance:= "<<near);
     step++;

     sleep(1);
     return (step<50&&near>1)?simulation():optimal_path_publish();

}
Ejemplo n.º 2
0
//--------------------------------------------------------------
void ofApp::setup() {

    #ifdef TARGET_OPENGLES
    // While this will will work on normal OpenGL as well, it is 
    // required for OpenGL ES because ARB textures are not supported.
    // If this IS set, then we conditionally normalize our 
    // texture coordinates below.
    ofEnableNormalizedTexCoords();
    #endif

	img.load("linzer.png");
	
	// OF_PRIMITIVE_TRIANGLES means every three vertices create a triangle
	mesh.setMode(OF_PRIMITIVE_TRIANGLES);
	int skip = 10;	// this controls the resolution of the mesh
	
	int width = img.getWidth();
	int height = img.getHeight();

	ofVec2f imageSize(width,height);

	ofVec3f zero(0, 0, 0);
	for(int y = 0; y < height - skip; y += skip) {
		for(int x = 0; x < width - skip; x += skip) {
			/*
			 To construct a mesh, we have to build a collection of quads made up of
			 the current pixel, the one to the right, to the bottom right, and
			 beneath. These are called nw, ne, se and sw. To get the texture coords
			 we need to use the actual image indices.
			 */
			ofVec3f nw = getVertexFromImg(img, x, y);
			ofVec3f ne = getVertexFromImg(img, x + skip, y);
			ofVec3f sw = getVertexFromImg(img, x, y + skip);
			ofVec3f se = getVertexFromImg(img, x + skip, y + skip);
			ofVec2f nwi(x, y);
			ofVec2f nei(x + skip, y);
			ofVec2f swi(x, y + skip);
			ofVec2f sei(x + skip, y + skip);
			
			// ignore any zero-data (where there is no depth info)
			if(nw != zero && ne != zero && sw != zero && se != zero) {
				addFace(mesh, nw, ne, se, sw);

				// Normalize our texture coordinates if normalized 
				// texture coordinates are currently enabled.
				if(ofGetUsingNormalizedTexCoords()) {
					nwi /= imageSize;
					nei /= imageSize;
					sei /= imageSize;
					swi /= imageSize;
				}

				addTexCoords(mesh, nwi, nei, sei, swi);
			}
		}
	}
	
	vboMesh = mesh;
}
int main()
{
    int i,cas;

    scanf("%d",&cas);
    getchar();
    for(i=0;i<cas;i++)
    {
        gets(ch);
        ji1=0;
        while(gets(ch)!=NULL)
        {
            if(0 == strcmp(ch,"END"))
                break;
            oj[ji1]=ch;
            ji1++;
        }
        
        gets(ch);
        ji2=0;
        while(gets(ch)!=NULL)
        {
            if(0 == strcmp(ch,"END"))
                break;
            own[ji2]=ch;
            ji2++;
        }
    
        if(1 == cmp())
        {
            printf("Accepted\n");
            continue;
        }
        if(1 == nei())
        {
            printf("Presentation Error\n");
            continue;
        }
        printf("Wrong Answer\n");
    }
    return 0;
}
Ejemplo n.º 4
0
//next best location
 void hotspot::updateMeasurement(float attribute[6])
{

    MatrixXf nei(6,2),iniPos(6,2),dummy;
    iniPos=repeatMat(initialRobotPosition);
    dummy=repeatMat(target);
    nei=array2Mat(HexSamples);

    VectorXf BaseCost(6),goalCost;
    BaseCost=distance( iniPos , nei);
    goalCost=distance(dummy,nei);


 //find direction based on measurement
    int local_best;
 //----------------------------------------------------------------
    //update measurement based on measurement gain
//    float curr_max[1],curr_min[1];
//    minMax(attribute,curr_max,curr_min);
//    local_best=tree->sampleMeasurement(attribute,BaseCost.data());

//    if(curr_max[0]-curr_min[0]<1.2)
//        local_best=area_coverage->area_coverage_direction(uav);
//    else
//        local_best=area_coverage->area_coverage_direction(uav,local_best);

//----------------------------------------------------------------
    local_best=tree->sampleMeasurement(goalCost.data(),BaseCost.data());
    updateParentLocation(uav,local_best);
    tree->addParent(uav);
    tree->currentchildren(HexSamples);
    ROS_INFO("updated uav (%f, %f)",uav[0],uav[1]);
    sampling_path_publish();



}