Exemple #1
0
int main(int argc, char* argv[]){
	int data[MAXCHAN];
	int bit = 0;
	int retries;

	if (argc > 1){
		maxchan = atoi(argv[1]);
	}

	printf( "%s maxchan %d\n", "$Version:$", maxchan);

	for (bit = 0; bit < 32; ++bit){
//		printf("bit %d\n", bit);

		setDIO32_bit(bit, 1);

		retries = 0;
		do {
			getMeans(data);
//			show_treshold(data);
		} while(over_threshold(data) == 0 && ++retries < 20);

		if (retries >= 20){
			show_threshold(data, bit);
			fprintf(stderr, "ERROR:TIMEOUT waiting for non-zero\n");
		}

		if (over_threshold(data) < maxchan/32){
			fprintf(stderr, "ERROR: bust channel? %d\n",
					bit+1);
		}else if (over_threshold(data) != maxchan/32){
			fprintf(stderr, "ERROR: crossed wires! %d\n",
					bit + 1);
		}
		show_threshold(data, bit);

		setDIO32_bit(bit, 0);

		retries = 0;
		do {
			getMeans(data);
//			show_threshold(data);
		} while (over_threshold(data) && ++retries < 20);

		if (retries >= 20){
			show_threshold(data, bit);
			fprintf(stderr, "ERROR:TIMEOUT waiting for zero\n");
		}
	}

	return 0;
}
void ExportMeanDialog::requestMeans(){
    // find out which button is requested... hmm,
    // this is ugly, but ..
    int norm = 0;
    if(zscore->isChecked()){ norm = 1; }
    if(mscore->isChecked()){ norm = 2; }
    if(raw->isChecked()){ norm = 3; }
    if(!norm){
	QMessageBox::information(this, "Error", "You must select one normalisation method", QMessageBox::Ok);
	return;
    }
    QString file = fileName->text();
    if(file.isNull() || file == ""){
	QMessageBox::information(this, "Error", "You must specify the file name", QMessageBox::Ok);
	return;
    }
    emit getMeans(file, norm);
    hide();
}
void LslidarN301Decoder::publishScan()
{
	sensor_msgs::LaserScan::Ptr scan(new sensor_msgs::LaserScan);

  if(sweep_data->scans[0].points.size() <= 1)
		return;

	scan->header.frame_id = child_frame_id;
	
	scan->angle_max = 0.0;
	scan->angle_min = 2.0*M_PI;
	scan->angle_increment = (scan->angle_max-scan->angle_min)/3600;

	//	scan->time_increment = motor_speed_/1e8;
	scan->range_min = 0.05;
	scan->range_max = 100.0;
	scan->ranges.reserve(3600);
	scan->intensities.reserve(3600);

  std::vector<point_struct> mean_points[3600] = {};
  point_struct temp_point;
  for(uint16_t i = 0; i < sweep_data->scans[0].points.size(); i++)
  {
    int degree = round(sweep_data->scans[0].points[i].azimuth * RAD_TO_DEG * 10);
    //ROS_INFO("degree = %d", degree);
    if (degree >= 3600) degree = 0;
    if (degree < 0) degree = 3599;
    if((degree<(1800+laser_number))&&(degree>(1800-laser_number)))				
	{
		
    		//ROS_INFO("degree = %d", degree);
		temp_point.distance=std::numeric_limits<float>::infinity();
		temp_point.intensity = 0;
	}
	else
	{
		
		temp_point.distance = sweep_data->scans[0].points[i].distance;
		temp_point.intensity = sweep_data->scans[0].points[i].intensity;
	}
	
    mean_points[degree].push_back(temp_point);
  }

  // calc mean


  point_struct mean_point;
  for(uint16_t i = 0; i < 3600; i++)
	{
//    ROS_INFO("%f", sweep_data->scans[0].points[i].azimuth);
    if ( mean_points[i].size() == 0)
    {
      scan->ranges.push_back(0);
      scan->intensities.push_back(0);
      continue;
    }
    mean_point = getMeans(mean_points[i]);
    scan->ranges.push_back(mean_point.distance);
    scan->intensities.push_back(mean_point.intensity);
	}
	scan->header.stamp = ros::Time::now();
	scan_pub.publish(scan);

}
Exemple #4
0
int lasp::load_sparse_data(const char* filename,
						   lasp::svm_sparse_data& myData)
{
    int pointCount = 0;
	ifstream fin;
	fin.open(filename);
	if(fin) {
		bool zeroIndexed = false;
		int maxIndex = -1;
		char curLine[LINE_SIZE];// (Yu)LINE_SIZE is defined in svm.h and the value is 100000
		
		while(fin.getline(curLine, LINE_SIZE)) {
			vector<svm_node> currentNodes;
			char* tokens = strtok(curLine, " ");
            
            // (Yu) this piece of code is used to store the label of each data into orderSeen
            // (Yu) if the data includes labels, seen becomes to true.
			int classification = lasp_atoi(tokens);
			bool seen = false;
			for(int i = 0; i < myData.orderSeen.size(); ++i) {
                
                //(Yu) by default, orderSeen is a vector with all 0s
				if(classification == myData.orderSeen[i]) {
					seen = true;
					break;
                    
				}
			}
			
			myData.pointOrder.push_back(classification);
			if (!seen) myData.orderSeen.push_back(classification);
			tokens = strtok(NULL, " "); //move forward one token
			while(tokens) {
				//parsing stuff, kind of messy, but gets job done.
				string oneToken;
				oneToken.assign(tokens);
				size_t found = oneToken.find(":");
				string index = oneToken.substr(0,found);
				if (lasp_atoi(index.c_str()) == 0){
					zeroIndexed = true;
				}
				string value = oneToken.substr(found+1, oneToken.length());
				
				svm_node newNode;
				newNode.index = lasp_atoi(index.c_str());
				newNode.value = lasp_atof(value.c_str());
				if(newNode.index > maxIndex) maxIndex = newNode.index;
				currentNodes.push_back(newNode);
				tokens = strtok(NULL, " ");
			}
			myData.allData[classification].push_back(currentNodes);
			pointCount ++;
		}
		myData.numPoints = pointCount;
		
		//I hate this piece of code, but I don't want to try to figure out a better way to deal with zero-indexed files (Gabe)
		if(zeroIndexed){
			maxIndex++;
			for(map<int, vector<vector<svm_node> > >::iterator iter = myData.allData.begin(); iter != myData.allData.end(); ++iter){
				for(vector<vector<svm_node> >::iterator iter2 = iter->second.begin(); iter2 != iter->second.end(); ++iter2){
					for(vector<svm_node>::iterator iter3 = iter2->begin(); iter3 != iter2->end(); ++iter3){
						iter3->index++;
					}
				}
			}
		}
		
        
		myData.numFeatures = maxIndex;
		myData.multiClass = myData.allData.size() > 2;
		fin.close();
        
        //(Yu)
        // get the full data which is gonna be used to compute the means and standard deviations
        lasp::svm_full_data fullData;
        sparse_data_to_full(fullData, myData);
        
        //(Yu)
        // get the means and standard deviation vectors
        getMeans(fullData, myData);
        getStandDeviations(fullData, myData);
        
		return 0;
	}
	else {
		cout << " The file \' "<< filename << "\' was not found." << endl;
		cout << "You must specify an existing file to read your" << endl;
		cout << "training data from." << endl;
		return UNOPENED_FILE_ERROR;
	}
    
}