Commit 73f8f8fc authored by limingbo's avatar limingbo

add period

parent 732b7821
This diff is collapsed.
......@@ -22,7 +22,7 @@ vector<string> getActiveTraces(
void getCrossTasks(
const vector<string> &allTask,
vector<string> &crossTasks)
vector<pair<string, vector<pair<float, float>>>> &crossTasks)
{
if(allTask.size() < 2){
return;
......@@ -152,9 +152,9 @@ bool checkMeshOut(
return false;
}
vector<string> crossFilter(
vector<pair<string, vector<pair<float, float>>>> crossFilter(
const vector<TaskInfo> &filteredTaskInfo){
vector<string> ret;
vector<pair<string, vector<pair<float, float>>>> ret;
if(filteredTaskInfo.size() < 2){
return ret;
}
......@@ -175,17 +175,37 @@ vector<string> crossFilter(
octree.addPointsFromInputCloud();
for(size_t pcIndex = 1; pcIndex < pointClouds.size(); pcIndex++){
bool found = false;
bool inPeriod = false;
float start =0, end = 0;
pair<string, vector<pair<float, float>>> oneRet;
vector<pair<float, float>> timePeriods;
float currTime;
for(const PointExport& query : pointClouds[pcIndex]->points){
int result_index;
float sqr_distance;
octree.approxNearestSearch(query, result_index, sqr_distance);
if(sqr_distance < 10){
found = true;
break;
if(!inPeriod){
start = query.info;
inPeriod = true;
}
}else{
if(inPeriod){
end = query.info;
inPeriod = false;
timePeriods.push_back(make_pair(start, end));
}
}
currTime = query.info;
}
if(inPeriod){
timePeriods.push_back(make_pair(start, currTime));
}
if(found){
ret.push_back(filteredTaskInfo[pcIndex].taskPath);
oneRet = make_pair(filteredTaskInfo[pcIndex].taskPath,
timePeriods);
ret.push_back(oneRet);
}
}
return ret;
......@@ -249,6 +269,7 @@ void getPointCloud(boost::shared_ptr<LocalCartesian> proj,
point.x = translation.x();
point.y = translation.y();
point.z = translation.z();
point.info = trajPoint.timestamp;
pointCloud->push_back(point);
}
}
......
......@@ -18,7 +18,9 @@ vector<string> getCloseTasks(
const string &parentPath,
boost::shared_ptr<Trajectory> currTraj);
void getCrossTasks(const vector<string> &allTask, vector<string> &crossTasks);
void getCrossTasks(
const vector<string> &allTask,
vector<pair<string, vector<pair<float, float> > > > &crossTasks);
bool getTaskInfo(
const string &taskPath,
......@@ -35,7 +37,7 @@ bool checkMeshOut(
const MeshOut& query,
const MeshOut& target);
vector<string> crossFilter(
vector<pair<string, vector<pair<float, float>>>> crossFilter(
const vector<TaskInfo> &filteredTaskInfo);
bool initTrajectory(const string &trajPath,
......
......@@ -35,20 +35,20 @@ int main(int argc, char *argv[])
}
activeTraces.insert(activeTraces.begin(), FLAGS_base_dir);
vector<string> crossTasks;
vector<pair<string, vector<pair<float, float>>>> crossTasks;
getCrossTasks(activeTraces, crossTasks);
if(crossTasks.size() == 0){
LOG(WARNING) << "crossTasks.size() == 0";
}else{
sort(crossTasks.begin(), crossTasks.end(),
[](const string& query, const string& target) {
return stoi(boost::filesystem::path(query).filename().string()) <
stoi(boost::filesystem::path(target).filename().string());
[](const auto& query, const auto& target) {
return stoi(boost::filesystem::path(query.first).filename().string()) <
stoi(boost::filesystem::path(target.first).filename().string());
});
}
for(string task : crossTasks){
LOG(INFO) << "cross task chekc in: " << task;
for(auto task : crossTasks){
LOG(INFO) << "cross task chekc in: " << task.first;
}
string outputPath = FLAGS_base_dir + "/multiTraj.txt";
......@@ -59,8 +59,13 @@ int main(int argc, char *argv[])
}
if(crossTasks.size() != 0){
// ofs << crossTasks.back() << std::endl;
for(string task : crossTasks){
ofs << task << std::endl;
for(auto task : crossTasks){
ofs << task.first;
for(auto period : task.second){
ofs << " " << period.first << " " << period.second;
}
ofs << std::endl;
}
}
ofs.close();
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment