Commit 33bf5bb1 authored by limingbo's avatar limingbo

test

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