Commit 33bf5bb1 authored by limingbo's avatar limingbo

test

parent 5a45d7f5
Pipeline #869 canceled with stages
...@@ -19,32 +19,35 @@ vector<string> getCloseTasks( ...@@ -19,32 +19,35 @@ vector<string> getCloseTasks(
if(!is_directory(rawTraceDir)){ if(!is_directory(rawTraceDir)){
continue; continue;
} }
string iePath = rawTraceDir + "/sample.gps"; string trajPath = rawTraceDir + "/sample.gps";
if(!exists(iePath)){ if(!exists(trajPath)){
trajPath = rawTraceDir + "/ie.txt";;
}
if(!exists(trajPath)){
continue; continue;
} }
if(currTraj->getTrajPath() == iePath){ if(currTraj->getTrajPath() == trajPath){
continue; continue;
} }
TrajPoint trajPoint; TrajPoint trajPoint;
if(getFstTraj(iePath, trajPoint, proj)){ if(!getFstTraj(trajPath, trajPoint, proj)){
continue; continue;
} }
if(trajPoint.translation.norm() > 30000){ if(trajPoint.translation.norm() > 30000){
continue; continue;
} }
closeTasks.push_back(iePath); closeTasks.push_back(trajPath);
} }
return closeTasks; return closeTasks;
} }
bool getFstTraj(const string &iePath, bool getFstTraj(const string &trajPath,
TrajPoint& trajPoint, TrajPoint& trajPoint,
boost::shared_ptr<LocalCartesian> proj){ boost::shared_ptr<LocalCartesian> proj){
std::ifstream ifs(iePath); std::ifstream ifs(trajPath);
if(!ifs){ if(!ifs){
LOG(WARNING) << iePath << " load fail!"; LOG(WARNING) << trajPath << " load fail!";
return false; return false;
} }
string line; string line;
...@@ -111,16 +114,16 @@ vector<string> getCrossTasks( ...@@ -111,16 +114,16 @@ vector<string> getCrossTasks(
} }
vector<boost::shared_ptr<Trajectory>> multiThreadInitTrajectory( vector<boost::shared_ptr<Trajectory>> multiThreadInitTrajectory(
const vector<string> &iePaths) const vector<string> &trajPaths)
{ {
vector<ThreadPtr> thread_vec; vector<ThreadPtr> thread_vec;
vector<boost::shared_ptr<Trajectory>> trajectories; vector<boost::shared_ptr<Trajectory>> trajectories;
trajectories.resize(iePaths.size()); trajectories.resize(trajPaths.size());
for(uint8_t thread_index = 0; thread_index < iePaths.size(); thread_index++){ for(uint8_t thread_index = 0; thread_index < trajPaths.size(); thread_index++){
// thread_vec.emplace_back(ThreadPtr(new boost::thread(boost::bind(&initTrajectory, // thread_vec.emplace_back(ThreadPtr(new boost::thread(boost::bind(&initTrajectory,
// iePaths[thread_index], // iePaths[thread_index],
// trajectories[thread_index])))); // trajectories[thread_index]))));
initTrajectory(iePaths[thread_index], trajectories[thread_index]); initTrajectory(trajPaths[thread_index], trajectories[thread_index]);
} }
for(uint8_t thread_index = 0; thread_index < thread_vec.size(); thread_index++){ for(uint8_t thread_index = 0; thread_index < thread_vec.size(); thread_index++){
thread_vec[thread_index]->join(); thread_vec[thread_index]->join();
...@@ -129,12 +132,19 @@ vector<boost::shared_ptr<Trajectory>> multiThreadInitTrajectory( ...@@ -129,12 +132,19 @@ vector<boost::shared_ptr<Trajectory>> multiThreadInitTrajectory(
return trajectories; return trajectories;
} }
void initTrajectory( bool initTrajectory(
const string &iePath, const string &trajPath,
boost::shared_ptr<Trajectory> &trajectory) boost::shared_ptr<Trajectory> &trajectory)
{ {
trajectory.reset(new Trajectory(iePath, PPK)); if(boost::filesystem::path(trajPath).stem() == "ie.txt"){
trajectory.reset(new Trajectory(trajPath, PPK));
}else if(boost::filesystem::path(trajPath).stem() == "sample.gps"){
trajectory.reset(new Trajectory(trajPath, PPK, 10));
}else{
return false;
}
trajectory->init(); trajectory->init();
return true;
} }
vector<PointCloudExport::Ptr> multiThreadGetPointCloud( vector<PointCloudExport::Ptr> multiThreadGetPointCloud(
...@@ -162,6 +172,9 @@ void getPointCloud(boost::shared_ptr<LocalCartesian> proj, ...@@ -162,6 +172,9 @@ void getPointCloud(boost::shared_ptr<LocalCartesian> proj,
boost::shared_ptr<Trajectory> &trajectory, boost::shared_ptr<Trajectory> &trajectory,
PointCloudExport::Ptr& pointCloud) PointCloudExport::Ptr& pointCloud)
{ {
if(!trajectory){
return;
}
vector<TrajPoint> traj = trajectory->getTrajectory(); vector<TrajPoint> traj = trajectory->getTrajectory();
for(const TrajPoint& trajPoint : traj){ for(const TrajPoint& trajPoint : traj){
PointExport point; PointExport point;
......
...@@ -9,7 +9,7 @@ vector<string> getCloseTasks( ...@@ -9,7 +9,7 @@ vector<string> getCloseTasks(
const string &parentPath, const string &parentPath,
boost::shared_ptr<Trajectory> currTraj); boost::shared_ptr<Trajectory> currTraj);
bool getFstTraj(const string &iePath, bool getFstTraj(const string &trajPath,
TrajPoint& trajPoint, TrajPoint& trajPoint,
boost::shared_ptr<LocalCartesian> proj); boost::shared_ptr<LocalCartesian> proj);
...@@ -17,10 +17,9 @@ vector<string> getCrossTasks( ...@@ -17,10 +17,9 @@ vector<string> getCrossTasks(
const vector<string> &closeTasks, const vector<string> &closeTasks,
boost::shared_ptr<Trajectory> currTraj); boost::shared_ptr<Trajectory> currTraj);
vector<boost::shared_ptr<Trajectory>> multiThreadInitTrajectory( vector<boost::shared_ptr<Trajectory>> multiThreadInitTrajectory(const vector<string> &trajPaths);
const vector<string> &iePaths);
void initTrajectory(const string &iePath, bool initTrajectory(const string &trajPath,
boost::shared_ptr<Trajectory> &trajectory); boost::shared_ptr<Trajectory> &trajectory);
vector<PointCloudExport::Ptr> multiThreadGetPointCloud( vector<PointCloudExport::Ptr> multiThreadGetPointCloud(
......
...@@ -25,8 +25,15 @@ int main(int argc, char *argv[]) ...@@ -25,8 +25,15 @@ int main(int argc, char *argv[])
FLAGS_logbufsecs = 0; FLAGS_logbufsecs = 0;
string ppk_dir_ = FLAGS_base_dir + "/raw_trace/sample.gps"; string ppk_dir_ = FLAGS_base_dir + "/raw_trace/sample.gps";
if(exists(ppk_dir_)){
ppk_traj_.reset(new Trajectory(ppk_dir_, PPK)); ppk_traj_.reset(new Trajectory(ppk_dir_, PPK, 10));
}else {
ppk_dir_ = FLAGS_base_dir + "/raw_trace/ie.txt";
if(!exists(ppk_dir_)){
return 0;
}
ppk_traj_.reset(new Trajectory(ppk_dir_, PPK));
}
ppk_traj_->init(); ppk_traj_->init();
LOG(INFO) << "Trajectory load done!"; LOG(INFO) << "Trajectory load done!";
......
...@@ -5,9 +5,13 @@ uint16_t MAX_REVERSE_CNT = 1; ...@@ -5,9 +5,13 @@ uint16_t MAX_REVERSE_CNT = 1;
uint16_t MIN_PPK_LINE_ITEM_CNT = 12; uint16_t MIN_PPK_LINE_ITEM_CNT = 12;
uint16_t MIN_NODE_LINE_ITEM_CNT = 10; uint16_t MIN_NODE_LINE_ITEM_CNT = 10;
Trajectory::Trajectory(const string &traj_path, const TrajType &trajType) Trajectory::Trajectory(
const string &traj_path,
const TrajType &trajType,
uint32_t frequency)
:trajectory_path_(traj_path), :trajectory_path_(traj_path),
trajType_(trajType) trajType_(trajType),
frequency_(frequency)
{ {
} }
...@@ -20,16 +24,19 @@ Trajectory::~Trajectory() ...@@ -20,16 +24,19 @@ Trajectory::~Trajectory()
bool Trajectory::init() bool Trajectory::init()
{ {
string range; string range;
switch(trajType_){ if(frequency_ != 0){
case PPK: switch(trajType_){
frequency_ = 1000; case PPK:
range = ","; frequency_ = 1000;
break; range = ",";
case NODE: break;
frequency_ = 10; case NODE:
range = " "; frequency_ = 10;
break; range = " ";
break;
}
} }
LOG(INFO) << "Trajectory set frequency: " << frequency_; LOG(INFO) << "Trajectory set frequency: " << frequency_;
io_ = new TextIO(trajectory_path_, range); io_ = new TextIO(trajectory_path_, range);
boost::function<void(const vector<string>&, uint8_t)> parse_callback = boost::function<void(const vector<string>&, uint8_t)> parse_callback =
......
...@@ -9,7 +9,10 @@ using namespace GeographicLib; ...@@ -9,7 +9,10 @@ using namespace GeographicLib;
class Trajectory class Trajectory
{ {
public: public:
Trajectory(const string &traj_path, const TrajType &trajType); Trajectory(
const string &traj_path,
const TrajType &trajType,
uint32_t frequency = 0);
~Trajectory(); ~Trajectory();
...@@ -57,7 +60,7 @@ private: ...@@ -57,7 +60,7 @@ private:
const TrajType trajType_; const TrajType trajType_;
double frequency_; uint32_t frequency_;
TextIO* io_ = nullptr; TextIO* io_ = nullptr;
......
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